@contractspec/module.examples 3.8.8 → 3.8.10

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.
@@ -1,710 +1,11 @@
1
- // src/registry.ts
2
- import { ExampleRegistry } from "@contractspec/lib.contracts-spec/examples/registry";
3
-
4
- // src/builtins.ts
5
- import AgentConsole from "@contractspec/example.agent-console/example";
6
- import AiChatAssistant from "@contractspec/example.ai-chat-assistant/example";
7
- import AiSupportBot from "@contractspec/example.ai-support-bot/example";
8
- import AnalyticsDashboard from "@contractspec/example.analytics-dashboard/example";
9
- import CalendarGoogle from "@contractspec/example.calendar-google/example";
10
- import ContentGeneration from "@contractspec/example.content-generation/example";
11
- import CrmPipeline from "@contractspec/example.crm-pipeline/example";
12
- import DataGridShowcase from "@contractspec/example.data-grid-showcase/example";
13
- import EmailGmail from "@contractspec/example.email-gmail/example";
14
- import HarnessLab from "@contractspec/example.harness-lab/example";
15
- import InAppDocs from "@contractspec/example.in-app-docs/example";
16
- import IntegrationHub from "@contractspec/example.integration-hub/example";
17
- import IntegrationPosthog from "@contractspec/example.integration-posthog/example";
18
- import IntegrationStripe from "@contractspec/example.integration-stripe/example";
19
- import IntegrationSupabase from "@contractspec/example.integration-supabase/example";
20
- import KbUpdatePipeline from "@contractspec/example.kb-update-pipeline/example";
21
- import KnowledgeCanon from "@contractspec/example.knowledge-canon/example";
22
- import LearningJourneyAmbientCoach from "@contractspec/example.learning-journey-ambient-coach/example";
23
- import LearningJourneyCrmOnboarding from "@contractspec/example.learning-journey-crm-onboarding/example";
24
- import LearningJourneyDuoDrills from "@contractspec/example.learning-journey-duo-drills/example";
25
- import LearningJourneyPlatformTour from "@contractspec/example.learning-journey-platform-tour/example";
26
- import LearningJourneyQuestChallenges from "@contractspec/example.learning-journey-quest-challenges/example";
27
- import LearningJourneyRegistry from "@contractspec/example.learning-journey-registry/example";
28
- import LearningJourneyStudioOnboarding from "@contractspec/example.learning-journey-studio-onboarding/example";
29
- import LearningJourneyUiCoaching from "@contractspec/example.learning-journey-ui-coaching/example";
30
- import LearningJourneyUiGamified from "@contractspec/example.learning-journey-ui-gamified/example";
31
- import LearningJourneyUiOnboarding from "@contractspec/example.learning-journey-ui-onboarding/example";
32
- import LearningJourneyUiShared from "@contractspec/example.learning-journey-ui-shared/example";
33
- import LearningPatterns from "@contractspec/example.learning-patterns/example";
34
- import LifecycleCli from "@contractspec/example.lifecycle-cli/example";
35
- import LifecycleDashboard from "@contractspec/example.lifecycle-dashboard/example";
36
- import LocaleJurisdictionGate from "@contractspec/example.locale-jurisdiction-gate/example";
37
- import Marketplace from "@contractspec/example.marketplace/example";
38
- import MeetingRecorderProviders from "@contractspec/example.meeting-recorder-providers/example";
39
- import MessagingAgentActions from "@contractspec/example.messaging-agent-actions/example";
40
- import Minimal from "@contractspec/example.minimal/example";
41
- import OpenbankingPowens from "@contractspec/example.openbanking-powens/example";
42
- import OpencodeCli from "@contractspec/example.opencode-cli/example";
43
- import Personalization from "@contractspec/example.personalization/example";
44
- import PocketFamilyOffice from "@contractspec/example.pocket-family-office/example";
45
- import PolicySafeKnowledgeAssistant from "@contractspec/example.policy-safe-knowledge-assistant/example";
46
- import ProductIntent from "@contractspec/example.product-intent/example";
47
- import ProjectManagementSync from "@contractspec/example.project-management-sync/example";
48
- import SaasBoilerplate from "@contractspec/example.saas-boilerplate/example";
49
- import ServiceBusinessOs from "@contractspec/example.service-business-os/example";
50
- import TeamHub from "@contractspec/example.team-hub/example";
51
- import VersionedKnowledgeBase from "@contractspec/example.versioned-knowledge-base/example";
52
- import VideoApiShowcase from "@contractspec/example.video-api-showcase/example";
53
- import VideoDocsTerminal from "@contractspec/example.video-docs-terminal/example";
54
- import VideoMarketingClip from "@contractspec/example.video-marketing-clip/example";
55
- import VisualizationShowcase from "@contractspec/example.visualization-showcase/example";
56
- import VoiceProviders from "@contractspec/example.voice-providers/example";
57
- import WealthSnapshot from "@contractspec/example.wealth-snapshot/example";
58
- import WorkflowSystem from "@contractspec/example.workflow-system/example";
59
- var EXAMPLE_REGISTRY = [
60
- AgentConsole,
61
- AiChatAssistant,
62
- AiSupportBot,
63
- AnalyticsDashboard,
64
- CalendarGoogle,
65
- ContentGeneration,
66
- CrmPipeline,
67
- DataGridShowcase,
68
- EmailGmail,
69
- HarnessLab,
70
- InAppDocs,
71
- IntegrationHub,
72
- IntegrationPosthog,
73
- IntegrationStripe,
74
- IntegrationSupabase,
75
- KbUpdatePipeline,
76
- KnowledgeCanon,
77
- LearningJourneyAmbientCoach,
78
- LearningJourneyCrmOnboarding,
79
- LearningJourneyDuoDrills,
80
- LearningJourneyPlatformTour,
81
- LearningJourneyQuestChallenges,
82
- LearningJourneyRegistry,
83
- LearningJourneyStudioOnboarding,
84
- LearningJourneyUiCoaching,
85
- LearningJourneyUiGamified,
86
- LearningJourneyUiOnboarding,
87
- LearningJourneyUiShared,
88
- LearningPatterns,
89
- LifecycleCli,
90
- LifecycleDashboard,
91
- LocaleJurisdictionGate,
92
- Marketplace,
93
- MeetingRecorderProviders,
94
- MessagingAgentActions,
95
- Minimal,
96
- OpenbankingPowens,
97
- OpencodeCli,
98
- Personalization,
99
- PocketFamilyOffice,
100
- PolicySafeKnowledgeAssistant,
101
- ProductIntent,
102
- ProjectManagementSync,
103
- SaasBoilerplate,
104
- ServiceBusinessOs,
105
- TeamHub,
106
- VersionedKnowledgeBase,
107
- VideoApiShowcase,
108
- VideoDocsTerminal,
109
- VideoMarketingClip,
110
- VisualizationShowcase,
111
- VoiceProviders,
112
- WealthSnapshot,
113
- WorkflowSystem
114
- ];
115
-
116
- // src/registry.ts
117
- import { ExampleRegistry as ExampleRegistry2 } from "@contractspec/lib.contracts-spec/examples/registry";
118
- var globalRegistry = new ExampleRegistry;
119
- for (const example of EXAMPLE_REGISTRY) {
120
- globalRegistry.register(example);
121
- }
122
- var EXAMPLE_REGISTRY2 = globalRegistry.list();
123
- function listExamples() {
124
- return globalRegistry.list();
125
- }
126
- function getExample(key) {
127
- return globalRegistry.get(key);
128
- }
129
- function searchExamples(query) {
130
- return globalRegistry.search(query);
131
- }
132
- // src/runtime/context.tsx
133
- import { ApolloProvider } from "@apollo/client/react";
134
- import { web as web2 } from "@contractspec/lib.runtime-sandbox";
135
- import { useEffect, useMemo, useState } from "react";
136
- import {
137
- AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
138
- createAgentConsoleDemoHandlers,
139
- getAgentConsoleDashboardData
140
- } from "@contractspec/example.agent-console";
141
- import {
142
- createAnalyticsHandlers
143
- } from "@contractspec/example.analytics-dashboard";
144
- import {
145
- createCrmHandlers
146
- } from "@contractspec/example.crm-pipeline";
147
- import {
148
- createIntegrationHandlers
149
- } from "@contractspec/example.integration-hub";
150
- import {
151
- createMarketplaceHandlers
152
- } from "@contractspec/example.marketplace";
153
- import {
154
- createPolicySafeKnowledgeAssistantHandlers
155
- } from "@contractspec/example.policy-safe-knowledge-assistant";
156
- import {
157
- createSaasHandlers
158
- } from "@contractspec/example.saas-boilerplate";
159
- import {
160
- createWorkflowHandlers
161
- } from "@contractspec/example.workflow-system";
162
- import {
163
- TemplateRuntimeContext,
164
- useTemplateComponents,
165
- useTemplateRuntime
166
- } from "@contractspec/lib.example-shared-ui";
167
-
168
- // src/runtime/engine.ts
169
- import {
170
- agentDashboardMarkdownRenderer,
171
- agentListMarkdownRenderer,
172
- agentListReactRenderer,
173
- runListMarkdownRenderer,
174
- toolRegistryMarkdownRenderer
175
- } from "@contractspec/example.agent-console";
176
- import {
177
- analyticsDashboardMarkdownRenderer,
178
- dashboardListMarkdownRenderer,
179
- queryBuilderMarkdownRenderer
180
- } from "@contractspec/example.analytics-dashboard";
181
- import {
182
- crmDashboardMarkdownRenderer,
183
- crmPipelineMarkdownRenderer,
184
- crmPipelineReactRenderer
185
- } from "@contractspec/example.crm-pipeline";
186
- import {
187
- connectionListMarkdownRenderer,
188
- integrationDashboardMarkdownRenderer,
189
- syncConfigMarkdownRenderer
190
- } from "@contractspec/example.integration-hub";
191
- import {
192
- marketplaceDashboardMarkdownRenderer,
193
- orderListMarkdownRenderer,
194
- productCatalogMarkdownRenderer
195
- } from "@contractspec/example.marketplace";
196
- import {
197
- projectListMarkdownRenderer,
198
- projectListReactRenderer,
199
- saasBillingMarkdownRenderer,
200
- saasDashboardMarkdownRenderer
201
- } from "@contractspec/example.saas-boilerplate";
202
- import { visualizationShowcaseMarkdownRenderer } from "@contractspec/example.visualization-showcase/ui/renderers";
203
- import {
204
- workflowDashboardMarkdownRenderer,
205
- workflowDefinitionListMarkdownRenderer,
206
- workflowInstanceDetailMarkdownRenderer
207
- } from "@contractspec/example.workflow-system";
208
- import {
209
- createDefaultTransformEngine,
210
- registerBasicValidation,
211
- registerDefaultReactRenderer
212
- } from "@contractspec/lib.contracts-runtime-client-react/transform-engine";
213
- function createTemplateTransformEngine() {
214
- const engine = createDefaultTransformEngine();
215
- registerDefaultReactRenderer(engine);
216
- registerBasicValidation(engine);
217
- registerTemplateRenderers(engine);
218
- return engine;
219
- }
220
- function registerTemplateRenderers(engine) {
221
- engine.register(agentListReactRenderer);
222
- engine.register(agentListMarkdownRenderer);
223
- engine.register(runListMarkdownRenderer);
224
- engine.register(toolRegistryMarkdownRenderer);
225
- engine.register(agentDashboardMarkdownRenderer);
226
- engine.register(projectListReactRenderer);
227
- engine.register(projectListMarkdownRenderer);
228
- engine.register(saasDashboardMarkdownRenderer);
229
- engine.register(saasBillingMarkdownRenderer);
230
- engine.register(crmPipelineReactRenderer);
231
- engine.register(crmPipelineMarkdownRenderer);
232
- engine.register(crmDashboardMarkdownRenderer);
233
- engine.register(workflowDashboardMarkdownRenderer);
234
- engine.register(workflowDefinitionListMarkdownRenderer);
235
- engine.register(workflowInstanceDetailMarkdownRenderer);
236
- engine.register(marketplaceDashboardMarkdownRenderer);
237
- engine.register(productCatalogMarkdownRenderer);
238
- engine.register(orderListMarkdownRenderer);
239
- engine.register(integrationDashboardMarkdownRenderer);
240
- engine.register(connectionListMarkdownRenderer);
241
- engine.register(syncConfigMarkdownRenderer);
242
- engine.register(analyticsDashboardMarkdownRenderer);
243
- engine.register(dashboardListMarkdownRenderer);
244
- engine.register(queryBuilderMarkdownRenderer);
245
- engine.register(visualizationShowcaseMarkdownRenderer);
246
- }
247
- var templateEngine = null;
248
- function getTemplateEngine() {
249
- if (!templateEngine) {
250
- templateEngine = createTemplateTransformEngine();
251
- }
252
- return templateEngine;
253
- }
254
- function resetTemplateEngine() {
255
- templateEngine = null;
256
- }
257
-
258
- // src/runtime/installer.ts
259
- import { web } from "@contractspec/lib.runtime-sandbox";
260
-
261
- // src/runtime/registry.ts
262
- var PRESENTATIONS_BY_TEMPLATE = {
263
- "saas-boilerplate": [
264
- "saas-boilerplate.dashboard",
265
- "saas-boilerplate.project.list",
266
- "saas-boilerplate.billing.settings"
267
- ],
268
- "crm-pipeline": ["crm-pipeline.dashboard", "crm-pipeline.deal.pipeline"],
269
- "agent-console": [
270
- "agent-console.dashboard",
271
- "agent-console.agent.viewList",
272
- "agent-console.run.list",
273
- "agent-console.tool.list"
274
- ],
275
- "workflow-system": [
276
- "workflow-system.dashboard",
277
- "workflow-system.definition.list",
278
- "workflow-system.instance.detail"
279
- ],
280
- marketplace: [
281
- "marketplace.dashboard",
282
- "marketplace.product.catalog",
283
- "marketplace.order.list"
284
- ],
285
- "integration-hub": [
286
- "integration-hub.dashboard",
287
- "integration-hub.connection.list",
288
- "integration-hub.sync.config"
289
- ],
290
- "analytics-dashboard": [
291
- "analytics-dashboard.dashboard",
292
- "analytics-dashboard.list",
293
- "analytics-dashboard.query.builder"
294
- ],
295
- "visualization-showcase": ["visualization-showcase.gallery"],
296
- "learning-journey-studio-onboarding": [
297
- "learning.journey.track_list",
298
- "learning.journey.track_detail",
299
- "learning.journey.progress_widget"
300
- ],
301
- "learning-journey-platform-tour": [
302
- "learning.journey.track_list",
303
- "learning.journey.track_detail",
304
- "learning.journey.progress_widget"
305
- ],
306
- "learning-journey-crm-onboarding": [
307
- "learning.journey.track_list",
308
- "learning.journey.track_detail",
309
- "learning.journey.progress_widget"
310
- ],
311
- "learning-journey-duo-drills": [
312
- "learning.journey.track_list",
313
- "learning.journey.track_detail",
314
- "learning.journey.progress_widget"
315
- ],
316
- "learning-journey-ambient-coach": [
317
- "learning.journey.track_list",
318
- "learning.journey.track_detail",
319
- "learning.journey.progress_widget"
320
- ],
321
- "learning-journey-quest-challenges": [
322
- "learning.journey.track_list",
323
- "learning.journey.track_detail",
324
- "learning.journey.progress_widget"
325
- ]
326
- };
327
- var GENERATED_TEMPLATE_REGISTRY = listExamples().filter((example) => example.meta.key !== "agent-console").map((example) => {
328
- const tags = [...example.meta.tags ?? []];
329
- const category = tags.some((tag) => tag.toLowerCase() === "ai") || tags.some((tag) => tag.toLowerCase() === "assistant") ? "ai" : "business";
330
- return {
331
- id: example.meta.key,
332
- name: example.meta.title ?? example.meta.key,
333
- description: example.meta.description ?? "",
334
- category,
335
- complexity: "beginner",
336
- icon: "\uD83D\uDCE6",
337
- features: [],
338
- tags,
339
- schema: { models: [], contracts: [] },
340
- components: { list: "ExampleList", detail: "ExampleDetail" },
341
- preview: {
342
- demoUrl: `/sandbox?template=${encodeURIComponent(example.meta.key)}`
343
- },
344
- package: example.entrypoints.packageName,
345
- presentations: PRESENTATIONS_BY_TEMPLATE[example.meta.key] ?? [],
346
- renderTargets: ["react", "markdown"]
347
- };
348
- });
349
- var TEMPLATE_REGISTRY = [
350
- {
351
- id: "todos-app",
352
- name: "To-dos List App",
353
- description: "CRUD flows, filtering, priorities, and ceremonies for handing off work across crews.",
354
- category: "productivity",
355
- complexity: "beginner",
356
- icon: "✅",
357
- features: ["CRUD tasks", "Filters", "Categories", "Search", "Priorities"],
358
- tags: ["tasks", "ops", "starter"],
359
- schema: {
360
- models: ["Task", "TaskCategory"],
361
- contracts: ["template.todos.crud"]
362
- },
363
- components: {
364
- list: "TaskList",
365
- detail: "TaskDetailPanel",
366
- form: "TaskForm"
367
- },
368
- preview: {
369
- demoUrl: "/sandbox?template=todos-app"
370
- },
371
- docs: {
372
- quickstart: "/docs/templates/todos-app"
373
- }
374
- },
375
- {
376
- id: "messaging-app",
377
- name: "Messaging Application",
378
- description: "Conversation roster, optimistic sending, typing indicators, and delivery telemetry.",
379
- category: "communication",
380
- complexity: "intermediate",
381
- icon: "\uD83D\uDCAC",
382
- features: [
383
- "Conversations",
384
- "Real-time feed",
385
- "Typing indicators",
386
- "Read receipts"
387
- ],
388
- tags: ["messaging", "realtime", "ws"],
389
- schema: {
390
- models: ["Conversation", "ConversationParticipant", "Message"],
391
- contracts: ["template.messaging.core"]
392
- },
393
- components: {
394
- list: "ConversationList",
395
- detail: "MessageThread",
396
- form: "MessageComposer"
397
- },
398
- preview: {
399
- demoUrl: "/sandbox?template=messaging-app"
400
- },
401
- docs: {
402
- quickstart: "/docs/templates/messaging-app"
403
- }
404
- },
405
- {
406
- id: "recipe-app-i18n",
407
- name: "Recipe App (i18n)",
408
- description: "Localized browsing experience with bilingual content, categories, and favorites.",
409
- category: "content",
410
- complexity: "intermediate",
411
- icon: "\uD83C\uDF72",
412
- features: ["i18n", "Favorites", "Categories", "Search", "RTL-ready"],
413
- tags: ["content", "i18n", "localization"],
414
- schema: {
415
- models: [
416
- "RecipeCategory",
417
- "Recipe",
418
- "RecipeIngredient",
419
- "RecipeInstruction"
420
- ],
421
- contracts: ["template.recipes.browse"]
422
- },
423
- components: {
424
- list: "RecipeList",
425
- detail: "RecipeDetail",
426
- form: "RecipeForm"
427
- },
428
- preview: {
429
- demoUrl: "/sandbox?template=recipe-app-i18n"
430
- },
431
- docs: {
432
- quickstart: "/docs/templates/recipe-app-i18n"
433
- }
434
- },
435
- {
436
- id: "agent-console",
437
- name: "Agent Console",
438
- description: "Deterministic autonomous-agent walkthrough with seeded agents, tool registry, runs, metrics, and replayable proof.",
439
- category: "ai",
440
- complexity: "intermediate",
441
- icon: "\uD83E\uDD16",
442
- features: [
443
- "Seeded autonomous agents",
444
- "Tool registry",
445
- "Run execution history",
446
- "Metrics",
447
- "Markdown and React views"
448
- ],
449
- tags: ["ai", "agents", "autonomous", "meetup", "sandbox"],
450
- schema: {
451
- models: ["Agent", "Tool", "Run"],
452
- contracts: [
453
- "agent-console.agent.list",
454
- "agent-console.agent.create",
455
- "agent-console.run.execute"
456
- ]
457
- },
458
- components: {
459
- list: "AgentListView",
460
- detail: "RunListView",
461
- form: "CreateAgentModal"
462
- },
463
- preview: {
464
- demoUrl: "/sandbox?template=agent-console"
465
- },
466
- package: "@contractspec/example.agent-console",
467
- presentations: PRESENTATIONS_BY_TEMPLATE["agent-console"] ?? [],
468
- renderTargets: ["react", "markdown"]
469
- },
470
- ...GENERATED_TEMPLATE_REGISTRY
471
- ];
472
- function listTemplates(filter) {
473
- if (!filter)
474
- return TEMPLATE_REGISTRY;
475
- return TEMPLATE_REGISTRY.filter((template) => {
476
- if (filter.category && template.category !== filter.category) {
477
- return false;
478
- }
479
- if (filter.complexity && template.complexity !== filter.complexity) {
480
- return false;
481
- }
482
- if (filter.tag && !template.tags.some((tag) => tag.toLowerCase() === filter.tag?.toLowerCase())) {
483
- return false;
484
- }
485
- return true;
486
- });
487
- }
488
- function getTemplate(id) {
489
- return TEMPLATE_REGISTRY.find((template) => template.id === id);
490
- }
491
- function getTemplatesByModule(modulePackage) {
492
- return TEMPLATE_REGISTRY.filter((template) => template.usesModules?.includes(modulePackage));
493
- }
494
- function getClonableTemplates() {
495
- return TEMPLATE_REGISTRY.filter((template) => !!template.package);
496
- }
497
-
498
- // src/runtime/registry-client.ts
499
- class ContractSpecRegistryClient {
500
- baseUrl;
501
- fetchImpl;
502
- constructor(options) {
503
- this.baseUrl = options.registryUrl.replace(/\/+$/, "");
504
- this.fetchImpl = options.fetchImpl ?? fetch;
505
- }
506
- async getManifest() {
507
- const res = await this.fetchImpl(`${this.baseUrl}/r/contractspec.json`, {
508
- method: "GET",
509
- headers: { Accept: "application/json" }
510
- });
511
- if (!res.ok) {
512
- throw new Error(`Registry manifest fetch failed: ${res.status} ${res.statusText}`);
513
- }
514
- return await res.json();
515
- }
516
- async listByType(type) {
517
- const manifest = await this.getManifest();
518
- return manifest.items.filter((i) => i.type === type);
519
- }
520
- async listTemplateSummaries() {
521
- const templates = await this.listByType("contractspec:template");
522
- return templates.map((t) => ({
523
- id: t.key,
524
- title: t.title,
525
- description: t.description,
526
- version: t.version,
527
- tags: t.meta.tags,
528
- source: "registry"
529
- }));
530
- }
531
- async getItem(typeSegment, name) {
532
- const res = await this.fetchImpl(`${this.baseUrl}/r/contractspec/${typeSegment}/${name}.json`, {
533
- method: "GET",
534
- headers: { Accept: "application/json" }
535
- });
536
- if (!res.ok) {
537
- throw new Error(`Registry item fetch failed: ${res.status} ${res.statusText}`);
538
- }
539
- return await res.json();
540
- }
541
- }
542
-
543
- // src/runtime/installer.ts
544
- "use client";
545
- var { LocalRuntimeServices } = web;
546
- var SAVE_TEMPLATE_MUTATION = `
1
+ import{ExampleRegistry as Lo}from"@contractspec/lib.contracts-spec/examples/registry";import R from"@contractspec/example.agent-console/example";import L from"@contractspec/example.ai-chat-assistant/example";import Y from"@contractspec/example.ai-support-bot/example";import M from"@contractspec/example.analytics-dashboard/example";import J from"@contractspec/example.calendar-google/example";import G from"@contractspec/example.content-generation/example";import H from"@contractspec/example.crm-pipeline/example";import _ from"@contractspec/example.data-grid-showcase/example";import T from"@contractspec/example.email-gmail/example";import j from"@contractspec/example.harness-lab/example";import N from"@contractspec/example.in-app-docs/example";import E from"@contractspec/example.integration-hub/example";import I from"@contractspec/example.integration-posthog/example";import oo from"@contractspec/example.integration-stripe/example";import so from"@contractspec/example.integration-supabase/example";import ao from"@contractspec/example.kb-update-pipeline/example";import ro from"@contractspec/example.knowledge-canon/example";import to from"@contractspec/example.learning-journey-ambient-coach/example";import io from"@contractspec/example.learning-journey-crm-onboarding/example";import co from"@contractspec/example.learning-journey-duo-drills/example";import wo from"@contractspec/example.learning-journey-platform-tour/example";import ho from"@contractspec/example.learning-journey-quest-challenges/example";import fo from"@contractspec/example.learning-journey-registry/example";import bo from"@contractspec/example.learning-journey-studio-onboarding/example";import no from"@contractspec/example.learning-journey-ui-coaching/example";import vo from"@contractspec/example.learning-journey-ui-gamified/example";import ko from"@contractspec/example.learning-journey-ui-onboarding/example";import yo from"@contractspec/example.learning-journey-ui-shared/example";import lo from"@contractspec/example.learning-patterns/example";import po from"@contractspec/example.lifecycle-cli/example";import uo from"@contractspec/example.lifecycle-dashboard/example";import eo from"@contractspec/example.locale-jurisdiction-gate/example";import xo from"@contractspec/example.marketplace/example";import So from"@contractspec/example.meeting-recorder-providers/example";import Co from"@contractspec/example.messaging-agent-actions/example";import Do from"@contractspec/example.minimal/example";import $o from"@contractspec/example.openbanking-powens/example";import go from"@contractspec/example.opencode-cli/example";import Wo from"@contractspec/example.personalization/example";import qo from"@contractspec/example.pocket-family-office/example";import Bo from"@contractspec/example.policy-safe-knowledge-assistant/example";import Qo from"@contractspec/example.product-intent/example";import Fo from"@contractspec/example.project-management-sync/example";import Vo from"@contractspec/example.saas-boilerplate/example";import Zo from"@contractspec/example.service-business-os/example";import mo from"@contractspec/example.team-hub/example";import zo from"@contractspec/example.versioned-knowledge-base/example";import Uo from"@contractspec/example.video-api-showcase/example";import Xo from"@contractspec/example.video-docs-terminal/example";import Oo from"@contractspec/example.video-marketing-clip/example";import Ko from"@contractspec/example.visualization-showcase/example";import Ao from"@contractspec/example.voice-providers/example";import Po from"@contractspec/example.wealth-snapshot/example";import Ro from"@contractspec/example.workflow-system/example";var q=[R,L,Y,M,J,G,H,_,T,j,N,E,I,oo,so,ao,ro,to,io,co,wo,ho,fo,bo,no,vo,ko,yo,lo,po,uo,eo,xo,So,Co,Do,$o,go,Wo,qo,Bo,Qo,Fo,Vo,Zo,mo,zo,Uo,Xo,Oo,Ko,Ao,Po,Ro];import{ExampleRegistry as Na}from"@contractspec/lib.contracts-spec/examples/registry";var k=new Lo;for(let o of q)k.register(o);var Ga=k.list();function B(){return k.list()}function Ha(o){return k.get(o)}function _a(o){return k.search(o)}import{ApolloProvider as gs}from"@apollo/client/react";import{web as Ws}from"@contractspec/lib.runtime-sandbox";import{useEffect as qs,useMemo as Bs,useState as m}from"react";import{AGENT_CONSOLE_DEMO_ORGANIZATION_ID as D,createAgentConsoleDemoHandlers as Fs,getAgentConsoleDashboardData as Vs}from"@contractspec/example.agent-console";import{createAnalyticsHandlers as Zs}from"@contractspec/example.analytics-dashboard";import{createCrmHandlers as ms}from"@contractspec/example.crm-pipeline";import{createIntegrationHandlers as zs}from"@contractspec/example.integration-hub";import{createMarketplaceHandlers as Us}from"@contractspec/example.marketplace";import{createPolicySafeKnowledgeAssistantHandlers as Xs}from"@contractspec/example.policy-safe-knowledge-assistant";import{createSaasHandlers as Os}from"@contractspec/example.saas-boilerplate";import{createWorkflowHandlers as Ks}from"@contractspec/example.workflow-system";import{TemplateRuntimeContext as As,useTemplateComponents as Ps,useTemplateRuntime as z}from"@contractspec/lib.example-shared-ui";import{agentDashboardMarkdownRenderer as Yo,agentListMarkdownRenderer as Mo,agentListReactRenderer as Jo,runListMarkdownRenderer as Go,toolRegistryMarkdownRenderer as Ho}from"@contractspec/example.agent-console";import{analyticsDashboardMarkdownRenderer as _o,dashboardListMarkdownRenderer as To,queryBuilderMarkdownRenderer as jo}from"@contractspec/example.analytics-dashboard";import{crmDashboardMarkdownRenderer as No,crmPipelineMarkdownRenderer as Eo,crmPipelineReactRenderer as Io}from"@contractspec/example.crm-pipeline";import{connectionListMarkdownRenderer as os,integrationDashboardMarkdownRenderer as ss,syncConfigMarkdownRenderer as as}from"@contractspec/example.integration-hub";import{marketplaceDashboardMarkdownRenderer as rs,orderListMarkdownRenderer as ts,productCatalogMarkdownRenderer as is}from"@contractspec/example.marketplace";import{projectListMarkdownRenderer as cs,projectListReactRenderer as ws,saasBillingMarkdownRenderer as ds,saasDashboardMarkdownRenderer as hs}from"@contractspec/example.saas-boilerplate";import{visualizationShowcaseMarkdownRenderer as fs}from"@contractspec/example.visualization-showcase/ui/renderers";import{workflowDashboardMarkdownRenderer as bs,workflowDefinitionListMarkdownRenderer as ns,workflowInstanceDetailMarkdownRenderer as vs}from"@contractspec/example.workflow-system";import{createDefaultTransformEngine as ks,registerBasicValidation as ys,registerDefaultReactRenderer as ls}from"@contractspec/lib.contracts-runtime-client-react/transform-engine";function ps(){let o=ks();return ls(o),ys(o),us(o),o}function us(o){o.register(Jo),o.register(Mo),o.register(Go),o.register(Ho),o.register(Yo),o.register(ws),o.register(cs),o.register(hs),o.register(ds),o.register(Io),o.register(Eo),o.register(No),o.register(bs),o.register(ns),o.register(vs),o.register(rs),o.register(is),o.register(ts),o.register(ss),o.register(os),o.register(as),o.register(_o),o.register(To),o.register(jo),o.register(fs)}var p=null;function Q(){if(!p)p=ps();return p}function wr(){p=null}import{web as xs}from"@contractspec/lib.runtime-sandbox";var F={"saas-boilerplate":["saas-boilerplate.dashboard","saas-boilerplate.project.list","saas-boilerplate.billing.settings"],"crm-pipeline":["crm-pipeline.dashboard","crm-pipeline.deal.pipeline"],"agent-console":["agent-console.dashboard","agent-console.agent.viewList","agent-console.run.list","agent-console.tool.list"],"workflow-system":["workflow-system.dashboard","workflow-system.definition.list","workflow-system.instance.detail"],marketplace:["marketplace.dashboard","marketplace.product.catalog","marketplace.order.list"],"integration-hub":["integration-hub.dashboard","integration-hub.connection.list","integration-hub.sync.config"],"analytics-dashboard":["analytics-dashboard.dashboard","analytics-dashboard.list","analytics-dashboard.query.builder"],"visualization-showcase":["visualization-showcase.gallery"],"learning-journey-studio-onboarding":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"],"learning-journey-platform-tour":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"],"learning-journey-crm-onboarding":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"],"learning-journey-duo-drills":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"],"learning-journey-ambient-coach":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"],"learning-journey-quest-challenges":["learning.journey.track_list","learning.journey.track_detail","learning.journey.progress_widget"]},es=B().filter((o)=>o.meta.key!=="agent-console").map((o)=>{let s=[...o.meta.tags??[]],i=s.some((w)=>w.toLowerCase()==="ai")||s.some((w)=>w.toLowerCase()==="assistant")?"ai":"business";return{id:o.meta.key,name:o.meta.title??o.meta.key,description:o.meta.description??"",category:i,complexity:"beginner",icon:"\uD83D\uDCE6",features:[],tags:s,schema:{models:[],contracts:[]},components:{list:"ExampleList",detail:"ExampleDetail"},preview:{demoUrl:`/sandbox?template=${encodeURIComponent(o.meta.key)}`},package:o.entrypoints.packageName,presentations:F[o.meta.key]??[],renderTargets:["react","markdown"]}}),f=[{id:"todos-app",name:"To-dos List App",description:"CRUD flows, filtering, priorities, and ceremonies for handing off work across crews.",category:"productivity",complexity:"beginner",icon:"✅",features:["CRUD tasks","Filters","Categories","Search","Priorities"],tags:["tasks","ops","starter"],schema:{models:["Task","TaskCategory"],contracts:["template.todos.crud"]},components:{list:"TaskList",detail:"TaskDetailPanel",form:"TaskForm"},preview:{demoUrl:"/sandbox?template=todos-app"},docs:{quickstart:"/docs/templates/todos-app"}},{id:"messaging-app",name:"Messaging Application",description:"Conversation roster, optimistic sending, typing indicators, and delivery telemetry.",category:"communication",complexity:"intermediate",icon:"\uD83D\uDCAC",features:["Conversations","Real-time feed","Typing indicators","Read receipts"],tags:["messaging","realtime","ws"],schema:{models:["Conversation","ConversationParticipant","Message"],contracts:["template.messaging.core"]},components:{list:"ConversationList",detail:"MessageThread",form:"MessageComposer"},preview:{demoUrl:"/sandbox?template=messaging-app"},docs:{quickstart:"/docs/templates/messaging-app"}},{id:"recipe-app-i18n",name:"Recipe App (i18n)",description:"Localized browsing experience with bilingual content, categories, and favorites.",category:"content",complexity:"intermediate",icon:"\uD83C\uDF72",features:["i18n","Favorites","Categories","Search","RTL-ready"],tags:["content","i18n","localization"],schema:{models:["RecipeCategory","Recipe","RecipeIngredient","RecipeInstruction"],contracts:["template.recipes.browse"]},components:{list:"RecipeList",detail:"RecipeDetail",form:"RecipeForm"},preview:{demoUrl:"/sandbox?template=recipe-app-i18n"},docs:{quickstart:"/docs/templates/recipe-app-i18n"}},{id:"agent-console",name:"Agent Console",description:"Deterministic autonomous-agent walkthrough with seeded agents, tool registry, runs, metrics, and replayable proof.",category:"ai",complexity:"intermediate",icon:"\uD83E\uDD16",features:["Seeded autonomous agents","Tool registry","Run execution history","Metrics","Markdown and React views"],tags:["ai","agents","autonomous","meetup","sandbox"],schema:{models:["Agent","Tool","Run"],contracts:["agent-console.agent.list","agent-console.agent.create","agent-console.run.execute"]},components:{list:"AgentListView",detail:"RunListView",form:"CreateAgentModal"},preview:{demoUrl:"/sandbox?template=agent-console"},package:"@contractspec/example.agent-console",presentations:F["agent-console"]??[],renderTargets:["react","markdown"]},...es];function fr(o){if(!o)return f;return f.filter((s)=>{if(o.category&&s.category!==o.category)return!1;if(o.complexity&&s.complexity!==o.complexity)return!1;if(o.tag&&!s.tags.some((i)=>i.toLowerCase()===o.tag?.toLowerCase()))return!1;return!0})}function y(o){return f.find((s)=>s.id===o)}function br(o){return f.filter((s)=>s.usesModules?.includes(o))}function nr(){return f.filter((o)=>!!o.package)}class S{baseUrl;fetchImpl;constructor(o){this.baseUrl=o.registryUrl.replace(/\/+$/,""),this.fetchImpl=o.fetchImpl??fetch}async getManifest(){let o=await this.fetchImpl(`${this.baseUrl}/r/contractspec.json`,{method:"GET",headers:{Accept:"application/json"}});if(!o.ok)throw Error(`Registry manifest fetch failed: ${o.status} ${o.statusText}`);return await o.json()}async listByType(o){return(await this.getManifest()).items.filter((i)=>i.type===o)}async listTemplateSummaries(){return(await this.listByType("contractspec:template")).map((s)=>({id:s.key,title:s.title,description:s.description,version:s.version,tags:s.meta.tags,source:"registry"}))}async getItem(o,s){let i=await this.fetchImpl(`${this.baseUrl}/r/contractspec/${o}/${s}.json`,{method:"GET",headers:{Accept:"application/json"}});if(!i.ok)throw Error(`Registry item fetch failed: ${i.status} ${i.statusText}`);return await i.json()}}var{LocalRuntimeServices:Ss}=xs,Cs=`
547
2
  mutation SaveTemplateToStudio($input: SaveTemplateInput!) {
548
3
  saveTemplateToStudio(input: $input) {
549
4
  projectId
550
5
  status
551
6
  }
552
7
  }
553
- `;
554
-
555
- class TemplateInstaller {
556
- runtime;
557
- endpoint;
558
- registryUrl;
559
- fetchImpl;
560
- constructor(options = {}) {
561
- this.runtime = options.runtime ?? new LocalRuntimeServices;
562
- this.endpoint = options.endpoint ?? "/api/graphql";
563
- this.registryUrl = options.registryUrl ? options.registryUrl.replace(/\/+$/, "") : null;
564
- this.fetchImpl = options.fetchImpl ?? fetch;
565
- }
566
- async init() {
567
- await this.runtime.init();
568
- }
569
- list(filter) {
570
- return filter ? TEMPLATE_REGISTRY.filter((template) => {
571
- if (filter.category && filter.category !== template.category) {
572
- return false;
573
- }
574
- if (filter.complexity && filter.complexity !== template.complexity) {
575
- return false;
576
- }
577
- if (filter.tag && !template.tags.includes(filter.tag)) {
578
- return false;
579
- }
580
- return true;
581
- }) : TEMPLATE_REGISTRY;
582
- }
583
- async listRemoteTemplates() {
584
- if (!this.registryUrl)
585
- return [];
586
- const client = new ContractSpecRegistryClient({
587
- registryUrl: this.registryUrl,
588
- fetchImpl: this.fetchImpl
589
- });
590
- return await client.listTemplateSummaries();
591
- }
592
- resolveLocalTemplateId(id) {
593
- const found = getTemplate(id);
594
- return found ? id : null;
595
- }
596
- get(templateId) {
597
- return getTemplate(templateId);
598
- }
599
- async install(templateId, options = {}) {
600
- await this.runtime.seedTemplate({
601
- templateId,
602
- projectId: options.projectId
603
- });
604
- }
605
- async saveToStudio(options) {
606
- const snapshot = await this.runtime.db.export();
607
- const payload = toBase64(snapshot);
608
- const response = await this.fetchImpl(options.endpoint ?? this.endpoint, {
609
- method: "POST",
610
- headers: {
611
- "Content-Type": "application/json",
612
- ...options.token ? { Authorization: `Bearer ${options.token}` } : {}
613
- },
614
- body: JSON.stringify({
615
- query: SAVE_TEMPLATE_MUTATION,
616
- variables: {
617
- input: {
618
- templateId: options.templateId,
619
- projectName: options.projectName,
620
- organizationId: options.organizationId,
621
- payload
622
- }
623
- }
624
- })
625
- });
626
- if (!response.ok) {
627
- throw new Error(`Failed to save template: ${response.status} ${response.statusText}`);
628
- }
629
- const json = await response.json();
630
- if (json.errors?.length) {
631
- throw new Error(json.errors[0]?.message ?? "Unknown error");
632
- }
633
- if (!json.data?.saveTemplateToStudio) {
634
- throw new Error("Invalid response from Studio API");
635
- }
636
- return json.data.saveTemplateToStudio;
637
- }
638
- }
639
- function toBase64(bytes) {
640
- if (typeof Buffer !== "undefined") {
641
- return Buffer.from(bytes).toString("base64");
642
- }
643
- let binary = "";
644
- bytes.forEach((value) => {
645
- binary += String.fromCharCode(value);
646
- });
647
- return btoa(binary);
648
- }
649
-
650
- // src/runtime/presentations.ts
651
- function createComponentPresentation(key, title, description, goal, context, componentKey) {
652
- return {
653
- meta: {
654
- key,
655
- version: "1.0.0",
656
- title,
657
- description,
658
- stability: "experimental",
659
- goal,
660
- context,
661
- owners: ["@contractspec/examples"],
662
- tags: ["template", "sandbox"]
663
- },
664
- source: {
665
- type: "component",
666
- framework: "react",
667
- componentKey
668
- },
669
- targets: ["react", "markdown"]
670
- };
671
- }
672
- var TEMPLATE_PRESENTATIONS = {
673
- "agent-console.dashboard": createComponentPresentation("agent-console.dashboard", "Agent Console Dashboard", "Operational dashboard for the agent console example.", "Review agent activity, throughput, and execution health.", "Sandbox presentation used for markdown previews.", "AgentConsoleDashboard"),
674
- "agent-console.agent.list": createComponentPresentation("agent-console.agent.list", "Agent List", "List of seeded agents in the agent console example.", "Browse configured agents and their current capabilities.", "Sandbox presentation used for markdown previews.", "AgentListView"),
675
- "agent-console.agent.viewList": createComponentPresentation("agent-console.agent.viewList", "Agent List", "List of seeded agents in the agent console example.", "Browse configured agents and their current capabilities.", "Sandbox presentation used for markdown previews.", "AgentListView"),
676
- "agent-console.run.list": createComponentPresentation("agent-console.run.list", "Run List", "Execution history for the agent console example.", "Inspect recent runs and their outcomes.", "Sandbox presentation used for markdown previews.", "RunListView"),
677
- "agent-console.tool.list": createComponentPresentation("agent-console.tool.list", "Tool Registry", "Available tools for the agent console example.", "Inspect the tool registry exposed to the seeded agents.", "Sandbox presentation used for markdown previews.", "ToolRegistryView"),
678
- "agent-console.tool.registry": createComponentPresentation("agent-console.tool.registry", "Tool Registry", "Available tools for the agent console example.", "Inspect the tool registry exposed to the seeded agents.", "Sandbox presentation used for markdown previews.", "ToolRegistryView"),
679
- "analytics-dashboard.dashboard": createComponentPresentation("analytics-dashboard.dashboard", "Analytics Dashboard", "Dashboard view for the analytics example.", "Review saved widgets and query-backed dashboards.", "Sandbox presentation used for markdown previews.", "AnalyticsDashboard"),
680
- "analytics-dashboard.list": createComponentPresentation("analytics-dashboard.list", "Dashboard List", "List view for analytics dashboards.", "Browse dashboards available in the analytics example.", "Sandbox presentation used for markdown previews.", "DashboardList"),
681
- "analytics-dashboard.query.builder": createComponentPresentation("analytics-dashboard.query.builder", "Query Builder", "Query authoring surface for the analytics example.", "Inspect reusable queries that power dashboards.", "Sandbox presentation used for markdown previews.", "QueryBuilder"),
682
- "crm-pipeline.dashboard": createComponentPresentation("crm-pipeline.dashboard", "CRM Dashboard", "Dashboard for the CRM pipeline example.", "Track pipeline health and revenue progress.", "Sandbox presentation used for markdown previews.", "CrmDashboard"),
683
- "crm-pipeline.deal.pipeline": createComponentPresentation("crm-pipeline.deal.pipeline", "Pipeline Kanban", "Pipeline board for the CRM pipeline example.", "Review deal flow across pipeline stages.", "Sandbox presentation used for markdown previews.", "PipelineKanbanView"),
684
- "integration-hub.connection.list": createComponentPresentation("integration-hub.connection.list", "Connection List", "Connected systems in the integration hub example.", "Review connected systems and connection health.", "Sandbox presentation used for markdown previews.", "ConnectionList"),
685
- "integration-hub.dashboard": createComponentPresentation("integration-hub.dashboard", "Integration Dashboard", "Operational dashboard for the integration hub example.", "Monitor integration mix, connection health, and sync issues.", "Sandbox presentation used for markdown previews.", "IntegrationDashboard"),
686
- "integration-hub.sync.config": createComponentPresentation("integration-hub.sync.config", "Sync Configuration", "Sync configuration surface for the integration hub example.", "Inspect sync configuration and field mapping defaults.", "Sandbox presentation used for markdown previews.", "SyncConfigEditor"),
687
- "marketplace.dashboard": createComponentPresentation("marketplace.dashboard", "Marketplace Dashboard", "Dashboard for the marketplace example.", "Review order flow, category mix, and revenue summaries.", "Sandbox presentation used for markdown previews.", "MarketplaceDashboard"),
688
- "marketplace.order.list": createComponentPresentation("marketplace.order.list", "Order List", "Order list for the marketplace example.", "Inspect order activity and fulfillment state.", "Sandbox presentation used for markdown previews.", "OrderList"),
689
- "marketplace.product.catalog": createComponentPresentation("marketplace.product.catalog", "Product Catalog", "Product catalog for the marketplace example.", "Browse the available products and merchandising data.", "Sandbox presentation used for markdown previews.", "ProductCatalog"),
690
- "saas-boilerplate.billing.settings": createComponentPresentation("saas-boilerplate.billing.settings", "Billing Settings", "Subscription and usage settings for the SaaS example.", "Review billing configuration and current subscription data.", "Sandbox presentation used for markdown previews.", "SubscriptionView"),
691
- "saas-boilerplate.dashboard": createComponentPresentation("saas-boilerplate.dashboard", "SaaS Dashboard", "Dashboard for the SaaS boilerplate example.", "Review account, project, and billing summaries.", "Sandbox presentation used for markdown previews.", "SaasDashboard"),
692
- "saas-boilerplate.project.list": createComponentPresentation("saas-boilerplate.project.list", "Project List", "Project list for the SaaS boilerplate example.", "Browse projects and their current lifecycle state.", "Sandbox presentation used for markdown previews.", "ProjectListView"),
693
- "visualization-showcase.gallery": createComponentPresentation("visualization-showcase.gallery", "Visualization Showcase", "Focused showcase of ContractSpec visualization primitives.", "Review the canonical visualization catalog and design-system wrappers.", "Sandbox presentation used for markdown previews.", "VisualizationShowcase"),
694
- "workflow-system.dashboard": createComponentPresentation("workflow-system.dashboard", "Workflow Dashboard", "Dashboard for the workflow system example.", "Review workflow instance health and workload metrics.", "Sandbox presentation used for markdown previews.", "WorkflowDashboard"),
695
- "workflow-system.definition.list": createComponentPresentation("workflow-system.definition.list", "Workflow Definition List", "Workflow definitions in the workflow system example.", "Browse available workflow definitions.", "Sandbox presentation used for markdown previews.", "WorkflowDefinitionList"),
696
- "workflow-system.instance.detail": createComponentPresentation("workflow-system.instance.detail", "Workflow Instance Detail", "Workflow instance details in the workflow system example.", "Inspect the state and approvals for a workflow instance.", "Sandbox presentation used for markdown previews.", "WorkflowInstanceDetail")
697
- };
698
- function resolveTemplatePresentation(presentationName) {
699
- return TEMPLATE_PRESENTATIONS[presentationName];
700
- }
701
-
702
- // src/runtime/context.tsx
703
- import { jsxDEV } from "react/jsx-dev-runtime";
704
- "use client";
705
- var { LocalRuntimeServices: LocalRuntimeServices2 } = web2;
706
- function logBootstrapFailure(error) {
707
- console.error(`
8
+ `;class C{runtime;endpoint;registryUrl;fetchImpl;constructor(o={}){this.runtime=o.runtime??new Ss,this.endpoint=o.endpoint??"/api/graphql",this.registryUrl=o.registryUrl?o.registryUrl.replace(/\/+$/,""):null,this.fetchImpl=o.fetchImpl??fetch}async init(){await this.runtime.init()}list(o){return o?f.filter((s)=>{if(o.category&&o.category!==s.category)return!1;if(o.complexity&&o.complexity!==s.complexity)return!1;if(o.tag&&!s.tags.includes(o.tag))return!1;return!0}):f}async listRemoteTemplates(){if(!this.registryUrl)return[];return await new S({registryUrl:this.registryUrl,fetchImpl:this.fetchImpl}).listTemplateSummaries()}resolveLocalTemplateId(o){return y(o)?o:null}get(o){return y(o)}async install(o,s={}){await this.runtime.seedTemplate({templateId:o,projectId:s.projectId})}async saveToStudio(o){let s=await this.runtime.db.export(),i=Ds(s),w=await this.fetchImpl(o.endpoint??this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",...o.token?{Authorization:`Bearer ${o.token}`}:{}},body:JSON.stringify({query:Cs,variables:{input:{templateId:o.templateId,projectName:o.projectName,organizationId:o.organizationId,payload:i}}})});if(!w.ok)throw Error(`Failed to save template: ${w.status} ${w.statusText}`);let h=await w.json();if(h.errors?.length)throw Error(h.errors[0]?.message??"Unknown error");if(!h.data?.saveTemplateToStudio)throw Error("Invalid response from Studio API");return h.data.saveTemplateToStudio}}function Ds(o){if(typeof Buffer<"u")return Buffer.from(o).toString("base64");let s="";return o.forEach((i)=>{s+=String.fromCharCode(i)}),btoa(s)}function r(o,s,i,w,h,u){return{meta:{key:o,version:"1.0.0",title:s,description:i,stability:"experimental",goal:w,context:h,owners:["@contractspec/examples"],tags:["template","sandbox"]},source:{type:"component",framework:"react",componentKey:u},targets:["react","markdown"]}}var $s={"agent-console.dashboard":r("agent-console.dashboard","Agent Console Dashboard","Operational dashboard for the agent console example.","Review agent activity, throughput, and execution health.","Sandbox presentation used for markdown previews.","AgentConsoleDashboard"),"agent-console.agent.list":r("agent-console.agent.list","Agent List","List of seeded agents in the agent console example.","Browse configured agents and their current capabilities.","Sandbox presentation used for markdown previews.","AgentListView"),"agent-console.agent.viewList":r("agent-console.agent.viewList","Agent List","List of seeded agents in the agent console example.","Browse configured agents and their current capabilities.","Sandbox presentation used for markdown previews.","AgentListView"),"agent-console.run.list":r("agent-console.run.list","Run List","Execution history for the agent console example.","Inspect recent runs and their outcomes.","Sandbox presentation used for markdown previews.","RunListView"),"agent-console.tool.list":r("agent-console.tool.list","Tool Registry","Available tools for the agent console example.","Inspect the tool registry exposed to the seeded agents.","Sandbox presentation used for markdown previews.","ToolRegistryView"),"agent-console.tool.registry":r("agent-console.tool.registry","Tool Registry","Available tools for the agent console example.","Inspect the tool registry exposed to the seeded agents.","Sandbox presentation used for markdown previews.","ToolRegistryView"),"analytics-dashboard.dashboard":r("analytics-dashboard.dashboard","Analytics Dashboard","Dashboard view for the analytics example.","Review saved widgets and query-backed dashboards.","Sandbox presentation used for markdown previews.","AnalyticsDashboard"),"analytics-dashboard.list":r("analytics-dashboard.list","Dashboard List","List view for analytics dashboards.","Browse dashboards available in the analytics example.","Sandbox presentation used for markdown previews.","DashboardList"),"analytics-dashboard.query.builder":r("analytics-dashboard.query.builder","Query Builder","Query authoring surface for the analytics example.","Inspect reusable queries that power dashboards.","Sandbox presentation used for markdown previews.","QueryBuilder"),"crm-pipeline.dashboard":r("crm-pipeline.dashboard","CRM Dashboard","Dashboard for the CRM pipeline example.","Track pipeline health and revenue progress.","Sandbox presentation used for markdown previews.","CrmDashboard"),"crm-pipeline.deal.pipeline":r("crm-pipeline.deal.pipeline","Pipeline Kanban","Pipeline board for the CRM pipeline example.","Review deal flow across pipeline stages.","Sandbox presentation used for markdown previews.","PipelineKanbanView"),"integration-hub.connection.list":r("integration-hub.connection.list","Connection List","Connected systems in the integration hub example.","Review connected systems and connection health.","Sandbox presentation used for markdown previews.","ConnectionList"),"integration-hub.dashboard":r("integration-hub.dashboard","Integration Dashboard","Operational dashboard for the integration hub example.","Monitor integration mix, connection health, and sync issues.","Sandbox presentation used for markdown previews.","IntegrationDashboard"),"integration-hub.sync.config":r("integration-hub.sync.config","Sync Configuration","Sync configuration surface for the integration hub example.","Inspect sync configuration and field mapping defaults.","Sandbox presentation used for markdown previews.","SyncConfigEditor"),"marketplace.dashboard":r("marketplace.dashboard","Marketplace Dashboard","Dashboard for the marketplace example.","Review order flow, category mix, and revenue summaries.","Sandbox presentation used for markdown previews.","MarketplaceDashboard"),"marketplace.order.list":r("marketplace.order.list","Order List","Order list for the marketplace example.","Inspect order activity and fulfillment state.","Sandbox presentation used for markdown previews.","OrderList"),"marketplace.product.catalog":r("marketplace.product.catalog","Product Catalog","Product catalog for the marketplace example.","Browse the available products and merchandising data.","Sandbox presentation used for markdown previews.","ProductCatalog"),"saas-boilerplate.billing.settings":r("saas-boilerplate.billing.settings","Billing Settings","Subscription and usage settings for the SaaS example.","Review billing configuration and current subscription data.","Sandbox presentation used for markdown previews.","SubscriptionView"),"saas-boilerplate.dashboard":r("saas-boilerplate.dashboard","SaaS Dashboard","Dashboard for the SaaS boilerplate example.","Review account, project, and billing summaries.","Sandbox presentation used for markdown previews.","SaasDashboard"),"saas-boilerplate.project.list":r("saas-boilerplate.project.list","Project List","Project list for the SaaS boilerplate example.","Browse projects and their current lifecycle state.","Sandbox presentation used for markdown previews.","ProjectListView"),"visualization-showcase.gallery":r("visualization-showcase.gallery","Visualization Showcase","Focused showcase of ContractSpec visualization primitives.","Review the canonical visualization catalog and design-system wrappers.","Sandbox presentation used for markdown previews.","VisualizationShowcase"),"workflow-system.dashboard":r("workflow-system.dashboard","Workflow Dashboard","Dashboard for the workflow system example.","Review workflow instance health and workload metrics.","Sandbox presentation used for markdown previews.","WorkflowDashboard"),"workflow-system.definition.list":r("workflow-system.definition.list","Workflow Definition List","Workflow definitions in the workflow system example.","Browse available workflow definitions.","Sandbox presentation used for markdown previews.","WorkflowDefinitionList"),"workflow-system.instance.detail":r("workflow-system.instance.detail","Workflow Instance Detail","Workflow instance details in the workflow system example.","Inspect the state and approvals for a workflow instance.","Sandbox presentation used for markdown previews.","WorkflowInstanceDetail")};function V(o){return $s[o]}function Z(o){return o.graphql.apollo}import{jsx as l,jsxs as Ls}from"react/jsx-runtime";var{LocalRuntimeServices:Qs}=Ws;function Rs(o){console.error(`
708
9
  [TemplateRuntime] Bootstrap Failed
709
10
  ==================================
710
11
 
@@ -714,326 +15,4 @@ The runtime failed to initialize. This usually happens because:
714
15
  3. The initial seed data could not be inserted
715
16
 
716
17
  Check the console for specific database errors.
717
- `.trim(), error);
718
- }
719
-
720
- class TemplateHandlers {
721
- crm;
722
- saas;
723
- agent;
724
- workflow;
725
- marketplace;
726
- integration;
727
- analytics;
728
- policySafeKnowledgeAssistant;
729
- }
730
- function TemplateRuntimeProvider({
731
- templateId,
732
- projectId = "local-project",
733
- lazy = false,
734
- children
735
- }) {
736
- const [context, setContext] = useState(null);
737
- const [error, setError] = useState(null);
738
- useEffect(() => {
739
- let mounted = true;
740
- async function bootstrap() {
741
- try {
742
- if (lazy)
743
- return;
744
- const template = getTemplate(templateId);
745
- if (!template) {
746
- throw new Error(`Template not found: ${templateId}`);
747
- }
748
- const runtime = new LocalRuntimeServices2;
749
- await runtime.init({});
750
- const installer = new TemplateInstaller({ runtime });
751
- await installer.install(templateId, { projectId });
752
- const client = web2.createLocalGraphqlClient(runtime);
753
- const engine = await getTemplateEngine();
754
- const handlers = new TemplateHandlers;
755
- handlers.crm = createCrmHandlers(runtime.db);
756
- handlers.saas = createSaasHandlers(runtime.db);
757
- handlers.agent = createAgentConsoleDemoHandlers({ projectId });
758
- handlers.workflow = createWorkflowHandlers(runtime.db);
759
- handlers.marketplace = createMarketplaceHandlers(runtime.db);
760
- handlers.integration = createIntegrationHandlers(runtime.db);
761
- handlers.analytics = createAnalyticsHandlers(runtime.db);
762
- handlers.policySafeKnowledgeAssistant = createPolicySafeKnowledgeAssistantHandlers(runtime.db);
763
- const fetchData = async (presentationName) => {
764
- if (presentationName === "crm-pipeline.dashboard") {
765
- const [dealsResult, stages] = await Promise.all([
766
- handlers.crm.listDeals({
767
- projectId,
768
- pipelineId: "pipeline-1",
769
- limit: 50
770
- }),
771
- handlers.crm.getPipelineStages({ pipelineId: "pipeline-1" })
772
- ]);
773
- return {
774
- data: {
775
- deals: dealsResult.deals,
776
- stages,
777
- summary: {
778
- total: dealsResult.total,
779
- totalValue: dealsResult.totalValue
780
- }
781
- },
782
- metadata: {
783
- total: dealsResult.total,
784
- timestamp: new Date,
785
- source: "crm-pipeline"
786
- }
787
- };
788
- }
789
- if (presentationName === "crm-pipeline.deal.pipeline") {
790
- const [dealsResult, stages] = await Promise.all([
791
- handlers.crm.listDeals({
792
- projectId,
793
- pipelineId: "pipeline-1",
794
- limit: 100
795
- }),
796
- handlers.crm.getPipelineStages({ pipelineId: "pipeline-1" })
797
- ]);
798
- return {
799
- data: {
800
- deals: dealsResult.deals,
801
- stages,
802
- total: dealsResult.total,
803
- totalValue: dealsResult.totalValue
804
- },
805
- metadata: {
806
- total: dealsResult.total,
807
- timestamp: new Date,
808
- source: "crm-pipeline"
809
- }
810
- };
811
- }
812
- if (presentationName === "saas-boilerplate.dashboard") {
813
- const [projectsResult, subscription] = await Promise.all([
814
- handlers.saas.listProjects({ projectId, limit: 10 }),
815
- handlers.saas.getSubscription({ projectId })
816
- ]);
817
- return {
818
- data: {
819
- projects: projectsResult.items,
820
- subscription,
821
- summary: { totalProjects: projectsResult.total }
822
- },
823
- metadata: {
824
- total: projectsResult.total,
825
- timestamp: new Date,
826
- source: "saas-boilerplate"
827
- }
828
- };
829
- }
830
- if (presentationName === "saas-boilerplate.project.list") {
831
- const result = await handlers.saas.listProjects({
832
- projectId,
833
- limit: 50
834
- });
835
- return {
836
- data: result.items,
837
- metadata: {
838
- total: result.total,
839
- timestamp: new Date,
840
- source: "saas-boilerplate"
841
- }
842
- };
843
- }
844
- if (presentationName === "saas-boilerplate.billing.settings") {
845
- const subscription = await handlers.saas.getSubscription({
846
- projectId
847
- });
848
- return {
849
- data: subscription,
850
- metadata: { timestamp: new Date, source: "saas-boilerplate" }
851
- };
852
- }
853
- if (presentationName === "agent-console.dashboard") {
854
- const data = await getAgentConsoleDashboardData(handlers.agent, {
855
- projectId,
856
- organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
857
- });
858
- return {
859
- data,
860
- metadata: { timestamp: new Date, source: "agent-console" }
861
- };
862
- }
863
- if (presentationName === "agent-console.agent.viewList" || presentationName === "agent-console.agent.list") {
864
- const result = await handlers.agent.listAgents({
865
- projectId,
866
- organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
867
- limit: 50
868
- });
869
- return {
870
- data: result.items,
871
- metadata: {
872
- total: result.total,
873
- timestamp: new Date,
874
- source: "agent-console"
875
- }
876
- };
877
- }
878
- if (presentationName === "agent-console.run.list") {
879
- const result = await handlers.agent.listRuns({
880
- projectId,
881
- limit: 50
882
- });
883
- return {
884
- data: result.items,
885
- metadata: {
886
- total: result.total,
887
- timestamp: new Date,
888
- source: "agent-console"
889
- }
890
- };
891
- }
892
- if (presentationName === "agent-console.tool.list" || presentationName === "agent-console.tool.registry") {
893
- const result = await handlers.agent.listTools({
894
- projectId,
895
- organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
896
- limit: 50
897
- });
898
- return {
899
- data: result.items,
900
- metadata: {
901
- total: result.total,
902
- timestamp: new Date,
903
- source: "agent-console"
904
- }
905
- };
906
- }
907
- if (presentationName === "visualization-showcase.gallery") {
908
- return {
909
- data: null,
910
- metadata: {
911
- timestamp: new Date,
912
- source: "visualization-showcase"
913
- }
914
- };
915
- }
916
- console.warn(`No data fetcher found for presentation: ${presentationName}`);
917
- return {
918
- data: null,
919
- metadata: { timestamp: new Date, source: "unknown" }
920
- };
921
- };
922
- if (mounted) {
923
- setContext({
924
- template,
925
- runtime,
926
- installer,
927
- client,
928
- templateId,
929
- projectId,
930
- engine,
931
- handlers,
932
- fetchData,
933
- resolvePresentation: resolveTemplatePresentation
934
- });
935
- }
936
- } catch (err) {
937
- logBootstrapFailure(err);
938
- if (mounted) {
939
- setError(err instanceof Error ? err : new Error("Unknown runtime error"));
940
- }
941
- }
942
- }
943
- bootstrap();
944
- return () => {
945
- mounted = false;
946
- };
947
- }, [templateId, projectId, lazy]);
948
- const components = useTemplateComponents(templateId);
949
- const contextValue = useMemo(() => {
950
- if (!context)
951
- return null;
952
- return {
953
- ...context,
954
- components
955
- };
956
- }, [context, components]);
957
- if (error) {
958
- return /* @__PURE__ */ jsxDEV("div", {
959
- className: "rounded border border-red-200 bg-red-50 p-4 text-red-500",
960
- children: [
961
- /* @__PURE__ */ jsxDEV("h3", {
962
- className: "font-bold",
963
- children: "Runtime Error"
964
- }, undefined, false, undefined, this),
965
- /* @__PURE__ */ jsxDEV("pre", {
966
- className: "mt-2 overflow-auto text-xs",
967
- children: error.message
968
- }, undefined, false, undefined, this)
969
- ]
970
- }, undefined, true, undefined, this);
971
- }
972
- if (!contextValue) {
973
- return /* @__PURE__ */ jsxDEV("div", {
974
- className: "animate-pulse p-12 text-center text-gray-400",
975
- children: "Initializing runtime environment..."
976
- }, undefined, false, undefined, this);
977
- }
978
- return /* @__PURE__ */ jsxDEV(ApolloProvider, {
979
- client: contextValue.client,
980
- children: /* @__PURE__ */ jsxDEV(TemplateRuntimeContext.Provider, {
981
- value: contextValue,
982
- children
983
- }, undefined, false, undefined, this)
984
- }, undefined, false, undefined, this);
985
- }
986
- function useTemplateEngine() {
987
- return useTemplateRuntime().engine;
988
- }
989
- function useTemplateHandlers() {
990
- return useTemplateRuntime().handlers;
991
- }
992
- function useCrmHandlers() {
993
- return useTemplateHandlers().crm;
994
- }
995
- function useSaasHandlers() {
996
- return useTemplateHandlers().saas;
997
- }
998
- function useAgentHandlers() {
999
- return useTemplateHandlers().agent;
1000
- }
1001
- function useWorkflowHandlers() {
1002
- return useTemplateHandlers().workflow;
1003
- }
1004
- function useMarketplaceHandlers() {
1005
- return useTemplateHandlers().marketplace;
1006
- }
1007
- function useIntegrationHandlers() {
1008
- return useTemplateHandlers().integration;
1009
- }
1010
- function useAnalyticsHandlers() {
1011
- return useTemplateHandlers().analytics;
1012
- }
1013
- export {
1014
- useWorkflowHandlers,
1015
- useTemplateHandlers,
1016
- useTemplateEngine,
1017
- useSaasHandlers,
1018
- useMarketplaceHandlers,
1019
- useIntegrationHandlers,
1020
- useCrmHandlers,
1021
- useAnalyticsHandlers,
1022
- useAgentHandlers,
1023
- searchExamples,
1024
- resetTemplateEngine,
1025
- listTemplates,
1026
- listExamples,
1027
- getTemplatesByModule,
1028
- getTemplateEngine,
1029
- getTemplate,
1030
- getExample,
1031
- getClonableTemplates,
1032
- createTemplateTransformEngine,
1033
- TemplateRuntimeProvider,
1034
- TemplateInstaller,
1035
- TemplateHandlers,
1036
- TEMPLATE_REGISTRY,
1037
- ExampleRegistry2 as ExampleRegistry,
1038
- EXAMPLE_REGISTRY2 as EXAMPLE_REGISTRY
1039
- };
18
+ `.trim(),o)}class U{crm;saas;agent;workflow;marketplace;integration;analytics;policySafeKnowledgeAssistant}function Kr({templateId:o,projectId:s="local-project",lazy:i=!1,children:w}){let[h,u]=m(null),[$,X]=m(null);qs(()=>{let x=!0;async function O(){try{if(i)return;let n=y(o);if(!n)throw Error(`Template not found: ${o}`);let d=new Qs;await d.init({});let W=new C({runtime:d});await W.install(o,{projectId:s});let K=Z(d),A=await Q(),t=new U;t.crm=ms(d.db),t.saas=Os(d.db),t.agent=Fs({projectId:s}),t.workflow=Ks(d.db),t.marketplace=Us(d.db),t.integration=zs(d.db),t.analytics=Zs(d.db),t.policySafeKnowledgeAssistant=Xs(d.db);let P=async(c)=>{if(c==="crm-pipeline.dashboard"){let[a,v]=await Promise.all([t.crm.listDeals({projectId:s,pipelineId:"pipeline-1",limit:50}),t.crm.getPipelineStages({pipelineId:"pipeline-1"})]);return{data:{deals:a.deals,stages:v,summary:{total:a.total,totalValue:a.totalValue}},metadata:{total:a.total,timestamp:new Date,source:"crm-pipeline"}}}if(c==="crm-pipeline.deal.pipeline"){let[a,v]=await Promise.all([t.crm.listDeals({projectId:s,pipelineId:"pipeline-1",limit:100}),t.crm.getPipelineStages({pipelineId:"pipeline-1"})]);return{data:{deals:a.deals,stages:v,total:a.total,totalValue:a.totalValue},metadata:{total:a.total,timestamp:new Date,source:"crm-pipeline"}}}if(c==="saas-boilerplate.dashboard"){let[a,v]=await Promise.all([t.saas.listProjects({projectId:s,limit:10}),t.saas.getSubscription({projectId:s})]);return{data:{projects:a.items,subscription:v,summary:{totalProjects:a.total}},metadata:{total:a.total,timestamp:new Date,source:"saas-boilerplate"}}}if(c==="saas-boilerplate.project.list"){let a=await t.saas.listProjects({projectId:s,limit:50});return{data:a.items,metadata:{total:a.total,timestamp:new Date,source:"saas-boilerplate"}}}if(c==="saas-boilerplate.billing.settings")return{data:await t.saas.getSubscription({projectId:s}),metadata:{timestamp:new Date,source:"saas-boilerplate"}};if(c==="agent-console.dashboard")return{data:await Vs(t.agent,{projectId:s,organizationId:D}),metadata:{timestamp:new Date,source:"agent-console"}};if(c==="agent-console.agent.viewList"||c==="agent-console.agent.list"){let a=await t.agent.listAgents({projectId:s,organizationId:D,limit:50});return{data:a.items,metadata:{total:a.total,timestamp:new Date,source:"agent-console"}}}if(c==="agent-console.run.list"){let a=await t.agent.listRuns({projectId:s,limit:50});return{data:a.items,metadata:{total:a.total,timestamp:new Date,source:"agent-console"}}}if(c==="agent-console.tool.list"||c==="agent-console.tool.registry"){let a=await t.agent.listTools({projectId:s,organizationId:D,limit:50});return{data:a.items,metadata:{total:a.total,timestamp:new Date,source:"agent-console"}}}if(c==="visualization-showcase.gallery")return{data:null,metadata:{timestamp:new Date,source:"visualization-showcase"}};return console.warn(`No data fetcher found for presentation: ${c}`),{data:null,metadata:{timestamp:new Date,source:"unknown"}}};if(x)u({template:n,runtime:d,installer:W,client:K,templateId:o,projectId:s,engine:A,handlers:t,fetchData:P,resolvePresentation:V})}catch(n){if(Rs(n),x)X(n instanceof Error?n:Error("Unknown runtime error"))}}return O(),()=>{x=!1}},[o,s,i]);let g=Ps(o),e=Bs(()=>{if(!h)return null;return{...h,components:g}},[h,g]);if($)return Ls("div",{className:"rounded border border-red-200 bg-red-50 p-4 text-red-500",children:[l("h3",{className:"font-bold",children:"Runtime Error"}),l("pre",{className:"mt-2 overflow-auto text-xs",children:$.message})]});if(!e)return l("div",{className:"animate-pulse p-12 text-center text-gray-400",children:"Initializing runtime environment..."});return l(gs,{client:e.client,children:l(As.Provider,{value:e,children:w})})}function Ar(){return z().engine}function b(){return z().handlers}function Pr(){return b().crm}function Rr(){return b().saas}function Lr(){return b().agent}function Yr(){return b().workflow}function Mr(){return b().marketplace}function Jr(){return b().integration}function Gr(){return b().analytics}export{Yr as useWorkflowHandlers,b as useTemplateHandlers,Ar as useTemplateEngine,Rr as useSaasHandlers,Mr as useMarketplaceHandlers,Jr as useIntegrationHandlers,Pr as useCrmHandlers,Gr as useAnalyticsHandlers,Lr as useAgentHandlers,_a as searchExamples,wr as resetTemplateEngine,fr as listTemplates,B as listExamples,br as getTemplatesByModule,Q as getTemplateEngine,y as getTemplate,Ha as getExample,nr as getClonableTemplates,ps as createTemplateTransformEngine,Kr as TemplateRuntimeProvider,C as TemplateInstaller,U as TemplateHandlers,f as TEMPLATE_REGISTRY,Na as ExampleRegistry,Ga as EXAMPLE_REGISTRY};