@contractspec/module.examples 3.7.6 → 3.8.2
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.
- package/README.md +58 -10
- package/dist/builtins.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +211 -113
- package/dist/node/index.js +211 -113
- package/dist/runtime/context.d.ts +6 -6
- package/dist/runtime/installer.d.ts +2 -2
- package/dist/runtime/presentations.d.ts +2 -0
- package/dist/runtime/registry.d.ts +1 -1
- package/package.json +61 -56
package/README.md
CHANGED
|
@@ -1,21 +1,69 @@
|
|
|
1
1
|
# @contractspec/module.examples
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
+
**Example contract specifications collection.**
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## What It Provides
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- **Layer**: module.
|
|
10
|
+
- **Consumers**: apps (web-landing, docs), bundles (contractspec-studio).
|
|
11
|
+
- Related ContractSpec packages include `@contractspec/example.agent-console`, `@contractspec/example.ai-chat-assistant`, `@contractspec/example.ai-support-bot`, `@contractspec/example.analytics-dashboard`, `@contractspec/example.calendar-google`, `@contractspec/example.content-generation`, ...
|
|
12
|
+
- `agent-console` is the default autonomous-agent showcase surfaced through `/sandbox`.
|
|
13
|
+
- `data-grid-showcase` is the focused ContractSpec table showcase surfaced through `/sandbox?template=data-grid-showcase`.
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
## Installation
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
- Pure validators to enforce minimum required metadata across examples
|
|
17
|
+
`npm install @contractspec/module.examples`
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
or
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
- Deterministic outputs from explicit inputs
|
|
19
|
-
- Strong typing (no `any`)
|
|
21
|
+
`bun add @contractspec/module.examples`
|
|
20
22
|
|
|
23
|
+
## Usage
|
|
21
24
|
|
|
25
|
+
Import the root entrypoint from `@contractspec/module.examples`, or choose a documented subpath when you only need one part of the package surface.
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
- `src/builtins.ts` is part of the package's public or composition surface.
|
|
30
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
31
|
+
- `src/registry.test.ts` is part of the package's public or composition surface.
|
|
32
|
+
- `src/registry.ts` is part of the package's public or composition surface.
|
|
33
|
+
- `src/runtime` is part of the package's public or composition surface.
|
|
34
|
+
|
|
35
|
+
## Public Entry Points
|
|
36
|
+
|
|
37
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
38
|
+
|
|
39
|
+
## Local Commands
|
|
40
|
+
|
|
41
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
42
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
43
|
+
- `bun run test` — bun test
|
|
44
|
+
- `bun run lint` — bun lint:fix
|
|
45
|
+
- `bun run lint:check` — biome check .
|
|
46
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
47
|
+
- `bun run typecheck` — tsc --noEmit
|
|
48
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
49
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
50
|
+
- `bun run clean` — rimraf dist .turbo
|
|
51
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
52
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
53
|
+
- `bun run generate:registry` — bun ../../../scripts/generate-example-registry.ts --write
|
|
54
|
+
- `bun run prebuild` — bun run generate:registry && contractspec-bun-build prebuild
|
|
55
|
+
|
|
56
|
+
## Recent Updates
|
|
57
|
+
|
|
58
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
59
|
+
- Add table capabilities.
|
|
60
|
+
- Stability.
|
|
61
|
+
- Vnext ai-native.
|
|
62
|
+
|
|
63
|
+
## Notes
|
|
64
|
+
|
|
65
|
+
- This module is a thin aggregator -- business logic belongs in individual example packages under `packages/examples/`.
|
|
66
|
+
- Adding a new example requires both creating the example package and wiring it as a dependency here.
|
|
67
|
+
- Depends on ~30 example workspace packages; keep the dependency list in sync with `packages/examples/`.
|
|
68
|
+
- The meetup-ready autonomous-agent path is the deterministic `agent-console` sandbox plus its replay proof lane.
|
|
69
|
+
- The shared ContractSpec table stack is demonstrated directly by `data-grid-showcase` and reused in `analytics-dashboard`, `crm-pipeline`, `integration-hub`, and `agent-console`.
|
package/dist/builtins.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExampleSpec } from
|
|
1
|
+
import type { ExampleSpec } from '@contractspec/lib.contracts-spec/examples/types';
|
|
2
2
|
export declare const EXAMPLE_REGISTRY: readonly ExampleSpec[];
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Pure types + registries for ContractSpec examples.
|
|
5
5
|
*/
|
|
6
6
|
export * from './registry';
|
|
7
|
+
export * from './runtime/context';
|
|
7
8
|
export * from './runtime/engine';
|
|
8
9
|
export * from './runtime/installer';
|
|
9
10
|
export * from './runtime/registry';
|
|
10
|
-
export * from './runtime/context';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import AnalyticsDashboard from "@contractspec/example.analytics-dashboard/exampl
|
|
|
10
10
|
import CalendarGoogle from "@contractspec/example.calendar-google/example";
|
|
11
11
|
import ContentGeneration from "@contractspec/example.content-generation/example";
|
|
12
12
|
import CrmPipeline from "@contractspec/example.crm-pipeline/example";
|
|
13
|
+
import DataGridShowcase from "@contractspec/example.data-grid-showcase/example";
|
|
13
14
|
import EmailGmail from "@contractspec/example.email-gmail/example";
|
|
14
15
|
import InAppDocs from "@contractspec/example.in-app-docs/example";
|
|
15
16
|
import IntegrationHub from "@contractspec/example.integration-hub/example";
|
|
@@ -35,7 +36,10 @@ import LifecycleDashboard from "@contractspec/example.lifecycle-dashboard/exampl
|
|
|
35
36
|
import LocaleJurisdictionGate from "@contractspec/example.locale-jurisdiction-gate/example";
|
|
36
37
|
import Marketplace from "@contractspec/example.marketplace/example";
|
|
37
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";
|
|
38
41
|
import OpenbankingPowens from "@contractspec/example.openbanking-powens/example";
|
|
42
|
+
import OpencodeCli from "@contractspec/example.opencode-cli/example";
|
|
39
43
|
import Personalization from "@contractspec/example.personalization/example";
|
|
40
44
|
import PocketFamilyOffice from "@contractspec/example.pocket-family-office/example";
|
|
41
45
|
import PolicySafeKnowledgeAssistant from "@contractspec/example.policy-safe-knowledge-assistant/example";
|
|
@@ -48,6 +52,7 @@ import VersionedKnowledgeBase from "@contractspec/example.versioned-knowledge-ba
|
|
|
48
52
|
import VideoApiShowcase from "@contractspec/example.video-api-showcase/example";
|
|
49
53
|
import VideoDocsTerminal from "@contractspec/example.video-docs-terminal/example";
|
|
50
54
|
import VideoMarketingClip from "@contractspec/example.video-marketing-clip/example";
|
|
55
|
+
import VisualizationShowcase from "@contractspec/example.visualization-showcase/example";
|
|
51
56
|
import VoiceProviders from "@contractspec/example.voice-providers/example";
|
|
52
57
|
import WealthSnapshot from "@contractspec/example.wealth-snapshot/example";
|
|
53
58
|
import WorkflowSystem from "@contractspec/example.workflow-system/example";
|
|
@@ -59,6 +64,7 @@ var EXAMPLE_REGISTRY = [
|
|
|
59
64
|
CalendarGoogle,
|
|
60
65
|
ContentGeneration,
|
|
61
66
|
CrmPipeline,
|
|
67
|
+
DataGridShowcase,
|
|
62
68
|
EmailGmail,
|
|
63
69
|
InAppDocs,
|
|
64
70
|
IntegrationHub,
|
|
@@ -84,7 +90,10 @@ var EXAMPLE_REGISTRY = [
|
|
|
84
90
|
LocaleJurisdictionGate,
|
|
85
91
|
Marketplace,
|
|
86
92
|
MeetingRecorderProviders,
|
|
93
|
+
MessagingAgentActions,
|
|
94
|
+
Minimal,
|
|
87
95
|
OpenbankingPowens,
|
|
96
|
+
OpencodeCli,
|
|
88
97
|
Personalization,
|
|
89
98
|
PocketFamilyOffice,
|
|
90
99
|
PolicySafeKnowledgeAssistant,
|
|
@@ -97,6 +106,7 @@ var EXAMPLE_REGISTRY = [
|
|
|
97
106
|
VideoApiShowcase,
|
|
98
107
|
VideoDocsTerminal,
|
|
99
108
|
VideoMarketingClip,
|
|
109
|
+
VisualizationShowcase,
|
|
100
110
|
VoiceProviders,
|
|
101
111
|
WealthSnapshot,
|
|
102
112
|
WorkflowSystem
|
|
@@ -118,12 +128,43 @@ function getExample(key) {
|
|
|
118
128
|
function searchExamples(query) {
|
|
119
129
|
return globalRegistry.search(query);
|
|
120
130
|
}
|
|
121
|
-
// src/runtime/
|
|
131
|
+
// src/runtime/context.tsx
|
|
132
|
+
import { ApolloProvider } from "@apollo/client/react";
|
|
133
|
+
import { web as web2 } from "@contractspec/lib.runtime-sandbox";
|
|
134
|
+
import { useEffect, useMemo, useState } from "react";
|
|
122
135
|
import {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} from "@contractspec/
|
|
136
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
137
|
+
createAgentConsoleDemoHandlers,
|
|
138
|
+
getAgentConsoleDashboardData
|
|
139
|
+
} from "@contractspec/example.agent-console";
|
|
140
|
+
import {
|
|
141
|
+
createAnalyticsHandlers
|
|
142
|
+
} from "@contractspec/example.analytics-dashboard";
|
|
143
|
+
import {
|
|
144
|
+
createCrmHandlers
|
|
145
|
+
} from "@contractspec/example.crm-pipeline";
|
|
146
|
+
import {
|
|
147
|
+
createIntegrationHandlers
|
|
148
|
+
} from "@contractspec/example.integration-hub";
|
|
149
|
+
import {
|
|
150
|
+
createMarketplaceHandlers
|
|
151
|
+
} from "@contractspec/example.marketplace";
|
|
152
|
+
import {
|
|
153
|
+
createPolicySafeKnowledgeAssistantHandlers
|
|
154
|
+
} from "@contractspec/example.policy-safe-knowledge-assistant";
|
|
155
|
+
import {
|
|
156
|
+
createSaasHandlers
|
|
157
|
+
} from "@contractspec/example.saas-boilerplate";
|
|
158
|
+
import {
|
|
159
|
+
createWorkflowHandlers
|
|
160
|
+
} from "@contractspec/example.workflow-system";
|
|
161
|
+
import {
|
|
162
|
+
TemplateRuntimeContext,
|
|
163
|
+
useTemplateComponents,
|
|
164
|
+
useTemplateRuntime
|
|
165
|
+
} from "@contractspec/lib.example-shared-ui";
|
|
166
|
+
|
|
167
|
+
// src/runtime/engine.ts
|
|
127
168
|
import {
|
|
128
169
|
agentDashboardMarkdownRenderer,
|
|
129
170
|
agentListMarkdownRenderer,
|
|
@@ -132,36 +173,42 @@ import {
|
|
|
132
173
|
toolRegistryMarkdownRenderer
|
|
133
174
|
} from "@contractspec/example.agent-console";
|
|
134
175
|
import {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} from "@contractspec/example.saas-boilerplate";
|
|
176
|
+
analyticsDashboardMarkdownRenderer,
|
|
177
|
+
dashboardListMarkdownRenderer,
|
|
178
|
+
queryBuilderMarkdownRenderer
|
|
179
|
+
} from "@contractspec/example.analytics-dashboard";
|
|
140
180
|
import {
|
|
141
181
|
crmDashboardMarkdownRenderer,
|
|
142
182
|
crmPipelineMarkdownRenderer,
|
|
143
183
|
crmPipelineReactRenderer
|
|
144
184
|
} from "@contractspec/example.crm-pipeline";
|
|
145
185
|
import {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} from "@contractspec/example.
|
|
186
|
+
connectionListMarkdownRenderer,
|
|
187
|
+
integrationDashboardMarkdownRenderer,
|
|
188
|
+
syncConfigMarkdownRenderer
|
|
189
|
+
} from "@contractspec/example.integration-hub";
|
|
150
190
|
import {
|
|
151
191
|
marketplaceDashboardMarkdownRenderer,
|
|
152
192
|
orderListMarkdownRenderer,
|
|
153
193
|
productCatalogMarkdownRenderer
|
|
154
194
|
} from "@contractspec/example.marketplace";
|
|
155
195
|
import {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
196
|
+
projectListMarkdownRenderer,
|
|
197
|
+
projectListReactRenderer,
|
|
198
|
+
saasBillingMarkdownRenderer,
|
|
199
|
+
saasDashboardMarkdownRenderer
|
|
200
|
+
} from "@contractspec/example.saas-boilerplate";
|
|
201
|
+
import { visualizationShowcaseMarkdownRenderer } from "@contractspec/example.visualization-showcase/ui/renderers";
|
|
160
202
|
import {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} from "@contractspec/example.
|
|
203
|
+
workflowDashboardMarkdownRenderer,
|
|
204
|
+
workflowDefinitionListMarkdownRenderer,
|
|
205
|
+
workflowInstanceDetailMarkdownRenderer
|
|
206
|
+
} from "@contractspec/example.workflow-system";
|
|
207
|
+
import {
|
|
208
|
+
createDefaultTransformEngine,
|
|
209
|
+
registerBasicValidation,
|
|
210
|
+
registerDefaultReactRenderer
|
|
211
|
+
} from "@contractspec/lib.contracts-spec/presentations/transform-engine";
|
|
165
212
|
function createTemplateTransformEngine() {
|
|
166
213
|
const engine = createDefaultTransformEngine();
|
|
167
214
|
registerDefaultReactRenderer(engine);
|
|
@@ -194,6 +241,7 @@ function registerTemplateRenderers(engine) {
|
|
|
194
241
|
engine.register(analyticsDashboardMarkdownRenderer);
|
|
195
242
|
engine.register(dashboardListMarkdownRenderer);
|
|
196
243
|
engine.register(queryBuilderMarkdownRenderer);
|
|
244
|
+
engine.register(visualizationShowcaseMarkdownRenderer);
|
|
197
245
|
}
|
|
198
246
|
var templateEngine = null;
|
|
199
247
|
function getTemplateEngine() {
|
|
@@ -205,6 +253,10 @@ function getTemplateEngine() {
|
|
|
205
253
|
function resetTemplateEngine() {
|
|
206
254
|
templateEngine = null;
|
|
207
255
|
}
|
|
256
|
+
|
|
257
|
+
// src/runtime/installer.ts
|
|
258
|
+
import { web } from "@contractspec/lib.runtime-sandbox";
|
|
259
|
+
|
|
208
260
|
// src/runtime/registry.ts
|
|
209
261
|
var PRESENTATIONS_BY_TEMPLATE = {
|
|
210
262
|
"saas-boilerplate": [
|
|
@@ -215,9 +267,9 @@ var PRESENTATIONS_BY_TEMPLATE = {
|
|
|
215
267
|
"crm-pipeline": ["crm-pipeline.dashboard", "crm-pipeline.deal.pipeline"],
|
|
216
268
|
"agent-console": [
|
|
217
269
|
"agent-console.dashboard",
|
|
218
|
-
"agent-console.agent.
|
|
270
|
+
"agent-console.agent.viewList",
|
|
219
271
|
"agent-console.run.list",
|
|
220
|
-
"agent-console.tool.
|
|
272
|
+
"agent-console.tool.list"
|
|
221
273
|
],
|
|
222
274
|
"workflow-system": [
|
|
223
275
|
"workflow-system.dashboard",
|
|
@@ -227,8 +279,7 @@ var PRESENTATIONS_BY_TEMPLATE = {
|
|
|
227
279
|
marketplace: [
|
|
228
280
|
"marketplace.dashboard",
|
|
229
281
|
"marketplace.product.catalog",
|
|
230
|
-
"marketplace.order.list"
|
|
231
|
-
"marketplace.store.manage"
|
|
282
|
+
"marketplace.order.list"
|
|
232
283
|
],
|
|
233
284
|
"integration-hub": [
|
|
234
285
|
"integration-hub.dashboard",
|
|
@@ -240,6 +291,7 @@ var PRESENTATIONS_BY_TEMPLATE = {
|
|
|
240
291
|
"analytics-dashboard.list",
|
|
241
292
|
"analytics-dashboard.query.builder"
|
|
242
293
|
],
|
|
294
|
+
"visualization-showcase": ["visualization-showcase.gallery"],
|
|
243
295
|
"learning-journey-studio-onboarding": [
|
|
244
296
|
"learning.journey.track_list",
|
|
245
297
|
"learning.journey.track_detail",
|
|
@@ -271,6 +323,28 @@ var PRESENTATIONS_BY_TEMPLATE = {
|
|
|
271
323
|
"learning.journey.progress_widget"
|
|
272
324
|
]
|
|
273
325
|
};
|
|
326
|
+
var GENERATED_TEMPLATE_REGISTRY = listExamples().filter((example) => example.meta.key !== "agent-console").map((example) => {
|
|
327
|
+
const tags = [...example.meta.tags ?? []];
|
|
328
|
+
const category = tags.some((tag) => tag.toLowerCase() === "ai") || tags.some((tag) => tag.toLowerCase() === "assistant") ? "ai" : "business";
|
|
329
|
+
return {
|
|
330
|
+
id: example.meta.key,
|
|
331
|
+
name: example.meta.title ?? example.meta.key,
|
|
332
|
+
description: example.meta.description ?? "",
|
|
333
|
+
category,
|
|
334
|
+
complexity: "beginner",
|
|
335
|
+
icon: "\uD83D\uDCE6",
|
|
336
|
+
features: [],
|
|
337
|
+
tags,
|
|
338
|
+
schema: { models: [], contracts: [] },
|
|
339
|
+
components: { list: "ExampleList", detail: "ExampleDetail" },
|
|
340
|
+
preview: {
|
|
341
|
+
demoUrl: `/sandbox?template=${encodeURIComponent(example.meta.key)}`
|
|
342
|
+
},
|
|
343
|
+
package: example.entrypoints.packageName,
|
|
344
|
+
presentations: PRESENTATIONS_BY_TEMPLATE[example.meta.key] ?? [],
|
|
345
|
+
renderTargets: ["react", "markdown"]
|
|
346
|
+
};
|
|
347
|
+
});
|
|
274
348
|
var TEMPLATE_REGISTRY = [
|
|
275
349
|
{
|
|
276
350
|
id: "todos-app",
|
|
@@ -357,30 +431,42 @@ var TEMPLATE_REGISTRY = [
|
|
|
357
431
|
quickstart: "/docs/templates/recipe-app-i18n"
|
|
358
432
|
}
|
|
359
433
|
},
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
|
|
434
|
+
{
|
|
435
|
+
id: "agent-console",
|
|
436
|
+
name: "Agent Console",
|
|
437
|
+
description: "Deterministic autonomous-agent walkthrough with seeded agents, tool registry, runs, metrics, and replayable proof.",
|
|
438
|
+
category: "ai",
|
|
439
|
+
complexity: "intermediate",
|
|
440
|
+
icon: "\uD83E\uDD16",
|
|
441
|
+
features: [
|
|
442
|
+
"Seeded autonomous agents",
|
|
443
|
+
"Tool registry",
|
|
444
|
+
"Run execution history",
|
|
445
|
+
"Metrics",
|
|
446
|
+
"Markdown and React views"
|
|
447
|
+
],
|
|
448
|
+
tags: ["ai", "agents", "autonomous", "meetup", "sandbox"],
|
|
449
|
+
schema: {
|
|
450
|
+
models: ["Agent", "Tool", "Run"],
|
|
451
|
+
contracts: [
|
|
452
|
+
"agent-console.agent.list",
|
|
453
|
+
"agent-console.agent.create",
|
|
454
|
+
"agent-console.run.execute"
|
|
455
|
+
]
|
|
456
|
+
},
|
|
457
|
+
components: {
|
|
458
|
+
list: "AgentListView",
|
|
459
|
+
detail: "RunListView",
|
|
460
|
+
form: "CreateAgentModal"
|
|
461
|
+
},
|
|
462
|
+
preview: {
|
|
463
|
+
demoUrl: "/sandbox?template=agent-console"
|
|
464
|
+
},
|
|
465
|
+
package: "@contractspec/example.agent-console",
|
|
466
|
+
presentations: PRESENTATIONS_BY_TEMPLATE["agent-console"] ?? [],
|
|
467
|
+
renderTargets: ["react", "markdown"]
|
|
468
|
+
},
|
|
469
|
+
...GENERATED_TEMPLATE_REGISTRY
|
|
384
470
|
];
|
|
385
471
|
function listTemplates(filter) {
|
|
386
472
|
if (!filter)
|
|
@@ -454,7 +540,6 @@ class ContractSpecRegistryClient {
|
|
|
454
540
|
}
|
|
455
541
|
|
|
456
542
|
// src/runtime/installer.ts
|
|
457
|
-
import { web } from "@contractspec/lib.runtime-sandbox";
|
|
458
543
|
"use client";
|
|
459
544
|
var { LocalRuntimeServices } = web;
|
|
460
545
|
var SAVE_TEMPLATE_MUTATION = `
|
|
@@ -560,39 +645,60 @@ function toBase64(bytes) {
|
|
|
560
645
|
});
|
|
561
646
|
return btoa(binary);
|
|
562
647
|
}
|
|
648
|
+
|
|
649
|
+
// src/runtime/presentations.ts
|
|
650
|
+
function createComponentPresentation(key, title, description, goal, context, componentKey) {
|
|
651
|
+
return {
|
|
652
|
+
meta: {
|
|
653
|
+
key,
|
|
654
|
+
version: "1.0.0",
|
|
655
|
+
title,
|
|
656
|
+
description,
|
|
657
|
+
stability: "experimental",
|
|
658
|
+
goal,
|
|
659
|
+
context,
|
|
660
|
+
owners: ["@contractspec/examples"],
|
|
661
|
+
tags: ["template", "sandbox"]
|
|
662
|
+
},
|
|
663
|
+
source: {
|
|
664
|
+
type: "component",
|
|
665
|
+
framework: "react",
|
|
666
|
+
componentKey
|
|
667
|
+
},
|
|
668
|
+
targets: ["react", "markdown"]
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
var TEMPLATE_PRESENTATIONS = {
|
|
672
|
+
"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"),
|
|
673
|
+
"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"),
|
|
674
|
+
"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"),
|
|
675
|
+
"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"),
|
|
676
|
+
"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"),
|
|
677
|
+
"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"),
|
|
678
|
+
"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"),
|
|
679
|
+
"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"),
|
|
680
|
+
"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"),
|
|
681
|
+
"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"),
|
|
682
|
+
"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"),
|
|
683
|
+
"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"),
|
|
684
|
+
"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"),
|
|
685
|
+
"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"),
|
|
686
|
+
"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"),
|
|
687
|
+
"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"),
|
|
688
|
+
"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"),
|
|
689
|
+
"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"),
|
|
690
|
+
"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"),
|
|
691
|
+
"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"),
|
|
692
|
+
"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"),
|
|
693
|
+
"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"),
|
|
694
|
+
"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"),
|
|
695
|
+
"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")
|
|
696
|
+
};
|
|
697
|
+
function resolveTemplatePresentation(presentationName) {
|
|
698
|
+
return TEMPLATE_PRESENTATIONS[presentationName];
|
|
699
|
+
}
|
|
700
|
+
|
|
563
701
|
// src/runtime/context.tsx
|
|
564
|
-
import { useEffect, useMemo, useState } from "react";
|
|
565
|
-
import { ApolloProvider } from "@apollo/client/react";
|
|
566
|
-
import { web as web2 } from "@contractspec/lib.runtime-sandbox";
|
|
567
|
-
import {
|
|
568
|
-
createCrmHandlers
|
|
569
|
-
} from "@contractspec/example.crm-pipeline";
|
|
570
|
-
import {
|
|
571
|
-
createSaasHandlers
|
|
572
|
-
} from "@contractspec/example.saas-boilerplate";
|
|
573
|
-
import {
|
|
574
|
-
createAgentHandlers
|
|
575
|
-
} from "@contractspec/example.agent-console";
|
|
576
|
-
import {
|
|
577
|
-
createWorkflowHandlers
|
|
578
|
-
} from "@contractspec/example.workflow-system";
|
|
579
|
-
import {
|
|
580
|
-
createMarketplaceHandlers
|
|
581
|
-
} from "@contractspec/example.marketplace";
|
|
582
|
-
import {
|
|
583
|
-
createIntegrationHandlers
|
|
584
|
-
} from "@contractspec/example.integration-hub";
|
|
585
|
-
import {
|
|
586
|
-
createAnalyticsHandlers
|
|
587
|
-
} from "@contractspec/example.analytics-dashboard";
|
|
588
|
-
import {
|
|
589
|
-
createPolicySafeKnowledgeAssistantHandlers
|
|
590
|
-
} from "@contractspec/example.policy-safe-knowledge-assistant";
|
|
591
|
-
import {
|
|
592
|
-
TemplateRuntimeContext,
|
|
593
|
-
useTemplateRuntime,
|
|
594
|
-
useTemplateComponents
|
|
595
|
-
} from "@contractspec/lib.example-shared-ui";
|
|
596
702
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
597
703
|
"use client";
|
|
598
704
|
var { LocalRuntimeServices: LocalRuntimeServices2 } = web2;
|
|
@@ -622,7 +728,7 @@ class TemplateHandlers {
|
|
|
622
728
|
}
|
|
623
729
|
function TemplateRuntimeProvider({
|
|
624
730
|
templateId,
|
|
625
|
-
projectId = "
|
|
731
|
+
projectId = "local-project",
|
|
626
732
|
lazy = false,
|
|
627
733
|
children
|
|
628
734
|
}) {
|
|
@@ -647,7 +753,7 @@ function TemplateRuntimeProvider({
|
|
|
647
753
|
const handlers = new TemplateHandlers;
|
|
648
754
|
handlers.crm = createCrmHandlers(runtime.db);
|
|
649
755
|
handlers.saas = createSaasHandlers(runtime.db);
|
|
650
|
-
handlers.agent =
|
|
756
|
+
handlers.agent = createAgentConsoleDemoHandlers({ projectId });
|
|
651
757
|
handlers.workflow = createWorkflowHandlers(runtime.db);
|
|
652
758
|
handlers.marketplace = createMarketplaceHandlers(runtime.db);
|
|
653
759
|
handlers.integration = createIntegrationHandlers(runtime.db);
|
|
@@ -744,37 +850,19 @@ function TemplateRuntimeProvider({
|
|
|
744
850
|
};
|
|
745
851
|
}
|
|
746
852
|
if (presentationName === "agent-console.dashboard") {
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
limit: 10
|
|
752
|
-
}),
|
|
753
|
-
handlers.agent.listRuns({ projectId, limit: 10 }),
|
|
754
|
-
handlers.agent.listTools({
|
|
755
|
-
projectId,
|
|
756
|
-
organizationId: "demo-org",
|
|
757
|
-
limit: 10
|
|
758
|
-
})
|
|
759
|
-
]);
|
|
853
|
+
const data = await getAgentConsoleDashboardData(handlers.agent, {
|
|
854
|
+
projectId,
|
|
855
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID
|
|
856
|
+
});
|
|
760
857
|
return {
|
|
761
|
-
data
|
|
762
|
-
agents: agentsResult.items,
|
|
763
|
-
runs: runsResult.items,
|
|
764
|
-
tools: toolsResult.items,
|
|
765
|
-
summary: {
|
|
766
|
-
totalAgents: agentsResult.total,
|
|
767
|
-
totalRuns: runsResult.total,
|
|
768
|
-
totalTools: toolsResult.total
|
|
769
|
-
}
|
|
770
|
-
},
|
|
858
|
+
data,
|
|
771
859
|
metadata: { timestamp: new Date, source: "agent-console" }
|
|
772
860
|
};
|
|
773
861
|
}
|
|
774
|
-
if (presentationName === "agent-console.agent.list") {
|
|
862
|
+
if (presentationName === "agent-console.agent.viewList" || presentationName === "agent-console.agent.list") {
|
|
775
863
|
const result = await handlers.agent.listAgents({
|
|
776
864
|
projectId,
|
|
777
|
-
organizationId:
|
|
865
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
778
866
|
limit: 50
|
|
779
867
|
});
|
|
780
868
|
return {
|
|
@@ -800,10 +888,10 @@ function TemplateRuntimeProvider({
|
|
|
800
888
|
}
|
|
801
889
|
};
|
|
802
890
|
}
|
|
803
|
-
if (presentationName === "agent-console.tool.registry") {
|
|
891
|
+
if (presentationName === "agent-console.tool.list" || presentationName === "agent-console.tool.registry") {
|
|
804
892
|
const result = await handlers.agent.listTools({
|
|
805
893
|
projectId,
|
|
806
|
-
organizationId:
|
|
894
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
807
895
|
limit: 50
|
|
808
896
|
});
|
|
809
897
|
return {
|
|
@@ -815,6 +903,15 @@ function TemplateRuntimeProvider({
|
|
|
815
903
|
}
|
|
816
904
|
};
|
|
817
905
|
}
|
|
906
|
+
if (presentationName === "visualization-showcase.gallery") {
|
|
907
|
+
return {
|
|
908
|
+
data: null,
|
|
909
|
+
metadata: {
|
|
910
|
+
timestamp: new Date,
|
|
911
|
+
source: "visualization-showcase"
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
818
915
|
console.warn(`No data fetcher found for presentation: ${presentationName}`);
|
|
819
916
|
return {
|
|
820
917
|
data: null,
|
|
@@ -831,7 +928,8 @@ function TemplateRuntimeProvider({
|
|
|
831
928
|
projectId,
|
|
832
929
|
engine,
|
|
833
930
|
handlers,
|
|
834
|
-
fetchData
|
|
931
|
+
fetchData,
|
|
932
|
+
resolvePresentation: resolveTemplatePresentation
|
|
835
933
|
});
|
|
836
934
|
}
|
|
837
935
|
} catch (err) {
|