@adia-ai/gen-ui 0.8.37
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/CHANGELOG.md +26 -0
- package/README.md +77 -0
- package/compose/CHANGELOG.md +1707 -0
- package/compose/README.md +215 -0
- package/compose/core/artifacts.js +262 -0
- package/compose/core/context-store.js +218 -0
- package/compose/core/generator.d.ts +4 -0
- package/compose/core/generator.js +602 -0
- package/compose/core/pipeline/engine.js +289 -0
- package/compose/core/pipeline/types.js +91 -0
- package/compose/core/plan-primitives.js +120 -0
- package/compose/core/plan-turn.js +145 -0
- package/compose/core/reference.js +150 -0
- package/compose/core/state.js +15 -0
- package/compose/evals/harness.d.ts +4 -0
- package/compose/evals/harness.mjs +193 -0
- package/compose/index.d.ts +4 -0
- package/compose/index.js +16 -0
- package/compose/shared/validate-and-repair.js +122 -0
- package/compose/strategies/_shared/chunk-loader.js +282 -0
- package/compose/strategies/cascade.d.ts +67 -0
- package/compose/strategies/cascade.js +165 -0
- package/compose/strategies/escalation.d.ts +13 -0
- package/compose/strategies/escalation.js +132 -0
- package/compose/strategies/free-form-composer/index.js +254 -0
- package/compose/strategies/free-form-composer/system-prompt.js +205 -0
- package/compose/strategies/free-form-composer/transpile.js +279 -0
- package/compose/strategies/monolithic/_shared.js +1619 -0
- package/compose/strategies/monolithic/generate-instant.js +228 -0
- package/compose/strategies/monolithic/generate-pro.js +490 -0
- package/compose/strategies/monolithic/generate-thinking.js +206 -0
- package/compose/strategies/registry.d.ts +20 -0
- package/compose/strategies/registry.js +495 -0
- package/compose/strategies/zettel/_smoke.js +27 -0
- package/compose/strategies/zettel/chunk-composer.js +214 -0
- package/compose/strategies/zettel/chunk-refiner.js +582 -0
- package/compose/strategies/zettel/chunk-synthesizer.js +458 -0
- package/compose/strategies/zettel/composer.js +78 -0
- package/compose/strategies/zettel/composition-library.js +418 -0
- package/compose/strategies/zettel/generate.js +15 -0
- package/compose/strategies/zettel/generator-adapter.d.ts +4 -0
- package/compose/strategies/zettel/generator-adapter.js +242 -0
- package/compose/strategies/zettel/issue-reporter.js +607 -0
- package/compose/strategies/zettel/session-store.js +121 -0
- package/compose/strategies/zettel/state-cache.js +158 -0
- package/compose/transpiler/transpiler-maps.js +675 -0
- package/compose/transpiler/transpiler.d.ts +4 -0
- package/compose/transpiler/transpiler.js +962 -0
- package/corpus/CHANGELOG.md +1957 -0
- package/corpus/README.md +279 -0
- package/corpus/catalog-a2ui_0_9.d.ts +4 -0
- package/corpus/catalog-a2ui_0_9.json +29571 -0
- package/corpus/catalog-a2ui_0_9_rules.txt +1215 -0
- package/corpus/chunk-embeddings.d.ts +4 -0
- package/corpus/chunk-embeddings.json +1 -0
- package/corpus/chunks/_index.json +16658 -0
- package/corpus/chunks/_source-hashes.json +571 -0
- package/corpus/chunks/access-denied-with-request.json +124 -0
- package/corpus/chunks/access-request-form.json +166 -0
- package/corpus/chunks/access-request-pending.json +133 -0
- package/corpus/chunks/accordion-settings.json +176 -0
- package/corpus/chunks/achievement-badges.json +413 -0
- package/corpus/chunks/achievement-unlock.json +104 -0
- package/corpus/chunks/action-list-record-actions.json +84 -0
- package/corpus/chunks/activity-feed.json +390 -0
- package/corpus/chunks/admin-page-header-flush.json +83 -0
- package/corpus/chunks/admin-page-header-title-description.json +80 -0
- package/corpus/chunks/admin-page-header-with-actions.json +107 -0
- package/corpus/chunks/admin-page-header-with-tabs.json +144 -0
- package/corpus/chunks/admin-shell-rounded-borderless.json +287 -0
- package/corpus/chunks/admin-shell-standard.json +310 -0
- package/corpus/chunks/admin-sidebar-brand-signin.json +158 -0
- package/corpus/chunks/admin-sidebar-brand-version.json +130 -0
- package/corpus/chunks/admin-sidebar-flat-nav.json +131 -0
- package/corpus/chunks/admin-sidebar-nav-dividers.json +150 -0
- package/corpus/chunks/admin-sidebar-nav-groups.json +171 -0
- package/corpus/chunks/admin-sidebar-workspace-switcher.json +139 -0
- package/corpus/chunks/admin-topbar-breadcrumb-actions.json +130 -0
- package/corpus/chunks/admin-topbar-breadcrumb-minimal.json +79 -0
- package/corpus/chunks/admin-topbar-deep-breadcrumb.json +129 -0
- package/corpus/chunks/admin-topbar-search.json +104 -0
- package/corpus/chunks/admin-topbar-status-indicator.json +122 -0
- package/corpus/chunks/admin-topbar-trailing-toggle.json +114 -0
- package/corpus/chunks/agent-activity-feed.json +163 -0
- package/corpus/chunks/agent-artifact-stub-card.json +115 -0
- package/corpus/chunks/agent-canvas-shell.json +305 -0
- package/corpus/chunks/agent-citations-source-chips.json +82 -0
- package/corpus/chunks/agent-command-palette-search.json +120 -0
- package/corpus/chunks/agent-cost-detailed.json +260 -0
- package/corpus/chunks/agent-cost-inline.json +78 -0
- package/corpus/chunks/agent-memory-detail.json +181 -0
- package/corpus/chunks/agent-memory-editor.json +173 -0
- package/corpus/chunks/agent-memory-list.json +207 -0
- package/corpus/chunks/agent-pipeline-status-stages.json +61 -0
- package/corpus/chunks/agent-prompt-card.json +179 -0
- package/corpus/chunks/agent-prompt-library-grid.json +341 -0
- package/corpus/chunks/agent-prompt-picker.json +282 -0
- package/corpus/chunks/agent-rate-limit.json +100 -0
- package/corpus/chunks/agent-reasoning-collapsed.json +128 -0
- package/corpus/chunks/agent-tool-call-accordion.json +109 -0
- package/corpus/chunks/agent-tool-call-collapsed.json +98 -0
- package/corpus/chunks/agent-tool-call-error.json +112 -0
- package/corpus/chunks/agent-tool-call-result.json +145 -0
- package/corpus/chunks/agent-tool-call-running.json +85 -0
- package/corpus/chunks/agent-tool-call-success.json +137 -0
- package/corpus/chunks/agent-trace-timeline.json +244 -0
- package/corpus/chunks/ai-streaming-response.json +147 -0
- package/corpus/chunks/alert-banner-stack.json +78 -0
- package/corpus/chunks/alert-banner.json +55 -0
- package/corpus/chunks/alert-dialog-simple.json +72 -0
- package/corpus/chunks/alert-dialog-typed.json +107 -0
- package/corpus/chunks/alert-dialog-unsaved.json +81 -0
- package/corpus/chunks/analytics-chart.json +213 -0
- package/corpus/chunks/analytics-sparklines-dashboard.json +259 -0
- package/corpus/chunks/anchor-bar-selection-bar.json +226 -0
- package/corpus/chunks/api-key-table.json +148 -0
- package/corpus/chunks/api-keys-create.json +140 -0
- package/corpus/chunks/api-keys-list.json +271 -0
- package/corpus/chunks/app-nav-badges-counts.json +77 -0
- package/corpus/chunks/app-nav-badges-group-rollup-badges.json +100 -0
- package/corpus/chunks/app-nav-badges-plan-tiers.json +76 -0
- package/corpus/chunks/app-nav-badges-status-callouts.json +75 -0
- package/corpus/chunks/app-nav-full-example.json +195 -0
- package/corpus/chunks/app-nav-groups.json +103 -0
- package/corpus/chunks/app-nav-items.json +74 -0
- package/corpus/chunks/app-nav-labels-and-dividers.json +92 -0
- package/corpus/chunks/app-nav-spacer.json +77 -0
- package/corpus/chunks/app-product-listing-card.json +214 -0
- package/corpus/chunks/approvals-detail.json +240 -0
- package/corpus/chunks/approvals-queue.json +321 -0
- package/corpus/chunks/audit-log-basic.json +184 -0
- package/corpus/chunks/audit-log.json +174 -0
- package/corpus/chunks/auth-account-deleted-actions.json +51 -0
- package/corpus/chunks/auth-account-deleted.json +202 -0
- package/corpus/chunks/auth-card-content.json +260 -0
- package/corpus/chunks/auth-card-header.json +205 -0
- package/corpus/chunks/auth-email-entry.json +65 -0
- package/corpus/chunks/auth-email-verify-confirm.json +52 -0
- package/corpus/chunks/auth-email-verify.json +196 -0
- package/corpus/chunks/auth-forbidden-actions.json +59 -0
- package/corpus/chunks/auth-forbidden.json +203 -0
- package/corpus/chunks/auth-invite-actions.json +49 -0
- package/corpus/chunks/auth-invite-team-card.json +86 -0
- package/corpus/chunks/auth-link-expired-form.json +65 -0
- package/corpus/chunks/auth-link-expired.json +196 -0
- package/corpus/chunks/auth-locked-account.json +211 -0
- package/corpus/chunks/auth-locked-recovery-options.json +60 -0
- package/corpus/chunks/auth-mfa-enrollment-submit.json +54 -0
- package/corpus/chunks/auth-mfa-enrollment.json +284 -0
- package/corpus/chunks/auth-mfa-fallback-actions.json +52 -0
- package/corpus/chunks/auth-mfa-recovery.json +61 -0
- package/corpus/chunks/auth-new-password-form.json +75 -0
- package/corpus/chunks/auth-new-password.json +217 -0
- package/corpus/chunks/auth-oauth-fallback-actions.json +52 -0
- package/corpus/chunks/auth-oauth-interstitial.json +160 -0
- package/corpus/chunks/auth-password-challenge.json +94 -0
- package/corpus/chunks/auth-password-reset-form.json +64 -0
- package/corpus/chunks/auth-password-reset.json +195 -0
- package/corpus/chunks/auth-profile-form.json +72 -0
- package/corpus/chunks/auth-profile-setup.json +194 -0
- package/corpus/chunks/auth-reset-sent.json +188 -0
- package/corpus/chunks/auth-session-expired-actions.json +52 -0
- package/corpus/chunks/auth-session-expired.json +201 -0
- package/corpus/chunks/auth-signin-card-email.json +245 -0
- package/corpus/chunks/auth-signin-card-magic-link.json +147 -0
- package/corpus/chunks/auth-signin-card-mfa.json +231 -0
- package/corpus/chunks/auth-signin-card-otp.json +205 -0
- package/corpus/chunks/auth-signin-card-password.json +264 -0
- package/corpus/chunks/auth-signin-card-recovery.json +218 -0
- package/corpus/chunks/auth-signout-actions.json +51 -0
- package/corpus/chunks/auth-signout.json +184 -0
- package/corpus/chunks/auth-signup-email-entry.json +66 -0
- package/corpus/chunks/auth-signup-entry.json +281 -0
- package/corpus/chunks/auth-signup-social-auths.json +54 -0
- package/corpus/chunks/auth-signup-verify.json +227 -0
- package/corpus/chunks/auth-social-auths.json +62 -0
- package/corpus/chunks/auth-sso-providers.json +55 -0
- package/corpus/chunks/auth-sso-required.json +213 -0
- package/corpus/chunks/auth-team-invite.json +288 -0
- package/corpus/chunks/avatar-group-overflow.json +137 -0
- package/corpus/chunks/avatar-stack-overflow.json +124 -0
- package/corpus/chunks/banner-announcement-beta.json +99 -0
- package/corpus/chunks/banner-announcement-promo.json +102 -0
- package/corpus/chunks/banner-live-update.json +102 -0
- package/corpus/chunks/banner-system-maintenance.json +101 -0
- package/corpus/chunks/banner-system-offline.json +85 -0
- package/corpus/chunks/banner-system-update.json +102 -0
- package/corpus/chunks/bell-menu-empty.json +107 -0
- package/corpus/chunks/bell-menu-unread.json +395 -0
- package/corpus/chunks/billing-cancel-subscription-danger.json +61 -0
- package/corpus/chunks/billing-invoice-history-table.json +75 -0
- package/corpus/chunks/billing-overview.json +202 -0
- package/corpus/chunks/billing-payment-method-card-on-file.json +157 -0
- package/corpus/chunks/billing-progress-label.json +101 -0
- package/corpus/chunks/blog-post-card.json +212 -0
- package/corpus/chunks/breadcrumb-navigation.json +72 -0
- package/corpus/chunks/bulk-action-toolbar-floating.json +199 -0
- package/corpus/chunks/bulk-action-toolbar-swap.json +158 -0
- package/corpus/chunks/bulk-selection-actions-bar.json +162 -0
- package/corpus/chunks/business-address-form.json +953 -0
- package/corpus/chunks/calendar-month-view.json +74 -0
- package/corpus/chunks/card-grid-images.json +459 -0
- package/corpus/chunks/card-header-with-description.json +47 -0
- package/corpus/chunks/card-with-empty-state.json +96 -0
- package/corpus/chunks/card-with-form.json +143 -0
- package/corpus/chunks/card-with-sparkline.json +90 -0
- package/corpus/chunks/card-with-stat-kpi.json +86 -0
- package/corpus/chunks/changelog-feed-basic.json +470 -0
- package/corpus/chunks/chart-in-card-chart-plus-breakdown.json +188 -0
- package/corpus/chunks/chart-in-card-chart-plus-stat.json +89 -0
- package/corpus/chunks/chart-in-card-chart-with-filter-pills.json +124 -0
- package/corpus/chunks/chart-in-card-full-bleed-legend.json +116 -0
- package/corpus/chunks/chart-in-card-full-chart.json +107 -0
- package/corpus/chunks/chart-in-card-sparkline-tile.json +93 -0
- package/corpus/chunks/chart-in-card-stat-with-sparkline.json +73 -0
- package/corpus/chunks/chart-in-card-trend-footer.json +115 -0
- package/corpus/chunks/chart-with-filter-pills.json +169 -0
- package/corpus/chunks/chat-empty-state-hero.json +102 -0
- package/corpus/chunks/chat-message-assistant-byline.json +85 -0
- package/corpus/chunks/chat-message-user-byline.json +84 -0
- package/corpus/chunks/chat-page-shell.json +379 -0
- package/corpus/chunks/chat-streaming-surface.json +169 -0
- package/corpus/chunks/checkout-order-summary-card.json +140 -0
- package/corpus/chunks/code-snippet.json +107 -0
- package/corpus/chunks/col-form-stack.json +93 -0
- package/corpus/chunks/col-heading-body-action.json +79 -0
- package/corpus/chunks/col-stat-label.json +63 -0
- package/corpus/chunks/color-picker-swatches.json +153 -0
- package/corpus/chunks/command-palette.json +327 -0
- package/corpus/chunks/comments-composer.json +158 -0
- package/corpus/chunks/comments-mention-menu.json +237 -0
- package/corpus/chunks/comments-thread.json +344 -0
- package/corpus/chunks/commerce-pricing-tiers.json +401 -0
- package/corpus/chunks/comparison-table.json +246 -0
- package/corpus/chunks/contact-form-card.json +197 -0
- package/corpus/chunks/contact-form.json +157 -0
- package/corpus/chunks/contact-support-form.json +702 -0
- package/corpus/chunks/conversion-funnel-4-step-funnel.json +139 -0
- package/corpus/chunks/conversion-funnel-6step.json +151 -0
- package/corpus/chunks/conversion-funnel-wide-summary.json +192 -0
- package/corpus/chunks/conversion-funnel-with-segment-compare.json +202 -0
- package/corpus/chunks/cta-banner-centered.json +102 -0
- package/corpus/chunks/dashboard-acquisition-panel.json +212 -0
- package/corpus/chunks/dashboard-admin-page.json +104 -0
- package/corpus/chunks/dashboard-audience-kpis.json +165 -0
- package/corpus/chunks/dashboard-audience-panel.json +756 -0
- package/corpus/chunks/dashboard-behavior-panel.json +114 -0
- package/corpus/chunks/dashboard-chart-recent.json +566 -0
- package/corpus/chunks/dashboard-cohort-retention.json +83 -0
- package/corpus/chunks/dashboard-conversion-panel.json +234 -0
- package/corpus/chunks/dashboard-country-list.json +304 -0
- package/corpus/chunks/dashboard-filter-bar.json +118 -0
- package/corpus/chunks/dashboard-funnel.json +142 -0
- package/corpus/chunks/dashboard-notifications-panel.json +423 -0
- package/corpus/chunks/dashboard-overview-panel.json +1644 -0
- package/corpus/chunks/dashboard-page-header.json +166 -0
- package/corpus/chunks/dashboard-pages-table.json +86 -0
- package/corpus/chunks/dashboard-quick-actions.json +116 -0
- package/corpus/chunks/dashboard-reports-panel.json +166 -0
- package/corpus/chunks/dashboard-reports-table.json +138 -0
- package/corpus/chunks/dashboard-storage-card.json +117 -0
- package/corpus/chunks/dashboard-tabs.json +86 -0
- package/corpus/chunks/dashboard-team-actions-storage.json +605 -0
- package/corpus/chunks/dashboard-team-list.json +334 -0
- package/corpus/chunks/dashboard-traffic-channels.json +184 -0
- package/corpus/chunks/dashboard-transactions-table.json +145 -0
- package/corpus/chunks/data-export-history.json +192 -0
- package/corpus/chunks/data-export-request.json +197 -0
- package/corpus/chunks/data-import-wizard.json +391 -0
- package/corpus/chunks/date-range-picker.json +156 -0
- package/corpus/chunks/date-time-picker-form.json +222 -0
- package/corpus/chunks/departments-checkbox-form.json +390 -0
- package/corpus/chunks/destructive-confirm-modal.json +149 -0
- package/corpus/chunks/diff-inline.json +84 -0
- package/corpus/chunks/diff-side-by-side.json +131 -0
- package/corpus/chunks/diff-structured.json +216 -0
- package/corpus/chunks/digest-email-preview.json +374 -0
- package/corpus/chunks/divider-text-label.json +87 -0
- package/corpus/chunks/doc-editor-shell.json +356 -0
- package/corpus/chunks/drawer-2fa-key.json +273 -0
- package/corpus/chunks/drawer-2fa-sms.json +261 -0
- package/corpus/chunks/drawer-2fa-totp.json +385 -0
- package/corpus/chunks/drawer-cancel-sub.json +636 -0
- package/corpus/chunks/drawer-change-plan.json +561 -0
- package/corpus/chunks/drawer-custom-roles.json +696 -0
- package/corpus/chunks/drawer-data-start.json +171 -0
- package/corpus/chunks/drawer-delete-account.json +341 -0
- package/corpus/chunks/drawer-delete-workspace.json +362 -0
- package/corpus/chunks/drawer-discord.json +434 -0
- package/corpus/chunks/drawer-figma.json +401 -0
- package/corpus/chunks/drawer-first-dashboard.json +220 -0
- package/corpus/chunks/drawer-gcal.json +475 -0
- package/corpus/chunks/drawer-github.json +589 -0
- package/corpus/chunks/drawer-invite.json +397 -0
- package/corpus/chunks/drawer-record-detail.json +44 -0
- package/corpus/chunks/drawer-report.json +528 -0
- package/corpus/chunks/drawer-revoke-session.json +331 -0
- package/corpus/chunks/drawer-role.json +190 -0
- package/corpus/chunks/drawer-slack.json +429 -0
- package/corpus/chunks/drawer-smtp.json +476 -0
- package/corpus/chunks/drawer-source.json +294 -0
- package/corpus/chunks/drawer-transaction.json +493 -0
- package/corpus/chunks/drawer-with-create-form.json +43 -0
- package/corpus/chunks/editor-code-pane.json +204 -0
- package/corpus/chunks/editor-page-shell.json +149 -0
- package/corpus/chunks/editor-preview-pane.json +136 -0
- package/corpus/chunks/editor-statusbar-ready.json +99 -0
- package/corpus/chunks/editor-toolbar-import-export.json +195 -0
- package/corpus/chunks/email-inbox-list.json +678 -0
- package/corpus/chunks/empty-state-danger.json +58 -0
- package/corpus/chunks/empty-state-minimal.json +44 -0
- package/corpus/chunks/empty-state-warning.json +53 -0
- package/corpus/chunks/empty-state.json +65 -0
- package/corpus/chunks/error-404-actions.json +54 -0
- package/corpus/chunks/error-404.json +204 -0
- package/corpus/chunks/error-500-actions.json +61 -0
- package/corpus/chunks/error-500.json +220 -0
- package/corpus/chunks/error-maintenance-actions.json +53 -0
- package/corpus/chunks/error-maintenance.json +203 -0
- package/corpus/chunks/error-page-shell.json +132 -0
- package/corpus/chunks/export-flow-async.json +210 -0
- package/corpus/chunks/export-flow-delivery.json +163 -0
- package/corpus/chunks/export-flow-sync.json +162 -0
- package/corpus/chunks/extended-profile-form.json +512 -0
- package/corpus/chunks/faq-accordion.json +123 -0
- package/corpus/chunks/feature-grid-icons.json +314 -0
- package/corpus/chunks/feature-grid-three-cards.json +187 -0
- package/corpus/chunks/feature-toggle-switch-grid.json +213 -0
- package/corpus/chunks/file-upload-dnd.json +166 -0
- package/corpus/chunks/file-upload-field.json +97 -0
- package/corpus/chunks/file-upload-form.json +251 -0
- package/corpus/chunks/filter-bar-active-filters.json +176 -0
- package/corpus/chunks/filter-bar-filter-bar-with-table.json +113 -0
- package/corpus/chunks/filter-bar-saved-views.json +117 -0
- package/corpus/chunks/filter-popover-form.json +137 -0
- package/corpus/chunks/footer-multi-column.json +270 -0
- package/corpus/chunks/footer-primary-only.json +41 -0
- package/corpus/chunks/form-checkbox-group.json +65 -0
- package/corpus/chunks/form-drawer-edit-form.json +178 -0
- package/corpus/chunks/form-drawer-simple-form.json +151 -0
- package/corpus/chunks/form-drawer-tall-form.json +325 -0
- package/corpus/chunks/form-field-email-hint.json +53 -0
- package/corpus/chunks/form-field-range.json +54 -0
- package/corpus/chunks/form-field-required.json +52 -0
- package/corpus/chunks/form-field-select.json +66 -0
- package/corpus/chunks/form-field-textarea.json +51 -0
- package/corpus/chunks/form-field-with-error.json +151 -0
- package/corpus/chunks/form-fields-two-column.json +69 -0
- package/corpus/chunks/form-page-shell.json +146 -0
- package/corpus/chunks/form-switch-toggle.json +41 -0
- package/corpus/chunks/form-system-live-demo.json +123 -0
- package/corpus/chunks/forms-address-autocomplete.json +277 -0
- package/corpus/chunks/forms-address-fields.json +221 -0
- package/corpus/chunks/forms-conditional-reveal.json +195 -0
- package/corpus/chunks/gallery-page-shell.json +444 -0
- package/corpus/chunks/grid-2col-entry-cards.json +140 -0
- package/corpus/chunks/grid-kpi-4col.json +164 -0
- package/corpus/chunks/grid-responsive-kpi.json +165 -0
- package/corpus/chunks/hero-cta-simple.json +107 -0
- package/corpus/chunks/hero-cta-split.json +183 -0
- package/corpus/chunks/hero-section-split.json +111 -0
- package/corpus/chunks/icon-text-row.json +60 -0
- package/corpus/chunks/image-caption-tile.json +99 -0
- package/corpus/chunks/image-carousel.json +156 -0
- package/corpus/chunks/image-thumbnail-grid.json +77 -0
- package/corpus/chunks/image-upload-preview.json +118 -0
- package/corpus/chunks/import-mapping-flow.json +972 -0
- package/corpus/chunks/inline-dialog-rename.json +128 -0
- package/corpus/chunks/inline-dialog-schedule.json +154 -0
- package/corpus/chunks/inline-dialog-status.json +179 -0
- package/corpus/chunks/integrations-api-keys-card-list.json +475 -0
- package/corpus/chunks/integrations-connect-form.json +550 -0
- package/corpus/chunks/integrations-grid.json +141 -0
- package/corpus/chunks/integrations-webhooks-empty-state.json +66 -0
- package/corpus/chunks/inventory-list-stock.json +137 -0
- package/corpus/chunks/invite-members.json +153 -0
- package/corpus/chunks/invoice-line-items.json +493 -0
- package/corpus/chunks/kanban-board-3col.json +713 -0
- package/corpus/chunks/kanban-page-shell.json +671 -0
- package/corpus/chunks/key-value-detail-list.json +242 -0
- package/corpus/chunks/keyboard-shortcut-display.json +250 -0
- package/corpus/chunks/labeled-textarea.json +45 -0
- package/corpus/chunks/leaderboard-table.json +140 -0
- package/corpus/chunks/library-browser-search-filter.json +109 -0
- package/corpus/chunks/linked-record-row.json +61 -0
- package/corpus/chunks/loading-skeleton-placeholder.json +387 -0
- package/corpus/chunks/login-form-card.json +207 -0
- package/corpus/chunks/logo-cloud-trusted-by.json +235 -0
- package/corpus/chunks/map-with-location-list.json +293 -0
- package/corpus/chunks/marketing-hero-cta.json +102 -0
- package/corpus/chunks/marketing-page-shell.json +352 -0
- package/corpus/chunks/masonry-gallery.json +154 -0
- package/corpus/chunks/member-edit-drawer.json +236 -0
- package/corpus/chunks/members-active-table-search-filter.json +184 -0
- package/corpus/chunks/members-pending-invites-cards.json +251 -0
- package/corpus/chunks/members-roles-permissions-list.json +146 -0
- package/corpus/chunks/menu-context-actions.json +113 -0
- package/corpus/chunks/metadata-description-list.json +178 -0
- package/corpus/chunks/modal-create-project-form.json +133 -0
- package/corpus/chunks/modal-preferences-tabs.json +147 -0
- package/corpus/chunks/multi-field-form-validation.json +394 -0
- package/corpus/chunks/nav-menu-icons.json +74 -0
- package/corpus/chunks/newsletter-subscription.json +190 -0
- package/corpus/chunks/notification-badges-feed.json +411 -0
- package/corpus/chunks/notification-preferences-panel.json +238 -0
- package/corpus/chunks/onb-completion.json +139 -0
- package/corpus/chunks/onb-extension-install.json +172 -0
- package/corpus/chunks/onb-hero-welcome.json +156 -0
- package/corpus/chunks/onb-import-picker.json +86 -0
- package/corpus/chunks/onb-mobile-handoff.json +121 -0
- package/corpus/chunks/onb-notification-prefs.json +83 -0
- package/corpus/chunks/onb-persona-picker.json +82 -0
- package/corpus/chunks/onb-provider-tiles.json +137 -0
- package/corpus/chunks/onb-settings-review.json +257 -0
- package/corpus/chunks/onb-step-footer.json +121 -0
- package/corpus/chunks/onb-step-header.json +121 -0
- package/corpus/chunks/onb-step-progress.json +140 -0
- package/corpus/chunks/onb-step-shell.json +380 -0
- package/corpus/chunks/onb-story-pane.json +121 -0
- package/corpus/chunks/onb-tutorial-steps.json +193 -0
- package/corpus/chunks/order-confirmation-success-card.json +177 -0
- package/corpus/chunks/order-tracking-timeline.json +131 -0
- package/corpus/chunks/pagination-controls.json +82 -0
- package/corpus/chunks/pane-settings-sidebar.json +204 -0
- package/corpus/chunks/patient-visit-shell.json +191 -0
- package/corpus/chunks/payment-checkout-form.json +341 -0
- package/corpus/chunks/payment-method-form.json +328 -0
- package/corpus/chunks/period-comparison.json +236 -0
- package/corpus/chunks/permission-matrix-table.json +438 -0
- package/corpus/chunks/permissions-matrix-grid.json +111 -0
- package/corpus/chunks/permissions-matrix-summary.json +157 -0
- package/corpus/chunks/permissions-role-picker-radio.json +107 -0
- package/corpus/chunks/permissions-role-picker-select.json +101 -0
- package/corpus/chunks/permissions-share-link.json +256 -0
- package/corpus/chunks/permissions-share-people.json +297 -0
- package/corpus/chunks/permissions-sharing-scopes.json +109 -0
- package/corpus/chunks/plan-selection-form.json +529 -0
- package/corpus/chunks/playground-a2ui.json +181 -0
- package/corpus/chunks/playground-agent-admin.json +117 -0
- package/corpus/chunks/playground-agent-chat.json +126 -0
- package/corpus/chunks/playground-app-shell.json +488 -0
- package/corpus/chunks/playground-chat.json +265 -0
- package/corpus/chunks/playground-construct-canvas.json +118 -0
- package/corpus/chunks/playground-css-channel.json +487 -0
- package/corpus/chunks/playground-gen-ui.json +224 -0
- package/corpus/chunks/playground-render-preview.json +369 -0
- package/corpus/chunks/playground-streams-bridge.json +437 -0
- package/corpus/chunks/playground-table-toolbar.json +38 -0
- package/corpus/chunks/popover-with-content.json +118 -0
- package/corpus/chunks/pricing-tiers.json +561 -0
- package/corpus/chunks/product-tour.json +158 -0
- package/corpus/chunks/profile-public.json +297 -0
- package/corpus/chunks/progress-tracker-milestones.json +294 -0
- package/corpus/chunks/radio-button-group.json +83 -0
- package/corpus/chunks/rating-stars-review-summary.json +259 -0
- package/corpus/chunks/reactions-bar.json +75 -0
- package/corpus/chunks/reactions-picker.json +245 -0
- package/corpus/chunks/real-time-metrics-dashboard.json +344 -0
- package/corpus/chunks/record-detail-drawer-simple-detail.json +296 -0
- package/corpus/chunks/record-detail-drawer-tabbed-detail.json +443 -0
- package/corpus/chunks/referral-share-link.json +128 -0
- package/corpus/chunks/referral-status.json +243 -0
- package/corpus/chunks/reg-address-form.json +825 -0
- package/corpus/chunks/reg-billing-card.json +210 -0
- package/corpus/chunks/reg-brand-scrape.json +599 -0
- package/corpus/chunks/reg-departments-toggle.json +259 -0
- package/corpus/chunks/reg-extended-profile.json +356 -0
- package/corpus/chunks/reg-final-done.json +457 -0
- package/corpus/chunks/reg-helpdesk-grid.json +571 -0
- package/corpus/chunks/reg-import-picker.json +112 -0
- package/corpus/chunks/reg-integrations-grid.json +418 -0
- package/corpus/chunks/reg-invite-form.json +245 -0
- package/corpus/chunks/reg-legal-entity.json +260 -0
- package/corpus/chunks/reg-org-chart-review.json +891 -0
- package/corpus/chunks/reg-profile-identity.json +188 -0
- package/corpus/chunks/reg-step-footer.json +201 -0
- package/corpus/chunks/reg-step-header.json +201 -0
- package/corpus/chunks/reg-step-progress.json +236 -0
- package/corpus/chunks/reg-step-shell.json +605 -0
- package/corpus/chunks/reg-story-pane.json +201 -0
- package/corpus/chunks/reg-success-summary.json +257 -0
- package/corpus/chunks/reg-team-size.json +128 -0
- package/corpus/chunks/reg-usecase-picker.json +104 -0
- package/corpus/chunks/reg-workspace-name.json +159 -0
- package/corpus/chunks/responsive-grid-pattern.json +71 -0
- package/corpus/chunks/responsive-kpi-grid.json +166 -0
- package/corpus/chunks/responsive-row-pattern.json +71 -0
- package/corpus/chunks/responsive-shell-sidebar.json +308 -0
- package/corpus/chunks/responsive-wrap-at-pattern.json +124 -0
- package/corpus/chunks/retention-cohort-default-retention.json +80 -0
- package/corpus/chunks/retention-cohort-stat-pair.json +163 -0
- package/corpus/chunks/retention-cohort-with-legend.json +135 -0
- package/corpus/chunks/revenue-heatmap.json +82 -0
- package/corpus/chunks/role-management.json +272 -0
- package/corpus/chunks/row-action-cluster.json +54 -0
- package/corpus/chunks/row-avatar-name-role.json +71 -0
- package/corpus/chunks/row-icon-label.json +52 -0
- package/corpus/chunks/row-spread-label-value.json +54 -0
- package/corpus/chunks/row-wrap-tags.json +72 -0
- package/corpus/chunks/schedule-meeting-form-card.json +229 -0
- package/corpus/chunks/search-recents-menu.json +195 -0
- package/corpus/chunks/search-results-grouped.json +357 -0
- package/corpus/chunks/search-results-list.json +202 -0
- package/corpus/chunks/search-saved-views.json +356 -0
- package/corpus/chunks/search-with-filters.json +311 -0
- package/corpus/chunks/searchable-picker-modal.json +164 -0
- package/corpus/chunks/section-with-stack.json +48 -0
- package/corpus/chunks/security-active-sessions-devices.json +287 -0
- package/corpus/chunks/security-change-password-form.json +102 -0
- package/corpus/chunks/security-delete-account-danger.json +79 -0
- package/corpus/chunks/segmented-control-billing-tabs.json +164 -0
- package/corpus/chunks/select-multiple-preselected.json +70 -0
- package/corpus/chunks/settings-2fa-setup.json +307 -0
- package/corpus/chunks/settings-admin-page.json +1205 -0
- package/corpus/chunks/settings-appearance-primitives.json +145 -0
- package/corpus/chunks/settings-appearance-theme-panel.json +55 -0
- package/corpus/chunks/settings-appearance.json +81 -0
- package/corpus/chunks/settings-danger-zone-delete-workspace.json +93 -0
- package/corpus/chunks/settings-general-form.json +69 -0
- package/corpus/chunks/settings-integrations.json +298 -0
- package/corpus/chunks/settings-members-invite.json +112 -0
- package/corpus/chunks/settings-notification-activity-checkboxes.json +108 -0
- package/corpus/chunks/settings-notification-channels-switches.json +101 -0
- package/corpus/chunks/settings-page-shell.json +190 -0
- package/corpus/chunks/settings-privacy.json +83 -0
- package/corpus/chunks/settings-profile-security.json +122 -0
- package/corpus/chunks/settings-toggle-switches.json +66 -0
- package/corpus/chunks/sidebar-nav.json +120 -0
- package/corpus/chunks/sidebar-navigation-panel.json +165 -0
- package/corpus/chunks/signup-form-card.json +218 -0
- package/corpus/chunks/signup-team-size-form.json +259 -0
- package/corpus/chunks/single-select-card-form.json +231 -0
- package/corpus/chunks/slider-range-controls.json +119 -0
- package/corpus/chunks/social-media-post-card.json +159 -0
- package/corpus/chunks/sortable-list.json +307 -0
- package/corpus/chunks/sortable-search-paginate-table.json +162 -0
- package/corpus/chunks/split-pane-editor.json +146 -0
- package/corpus/chunks/stack-avatar-badge-overlay.json +53 -0
- package/corpus/chunks/stack-image-shimmer.json +51 -0
- package/corpus/chunks/stat-cards-kpi-dashboard.json +178 -0
- package/corpus/chunks/stats-band-big-numbers.json +175 -0
- package/corpus/chunks/status-dashboard.json +282 -0
- package/corpus/chunks/stepper-form-wizard.json +165 -0
- package/corpus/chunks/subscription-status-renewal-card.json +285 -0
- package/corpus/chunks/survey-rating-form.json +165 -0
- package/corpus/chunks/swiper-product-carousel.json +349 -0
- package/corpus/chunks/swiper-testimonial-carousel.json +279 -0
- package/corpus/chunks/table-empty-state.json +116 -0
- package/corpus/chunks/table-inline-edit-row.json +269 -0
- package/corpus/chunks/table-spreadsheet-cells.json +334 -0
- package/corpus/chunks/table-toolbar-no-search.json +42 -0
- package/corpus/chunks/table-toolbar-with-table.json +208 -0
- package/corpus/chunks/table-with-toolbar-card.json +80 -0
- package/corpus/chunks/tabs-with-panels.json +187 -0
- package/corpus/chunks/tag-chips-filter.json +100 -0
- package/corpus/chunks/team-invite-form.json +380 -0
- package/corpus/chunks/team-members-list.json +341 -0
- package/corpus/chunks/testimonial-grid.json +269 -0
- package/corpus/chunks/testimonial-pull-quote.json +137 -0
- package/corpus/chunks/testimonials-avatar-cards.json +286 -0
- package/corpus/chunks/timeline-events.json +89 -0
- package/corpus/chunks/timezone-selector-basic.json +99 -0
- package/corpus/chunks/timezone-selector-preview.json +104 -0
- package/corpus/chunks/toolbar-icons.json +216 -0
- package/corpus/chunks/toolbar-rich-text-editor.json +230 -0
- package/corpus/chunks/toolbar-tooltips.json +191 -0
- package/corpus/chunks/tooltip-hover-button.json +106 -0
- package/corpus/chunks/tree-file-explorer.json +136 -0
- package/corpus/chunks/tree-table-basic.json +171 -0
- package/corpus/chunks/trial-banner.json +158 -0
- package/corpus/chunks/url-import-form.json +728 -0
- package/corpus/chunks/usage-quota-meter-card.json +217 -0
- package/corpus/chunks/user-identity-row.json +81 -0
- package/corpus/chunks/user-onboarding-checklist.json +301 -0
- package/corpus/chunks/user-profile-card.json +192 -0
- package/corpus/chunks/users-table-badge.json +135 -0
- package/corpus/chunks/verification-document-upload.json +179 -0
- package/corpus/chunks/verification-status.json +97 -0
- package/corpus/chunks/verification-stepper.json +111 -0
- package/corpus/chunks/video-player-controls.json +120 -0
- package/corpus/chunks/webhook-config.json +209 -0
- package/corpus/chunks/webhooks-list.json +204 -0
- package/corpus/chunks/wizard-drawer-three-step-wizard.json +443 -0
- package/corpus/manifest.d.ts +4 -0
- package/corpus/manifest.json +6 -0
- package/corpus/scripts/chunk-library.d.ts +4 -0
- package/corpus/scripts/chunk-library.js +335 -0
- package/node-shims.d.ts +48 -0
- package/package.json +215 -0
- package/retrieval/CHANGELOG.md +1073 -0
- package/retrieval/README.md +71 -0
- package/retrieval/anti-patterns.js +189 -0
- package/retrieval/authoring/index.d.ts +4 -0
- package/retrieval/authoring/index.js +9 -0
- package/retrieval/authoring/web-research.js +220 -0
- package/retrieval/catalog.js +250 -0
- package/retrieval/component-catalog.js +168 -0
- package/retrieval/component-entry.js +80 -0
- package/retrieval/context-assembler.js +174 -0
- package/retrieval/domain-router.js +417 -0
- package/retrieval/embedding/chunk-embedding-retriever.js +117 -0
- package/retrieval/embedding/embedding-provider.js +72 -0
- package/retrieval/embedding/index.d.ts +4 -0
- package/retrieval/embedding/index.js +2 -0
- package/retrieval/feedback/dialog-recorder.js +107 -0
- package/retrieval/feedback/feedback-analyzer.js +180 -0
- package/retrieval/feedback/feedback-store.js +194 -0
- package/retrieval/feedback/feedback.js +117 -0
- package/retrieval/feedback/gap-registry.js +80 -0
- package/retrieval/feedback/human-signal.js +113 -0
- package/retrieval/feedback/index.d.ts +4 -0
- package/retrieval/feedback/index.js +24 -0
- package/retrieval/feedback/submit-feedback.js +45 -0
- package/retrieval/index.d.ts +4 -0
- package/retrieval/index.js +53 -0
- package/retrieval/intent/clarity.js +139 -0
- package/retrieval/intent/decomposer.js +124 -0
- package/retrieval/intent/index.d.ts +4 -0
- package/retrieval/intent/index.js +18 -0
- package/retrieval/intent/intent-alignment.js +172 -0
- package/retrieval/intent/intent-categorizer.js +69 -0
- package/retrieval/intent/intent-gate.js +96 -0
- package/retrieval/intent/prompt-analyzer.js +162 -0
- package/retrieval/wiring-catalog.js +168 -0
- package/validate/catalog-validator.d.ts +4 -0
- package/validate/catalog-validator.js +327 -0
- package/validate/semantic/cache.js +54 -0
- package/validate/semantic/classify-intent.js +128 -0
- package/validate/semantic/index.js +163 -0
- package/validate/semantic/intent-specs.js +162 -0
- package/validate/semantic/judge.js +180 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PipelineEngine — State machine for generative pipeline executions.
|
|
3
|
+
*
|
|
4
|
+
* Manages execution lifecycle: start → stage submissions → completion/abort.
|
|
5
|
+
* Enforces stage ordering (interpret → analyze → plan → generate → validate → render)
|
|
6
|
+
* with doNotRedo support for skipping stages on iteration.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { STAGES, stageIndex, createStepReport, createEvent } from './types.js';
|
|
10
|
+
|
|
11
|
+
let nextId = 1;
|
|
12
|
+
|
|
13
|
+
/** Generate a unique execution ID */
|
|
14
|
+
function uid() {
|
|
15
|
+
return `exec_${Date.now().toString(36)}_${(nextId++).toString(36)}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {object} PipelineExecution
|
|
20
|
+
* @property {string} id — Unique execution ID
|
|
21
|
+
* @property {string} intent — Original user intent
|
|
22
|
+
* @property {'instant'|'thinking'|'pro'|'god'} mode — Generation mode
|
|
23
|
+
* @property {'active'|'completed'|'failed'|'aborted'} state — Current state
|
|
24
|
+
* @property {Map<string, object>} stages — Stage outputs keyed by stage name
|
|
25
|
+
* @property {object[]} reports — StepReports in order
|
|
26
|
+
* @property {object[]} events — PipelineEvent log
|
|
27
|
+
* @property {string[]} doNotRedo — Stages to skip on iteration
|
|
28
|
+
* @property {number} created — Timestamp
|
|
29
|
+
* @property {number} updated — Timestamp
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
export class PipelineEngine {
|
|
33
|
+
#executions = new Map();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Start a new pipeline execution.
|
|
37
|
+
*
|
|
38
|
+
* @param {object} opts
|
|
39
|
+
* @param {string} opts.intent — User intent text
|
|
40
|
+
* @param {'instant'|'thinking'|'pro'|'god'} [opts.mode='instant'] — Generation mode
|
|
41
|
+
* @returns {string} — executionId
|
|
42
|
+
*/
|
|
43
|
+
start({ intent, mode = 'instant' }) {
|
|
44
|
+
const id = uid();
|
|
45
|
+
const execution = {
|
|
46
|
+
id,
|
|
47
|
+
intent,
|
|
48
|
+
mode,
|
|
49
|
+
state: 'active',
|
|
50
|
+
stages: new Map(),
|
|
51
|
+
reports: [],
|
|
52
|
+
events: [],
|
|
53
|
+
doNotRedo: [],
|
|
54
|
+
created: Date.now(),
|
|
55
|
+
updated: Date.now(),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
execution.events.push(createEvent({
|
|
59
|
+
executionId: id,
|
|
60
|
+
type: 'pipeline:start',
|
|
61
|
+
message: `Pipeline started for intent: "${intent}" (mode: ${mode})`,
|
|
62
|
+
data: { intent, mode },
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
this.#executions.set(id, execution);
|
|
66
|
+
return id;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Submit a stage output to an active execution.
|
|
71
|
+
*
|
|
72
|
+
* Validates stage ordering: stages must proceed in STAGES order.
|
|
73
|
+
* Stages listed in doNotRedo are skipped automatically.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} executionId
|
|
76
|
+
* @param {string} stage — Stage name (from STAGES)
|
|
77
|
+
* @param {object} output — Stage output data
|
|
78
|
+
* @param {object} [opts] — Options
|
|
79
|
+
* @param {boolean} [opts.force=false] — Skip ordering check
|
|
80
|
+
* @param {string[]} [opts.doNotRedo] — Stages to skip on future iterations
|
|
81
|
+
* @returns {object} — StepReport
|
|
82
|
+
*/
|
|
83
|
+
submitStage(executionId, stage, output, { force = false, doNotRedo = [] } = {}) {
|
|
84
|
+
const execution = this.#executions.get(executionId);
|
|
85
|
+
if (!execution) throw new Error(`Unknown execution: ${executionId}`);
|
|
86
|
+
if (execution.state !== 'active') throw new Error(`Execution ${executionId} is ${execution.state}, not active`);
|
|
87
|
+
|
|
88
|
+
const idx = stageIndex(stage);
|
|
89
|
+
if (idx === -1) throw new Error(`Unknown stage: ${stage}`);
|
|
90
|
+
|
|
91
|
+
// Check ordering: the submitted stage must come after the last completed stage
|
|
92
|
+
if (!force && execution.stages.size > 0) {
|
|
93
|
+
const completedStages = [...execution.stages.keys()];
|
|
94
|
+
const lastCompleted = completedStages[completedStages.length - 1];
|
|
95
|
+
const lastIdx = stageIndex(lastCompleted);
|
|
96
|
+
|
|
97
|
+
// Allow re-submission of same stage (iteration) or next stage
|
|
98
|
+
if (idx < lastIdx) {
|
|
99
|
+
throw new Error(`Stage "${stage}" (${idx}) cannot precede already completed "${lastCompleted}" (${lastIdx}). Use force to override.`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Check for skipped stages (unless they're in doNotRedo)
|
|
103
|
+
const allSkippable = [...execution.doNotRedo, ...doNotRedo];
|
|
104
|
+
for (let i = lastIdx + 1; i < idx; i++) {
|
|
105
|
+
const skippedName = STAGES[i];
|
|
106
|
+
if (!allSkippable.includes(skippedName) && !execution.stages.has(skippedName)) {
|
|
107
|
+
throw new Error(`Stage "${skippedName}" must be completed before "${stage}". Add to doNotRedo to skip.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Record doNotRedo additions
|
|
113
|
+
if (doNotRedo.length > 0) {
|
|
114
|
+
for (const s of doNotRedo) {
|
|
115
|
+
if (!execution.doNotRedo.includes(s)) execution.doNotRedo.push(s);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Store stage output
|
|
120
|
+
execution.stages.set(stage, output);
|
|
121
|
+
execution.updated = Date.now();
|
|
122
|
+
|
|
123
|
+
// Create step report
|
|
124
|
+
const report = createStepReport({
|
|
125
|
+
stage,
|
|
126
|
+
status: 'passed',
|
|
127
|
+
goal: `Complete ${stage} stage`,
|
|
128
|
+
summary: `Stage "${stage}" submitted successfully`,
|
|
129
|
+
confidence: output.confidence ?? 0.8,
|
|
130
|
+
checks: output.checks ?? [],
|
|
131
|
+
assumptions: output.assumptions ?? [],
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
execution.reports.push(report);
|
|
135
|
+
|
|
136
|
+
// Log event
|
|
137
|
+
execution.events.push(createEvent({
|
|
138
|
+
executionId,
|
|
139
|
+
type: 'stage:complete',
|
|
140
|
+
stage,
|
|
141
|
+
message: `Stage "${stage}" completed`,
|
|
142
|
+
data: { output: summarizeOutput(output) },
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
// Auto-complete if render stage is done
|
|
146
|
+
if (stage === 'render') {
|
|
147
|
+
execution.state = 'completed';
|
|
148
|
+
execution.events.push(createEvent({
|
|
149
|
+
executionId,
|
|
150
|
+
type: 'pipeline:complete',
|
|
151
|
+
message: 'Pipeline completed successfully',
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return report;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get the current state of an execution.
|
|
160
|
+
*
|
|
161
|
+
* @param {string} executionId
|
|
162
|
+
* @returns {object|null} — Execution state snapshot (or null if not found)
|
|
163
|
+
*/
|
|
164
|
+
getState(executionId) {
|
|
165
|
+
const execution = this.#executions.get(executionId);
|
|
166
|
+
if (!execution) return null;
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
id: execution.id,
|
|
170
|
+
intent: execution.intent,
|
|
171
|
+
mode: execution.mode,
|
|
172
|
+
state: execution.state,
|
|
173
|
+
completedStages: [...execution.stages.keys()],
|
|
174
|
+
currentStage: this.#currentStage(execution),
|
|
175
|
+
reports: [...execution.reports],
|
|
176
|
+
eventCount: execution.events.length,
|
|
177
|
+
doNotRedo: [...execution.doNotRedo],
|
|
178
|
+
created: execution.created,
|
|
179
|
+
updated: execution.updated,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Get the full event log for an execution.
|
|
185
|
+
*
|
|
186
|
+
* @param {string} executionId
|
|
187
|
+
* @returns {object[]}
|
|
188
|
+
*/
|
|
189
|
+
getEvents(executionId) {
|
|
190
|
+
const execution = this.#executions.get(executionId);
|
|
191
|
+
return execution ? [...execution.events] : [];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Get the output from a specific stage.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} executionId
|
|
198
|
+
* @param {string} stage
|
|
199
|
+
* @returns {object|null}
|
|
200
|
+
*/
|
|
201
|
+
getStageOutput(executionId, stage) {
|
|
202
|
+
const execution = this.#executions.get(executionId);
|
|
203
|
+
if (!execution) return null;
|
|
204
|
+
return execution.stages.get(stage) ?? null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Abort an active execution.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} executionId
|
|
211
|
+
* @param {string} [reason] — Abort reason
|
|
212
|
+
*/
|
|
213
|
+
abort(executionId, reason = 'Aborted by caller') {
|
|
214
|
+
const execution = this.#executions.get(executionId);
|
|
215
|
+
if (!execution) throw new Error(`Unknown execution: ${executionId}`);
|
|
216
|
+
if (execution.state !== 'active') return; // already terminal
|
|
217
|
+
|
|
218
|
+
execution.state = 'aborted';
|
|
219
|
+
execution.updated = Date.now();
|
|
220
|
+
|
|
221
|
+
execution.events.push(createEvent({
|
|
222
|
+
executionId,
|
|
223
|
+
type: 'pipeline:abort',
|
|
224
|
+
message: reason,
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Mark an execution as failed.
|
|
230
|
+
*
|
|
231
|
+
* @param {string} executionId
|
|
232
|
+
* @param {string} stage — Stage where failure occurred
|
|
233
|
+
* @param {string} error — Error description
|
|
234
|
+
*/
|
|
235
|
+
fail(executionId, stage, error) {
|
|
236
|
+
const execution = this.#executions.get(executionId);
|
|
237
|
+
if (!execution) throw new Error(`Unknown execution: ${executionId}`);
|
|
238
|
+
if (execution.state !== 'active') return;
|
|
239
|
+
|
|
240
|
+
execution.state = 'failed';
|
|
241
|
+
execution.updated = Date.now();
|
|
242
|
+
|
|
243
|
+
const report = createStepReport({
|
|
244
|
+
stage,
|
|
245
|
+
status: 'failed',
|
|
246
|
+
goal: `Complete ${stage} stage`,
|
|
247
|
+
summary: error,
|
|
248
|
+
confidence: 0,
|
|
249
|
+
});
|
|
250
|
+
execution.reports.push(report);
|
|
251
|
+
|
|
252
|
+
execution.events.push(createEvent({
|
|
253
|
+
executionId,
|
|
254
|
+
type: 'stage:fail',
|
|
255
|
+
stage,
|
|
256
|
+
message: error,
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
execution.events.push(createEvent({
|
|
260
|
+
executionId,
|
|
261
|
+
type: 'pipeline:fail',
|
|
262
|
+
message: `Pipeline failed at stage "${stage}": ${error}`,
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Determine the next expected stage for an execution.
|
|
268
|
+
* @param {object} execution
|
|
269
|
+
* @returns {string|null}
|
|
270
|
+
*/
|
|
271
|
+
#currentStage(execution) {
|
|
272
|
+
if (execution.state !== 'active') return null;
|
|
273
|
+
const completed = new Set(execution.stages.keys());
|
|
274
|
+
for (const stage of STAGES) {
|
|
275
|
+
if (!completed.has(stage) && !execution.doNotRedo.includes(stage)) {
|
|
276
|
+
return stage;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Summarize output for event log (avoid storing huge payloads in events) */
|
|
284
|
+
function summarizeOutput(output) {
|
|
285
|
+
if (!output) return null;
|
|
286
|
+
const keys = Object.keys(output);
|
|
287
|
+
if (keys.length <= 5) return output;
|
|
288
|
+
return { _keys: keys, _size: JSON.stringify(output).length };
|
|
289
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Type Definitions — Stage names, StepReport, Handoff, PipelineEvent.
|
|
3
|
+
*
|
|
4
|
+
* Pure data constructors for the pipeline state machine.
|
|
5
|
+
* No dependencies — usable from browser and Node.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Ordered pipeline stages */
|
|
9
|
+
export const STAGES = ['interpret', 'analyze', 'plan', 'generate', 'validate', 'render'];
|
|
10
|
+
|
|
11
|
+
/** Stage index lookup for ordering enforcement */
|
|
12
|
+
const STAGE_INDEX = Object.fromEntries(STAGES.map((s, i) => [s, i]));
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the numeric index of a stage (for ordering checks).
|
|
16
|
+
* @param {string} stage
|
|
17
|
+
* @returns {number} — -1 if unknown
|
|
18
|
+
*/
|
|
19
|
+
export function stageIndex(stage) {
|
|
20
|
+
return STAGE_INDEX[stage] ?? -1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a StepReport — per-stage quality gate.
|
|
25
|
+
*
|
|
26
|
+
* @param {object} opts
|
|
27
|
+
* @param {string} opts.stage — Stage name (from STAGES)
|
|
28
|
+
* @param {'passed'|'failed'|'skipped'} opts.status — Gate result
|
|
29
|
+
* @param {string} opts.goal — What this stage aimed to accomplish
|
|
30
|
+
* @param {string} opts.summary — What actually happened
|
|
31
|
+
* @param {number} opts.confidence — 0-1 confidence score
|
|
32
|
+
* @param {object[]} [opts.checks] — Individual check results
|
|
33
|
+
* @param {string[]} [opts.assumptions] — Assumptions made during this stage
|
|
34
|
+
* @returns {object}
|
|
35
|
+
*/
|
|
36
|
+
export function createStepReport({ stage, status, goal, summary, confidence, checks = [], assumptions = [] }) {
|
|
37
|
+
return {
|
|
38
|
+
stage,
|
|
39
|
+
status,
|
|
40
|
+
goal,
|
|
41
|
+
summary,
|
|
42
|
+
confidence: Math.max(0, Math.min(1, confidence)),
|
|
43
|
+
checks,
|
|
44
|
+
assumptions,
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create a Handoff — stage boundary contract.
|
|
51
|
+
*
|
|
52
|
+
* @param {object} opts
|
|
53
|
+
* @param {string} opts.from — Source stage
|
|
54
|
+
* @param {string} opts.to — Target stage
|
|
55
|
+
* @param {object} opts.completed — Data produced by the source stage
|
|
56
|
+
* @param {string[]} [opts.unresolved] — Open questions or gaps
|
|
57
|
+
* @param {string[]} [opts.doNotRedo] — Stages that should be skipped on iteration
|
|
58
|
+
* @returns {object}
|
|
59
|
+
*/
|
|
60
|
+
export function createHandoff({ from, to, completed, unresolved = [], doNotRedo = [] }) {
|
|
61
|
+
return {
|
|
62
|
+
from,
|
|
63
|
+
to,
|
|
64
|
+
completed,
|
|
65
|
+
unresolved,
|
|
66
|
+
doNotRedo,
|
|
67
|
+
timestamp: Date.now(),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create a PipelineEvent — event log entry.
|
|
73
|
+
*
|
|
74
|
+
* @param {object} opts
|
|
75
|
+
* @param {string} opts.executionId
|
|
76
|
+
* @param {'stage:start'|'stage:complete'|'stage:fail'|'stage:skip'|'pipeline:start'|'pipeline:complete'|'pipeline:fail'|'pipeline:abort'} opts.type
|
|
77
|
+
* @param {string} [opts.stage] — Stage name (if stage-level event)
|
|
78
|
+
* @param {string} opts.message — Human-readable description
|
|
79
|
+
* @param {*} [opts.data] — Arbitrary event payload
|
|
80
|
+
* @returns {object}
|
|
81
|
+
*/
|
|
82
|
+
export function createEvent({ executionId, type, stage = null, message, data = null }) {
|
|
83
|
+
return {
|
|
84
|
+
executionId,
|
|
85
|
+
type,
|
|
86
|
+
stage,
|
|
87
|
+
message,
|
|
88
|
+
data,
|
|
89
|
+
timestamp: Date.now(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* R-O11/R-O12's two pure plan primitives, resident in this package (gh#1186).
|
|
3
|
+
*
|
|
4
|
+
* WHY A COPY LIVES HERE. `plan-turn.js` used to import these from
|
|
5
|
+
* `@genui/producer`, which is a VENDORED tree (`packages/genui/*`, synced by
|
|
6
|
+
* `scripts/build/sync-genui.mjs`, guarded by `check:genui-vendor`) and is
|
|
7
|
+
* marked `"private": true`. A published `@adia-ai/gen-ui` that depends
|
|
8
|
+
* on it can never be installed — `npm install` 404s on `@genui/producer`
|
|
9
|
+
* before any code runs, which is what made `@adia-ai/a2ui-mcp@0.8.35`
|
|
10
|
+
* uninstallable, not merely unbootable.
|
|
11
|
+
*
|
|
12
|
+
* The two functions are pure, dependency-free, and defined by the spec
|
|
13
|
+
* (docs/ORCHESTRATION.md §Plan envelope) rather than by the vendored tree, so
|
|
14
|
+
* carrying them here costs nothing at runtime. The vendored tree stays the
|
|
15
|
+
* upstream reference: `plan-primitives.test.js` runs both implementations
|
|
16
|
+
* against the same fixtures and fails if they diverge, so the copy cannot
|
|
17
|
+
* drift silently. That test is monorepo-only — it never ships in the tarball.
|
|
18
|
+
*
|
|
19
|
+
* Never hand-edit `packages/genui/producer/dist/plan.js` to match this file;
|
|
20
|
+
* the sync direction is upstream → vendored tree → here.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* R-O11's one shared predicate: an executor (gen-ui-kit-side) and any
|
|
25
|
+
* producer-side self-check call THIS function, so "off-manifest" and
|
|
26
|
+
* "out-of-order" are defined exactly once.
|
|
27
|
+
*
|
|
28
|
+
* - A surfaceId executed that the manifest never named → `off-manifest-surface`.
|
|
29
|
+
* - A surfaceId the manifest named, executed out of the manifest's relative
|
|
30
|
+
* order → `out-of-order`.
|
|
31
|
+
*
|
|
32
|
+
* Order is checked only over the subsequence of executed ids that ARE in the
|
|
33
|
+
* manifest — an off-manifest surface is reported once (as off-manifest) and
|
|
34
|
+
* does not itself break the in-manifest ordering check for the surfaces
|
|
35
|
+
* around it.
|
|
36
|
+
*/
|
|
37
|
+
export function checkExecutionAgainstPlan(plan, executedSurfaceIds) {
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
const manifestIds = plan.surfaces.map((s) => s.surfaceId);
|
|
40
|
+
const manifestIndex = new Map(manifestIds.map((id, i) => [id, i]));
|
|
41
|
+
let lastSeenIndex = -1;
|
|
42
|
+
for (const surfaceId of executedSurfaceIds) {
|
|
43
|
+
const idx = manifestIndex.get(surfaceId);
|
|
44
|
+
if (idx === undefined) {
|
|
45
|
+
diagnostics.push({
|
|
46
|
+
code: 'off-manifest-surface',
|
|
47
|
+
surfaceId,
|
|
48
|
+
message: `surface "${surfaceId}" was executed but is not in the plan manifest (turn ${plan.turnId})`,
|
|
49
|
+
});
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (idx < lastSeenIndex) {
|
|
53
|
+
diagnostics.push({
|
|
54
|
+
code: 'out-of-order',
|
|
55
|
+
surfaceId,
|
|
56
|
+
message:
|
|
57
|
+
`surface "${surfaceId}" (manifest position ${idx}) was executed after a surface at ` +
|
|
58
|
+
`manifest position ${lastSeenIndex} — manifest order was not respected`,
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
lastSeenIndex = idx;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* R-O12's pure derivation: "what changed" this turn, from the manifest plus
|
|
69
|
+
* the envelopes actually emitted — never a hand-maintained side channel.
|
|
70
|
+
* DATA, never an envelope (ruling 3) — the caller renders it as feed chrome,
|
|
71
|
+
* never mints a surface from it.
|
|
72
|
+
*
|
|
73
|
+
* - A surfaceId first touched this turn (not in `previouslyKnownSurfaceIds`) → `new`.
|
|
74
|
+
* - A previously-known surfaceId touched by updateComponents/updateDataModel
|
|
75
|
+
* this turn → `updated`.
|
|
76
|
+
* - A previously-known surfaceId touched by deleteSurface this turn → `closed`.
|
|
77
|
+
*
|
|
78
|
+
* Deterministic ordering: each list preserves the manifest's surface order,
|
|
79
|
+
* then any emitted surfaceId not in the manifest, in first-seen order — same
|
|
80
|
+
* inputs always yield deep-equal output.
|
|
81
|
+
*/
|
|
82
|
+
export function synthesizeTurn(plan, emitted, previouslyKnownSurfaceIds) {
|
|
83
|
+
const known = new Set(previouslyKnownSurfaceIds);
|
|
84
|
+
const newSet = new Set();
|
|
85
|
+
const updatedSet = new Set();
|
|
86
|
+
const closedSet = new Set();
|
|
87
|
+
for (const event of emitted) {
|
|
88
|
+
const { surfaceId, kind } = event;
|
|
89
|
+
if (kind === 'deleteSurface') {
|
|
90
|
+
if (known.has(surfaceId)) closedSet.add(surfaceId);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!known.has(surfaceId)) {
|
|
94
|
+
newSet.add(surfaceId);
|
|
95
|
+
} else if (kind === 'updateComponents' || kind === 'updateDataModel') {
|
|
96
|
+
updatedSet.add(surfaceId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const orderedIds = [
|
|
100
|
+
...plan.surfaces.map((s) => s.surfaceId),
|
|
101
|
+
...emitted.map((e) => e.surfaceId).filter((id) => !plan.surfaces.some((s) => s.surfaceId === id)),
|
|
102
|
+
];
|
|
103
|
+
const dedupOrdered = (set) => {
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
const out = [];
|
|
106
|
+
for (const id of orderedIds) {
|
|
107
|
+
if (set.has(id) && !seen.has(id)) {
|
|
108
|
+
seen.add(id);
|
|
109
|
+
out.push(id);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
turnId: plan.turnId,
|
|
116
|
+
new: dedupOrdered(newSet),
|
|
117
|
+
updated: dedupOrdered(updatedSet),
|
|
118
|
+
closed: dedupOrdered(closedSet),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan-envelope executor (gh#648, docs/ORCHESTRATION.md §Plan envelope,
|
|
3
|
+
* R-O10–R-O13 in the vendored `@genui/producer`).
|
|
4
|
+
*
|
|
5
|
+
* gen-ui-kit's own compose engines (`../strategies/registry.js`) never call
|
|
6
|
+
* the vendored `@genui/producer#produce()` loop — `packages/genui/adia-
|
|
7
|
+
* producer` deliberately bypasses it (see that package's own header: the
|
|
8
|
+
* dialect these engines emit isn't genui v1.0's JSONL envelope grammar). So
|
|
9
|
+
* `deps.plan`/`deps.onPlan` (R-O10, produce()-only) never reach this repo's
|
|
10
|
+
* engines directly. What DOES travel from the vendored package is the two
|
|
11
|
+
* PURE primitives R-O11/R-O12 name as the one shared definition:
|
|
12
|
+
* `checkExecutionAgainstPlan` and `synthesizeTurn`. This module is gen-ui-
|
|
13
|
+
* kit's own executor built on top of them — the "gen-ui-kit-side executor"
|
|
14
|
+
* ORCHESTRATION.md's Data section describes.
|
|
15
|
+
*
|
|
16
|
+
* Scope ruling (recorded here, not reopened): a multi-surface TURN is a
|
|
17
|
+
* sequence of otherwise-independent single-surface engine calls — the
|
|
18
|
+
* engines in registry.js each still produce exactly one surface's messages
|
|
19
|
+
* per call, unchanged. `runPlannedTurn` is the new caller-facing seam that
|
|
20
|
+
* strings several such calls together under one inspectable manifest.
|
|
21
|
+
* Ruling 2 (ORCHESTRATION.md) names zettel/chunk-zettel as the natural
|
|
22
|
+
* opt-in strategies (retrieval already plans) and exempts monolithic-
|
|
23
|
+
* instant by design (latency) — `PLAN_STAGE_ENGINES` encodes exactly that
|
|
24
|
+
* set; `monolithic-instant` (and any engine not listed) throws rather than
|
|
25
|
+
* silently accepting a plan, so the exemption can't be violated by a
|
|
26
|
+
* caller forgetting the ruling.
|
|
27
|
+
*/
|
|
28
|
+
// R-O11/R-O12's two primitives live in this package rather than in the
|
|
29
|
+
// vendored (and unpublishable) `@genui/producer` — see plan-primitives.js
|
|
30
|
+
// for why, and plan-primitives.test.js for the anti-drift guard (gh#1186).
|
|
31
|
+
import { checkExecutionAgainstPlan, synthesizeTurn } from './plan-primitives.js';
|
|
32
|
+
import { pick } from '../strategies/registry.js';
|
|
33
|
+
|
|
34
|
+
export { checkExecutionAgainstPlan, synthesizeTurn };
|
|
35
|
+
|
|
36
|
+
/** Ruling 2 — the strategies whose retrieval step already plans, so
|
|
37
|
+
* surfacing that plan costs nothing new. Not the RESERVED engine-name set
|
|
38
|
+
* (registry.js) — this is strictly narrower, and intentionally not every
|
|
39
|
+
* reserved name: `monolithic-instant` stays exempt by design. */
|
|
40
|
+
export const PLAN_STAGE_ENGINES = new Set(['zettel', 'chunk-zettel']);
|
|
41
|
+
|
|
42
|
+
export function isPlanStageEngine(engineName) {
|
|
43
|
+
return PLAN_STAGE_ENGINES.has(engineName);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Thrown when the executed surface order doesn't match the manifest
|
|
47
|
+
* (R-O11) — surfaced the same way every other engine's validation failure
|
|
48
|
+
* is (`validation`/`diagnostics` on the error, never a silent extra
|
|
49
|
+
* render). */
|
|
50
|
+
export class PlanViolationError extends Error {
|
|
51
|
+
constructor(diagnostics) {
|
|
52
|
+
super(
|
|
53
|
+
`plan-turn: execution violated the plan manifest — ` +
|
|
54
|
+
diagnostics.map((d) => `[${d.code}] ${d.message}`).join('; '),
|
|
55
|
+
);
|
|
56
|
+
this.name = 'PlanViolationError';
|
|
57
|
+
this.diagnostics = diagnostics;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Runs a multi-surface turn against a caller-supplied plan (R-O10's shape:
|
|
63
|
+
* the plan is an INPUT, never derived here — deciding *which* surfaces a
|
|
64
|
+
* turn needs is the caller's planning step, out of this module's scope).
|
|
65
|
+
*
|
|
66
|
+
* @param {object} opts
|
|
67
|
+
* @param {string} opts.turnId
|
|
68
|
+
* @param {string} opts.engine — must be in PLAN_STAGE_ENGINES
|
|
69
|
+
* @param {{surfaceId: string, rationale: string, intent: string}[]} opts.surfaces
|
|
70
|
+
* — non-empty, in EXECUTION order (R-O11: array order IS execution order)
|
|
71
|
+
* @param {object} [opts.llmAdapter]
|
|
72
|
+
* @param {string} [opts.sessionId]
|
|
73
|
+
* @param {object} [opts.context]
|
|
74
|
+
* @param {string[]} [opts.previouslyKnownSurfaceIds] — for synthesizeTurn (R-O12)
|
|
75
|
+
* @param {(plan: {turnId: string, surfaces: {surfaceId: string, rationale: string}[]}) => void} [opts.onPlan]
|
|
76
|
+
* — fires exactly once, before the first engine call (mirrors R-O10)
|
|
77
|
+
* @returns {Promise<{
|
|
78
|
+
* plan: object,
|
|
79
|
+
* results: {surfaceId: string, result: object}[],
|
|
80
|
+
* planCheck: {ok: true} | {ok: false, diagnostics: object[]},
|
|
81
|
+
* synthesis: {turnId: string, new: string[], updated: string[], closed: string[]},
|
|
82
|
+
* }>}
|
|
83
|
+
*/
|
|
84
|
+
export async function runPlannedTurn({
|
|
85
|
+
turnId,
|
|
86
|
+
engine,
|
|
87
|
+
surfaces,
|
|
88
|
+
llmAdapter,
|
|
89
|
+
sessionId,
|
|
90
|
+
context,
|
|
91
|
+
previouslyKnownSurfaceIds = [],
|
|
92
|
+
onPlan,
|
|
93
|
+
}) {
|
|
94
|
+
if (!turnId) throw new Error('runPlannedTurn: opts.turnId is required');
|
|
95
|
+
if (!Array.isArray(surfaces) || surfaces.length === 0) {
|
|
96
|
+
throw new Error('runPlannedTurn: opts.surfaces must be a non-empty array (R-O10: non-empty manifest)');
|
|
97
|
+
}
|
|
98
|
+
if (!isPlanStageEngine(engine)) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`runPlannedTurn: engine "${engine}" is not plan-stage-eligible — only ` +
|
|
101
|
+
`${[...PLAN_STAGE_ENGINES].join(', ')} opt in (ruling 2, docs/ORCHESTRATION.md); ` +
|
|
102
|
+
`monolithic-instant is exempt by design (latency).`,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const plan = {
|
|
107
|
+
turnId,
|
|
108
|
+
surfaces: surfaces.map(({ surfaceId, rationale }) => ({ surfaceId, rationale })),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// R-O10: the manifest is the turn's first observable output, before any
|
|
112
|
+
// generation call.
|
|
113
|
+
onPlan?.(plan);
|
|
114
|
+
|
|
115
|
+
const generate = pick({ engine, mode: 'instant' });
|
|
116
|
+
const results = [];
|
|
117
|
+
const executedSurfaceIds = [];
|
|
118
|
+
const emitted = [];
|
|
119
|
+
|
|
120
|
+
for (const surface of surfaces) {
|
|
121
|
+
const result = await generate({
|
|
122
|
+
intent: surface.intent,
|
|
123
|
+
llmAdapter,
|
|
124
|
+
sessionId,
|
|
125
|
+
context,
|
|
126
|
+
storeId: sessionId,
|
|
127
|
+
executionId: surface.surfaceId,
|
|
128
|
+
});
|
|
129
|
+
results.push({ surfaceId: surface.surfaceId, result });
|
|
130
|
+
executedSurfaceIds.push(surface.surfaceId);
|
|
131
|
+
const kind = previouslyKnownSurfaceIds.includes(surface.surfaceId)
|
|
132
|
+
? 'updateComponents'
|
|
133
|
+
: 'createSurface';
|
|
134
|
+
emitted.push({ surfaceId: surface.surfaceId, kind });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const planCheck = checkExecutionAgainstPlan(plan, executedSurfaceIds);
|
|
138
|
+
if (!planCheck.ok) {
|
|
139
|
+
throw new PlanViolationError(planCheck.diagnostics);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const synthesis = synthesizeTurn(plan, emitted, previouslyKnownSurfaceIds);
|
|
143
|
+
|
|
144
|
+
return { plan, results, planCheck, synthesis };
|
|
145
|
+
}
|