@anthusai/papyrus 0.0.0 → 1.0.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/amplify/auth/resource.js +61 -0
- package/amplify/auth/resource.ts +65 -0
- package/amplify/data/resource.js +2069 -0
- package/amplify/data/resource.ts +2185 -0
- package/amplify/data/schema.js +1882 -0
- package/amplify/data/schema.ts +1990 -0
- package/amplify/functions/assignment-action/handler.ts +1416 -0
- package/amplify/functions/assignment-action/resource.js +8 -0
- package/amplify/functions/assignment-action/resource.ts +9 -0
- package/amplify/functions/category-action/handler.ts +2259 -0
- package/amplify/functions/category-action/resource.js +8 -0
- package/amplify/functions/category-action/resource.ts +9 -0
- package/amplify/functions/console-chat-responder/Cargo.lock +3456 -0
- package/amplify/functions/console-chat-responder/Cargo.toml +26 -0
- package/amplify/functions/console-chat-responder/Dockerfile +19 -0
- package/amplify/functions/console-chat-responder/py/execute_tactus_runner.py +116 -0
- package/amplify/functions/console-chat-responder/resource.js +153 -0
- package/amplify/functions/console-chat-responder/resource.ts +179 -0
- package/amplify/functions/console-chat-responder/src/main.rs +3242 -0
- package/amplify/functions/content-actions/handler.py +149 -0
- package/amplify/functions/content-actions/requirements.txt +4 -0
- package/amplify/functions/content-actions/resource.js +40 -0
- package/amplify/functions/content-actions/resource.ts +54 -0
- package/amplify/functions/email-submission-processor/handler.py +46 -0
- package/amplify/functions/email-submission-processor/requirements.txt +2 -0
- package/amplify/functions/email-submission-processor/resource.js +56 -0
- package/amplify/functions/email-submission-processor/resource.ts +69 -0
- package/amplify/functions/graphql-jwt-authorizer/handler.ts +193 -0
- package/amplify/functions/graphql-jwt-authorizer/resource.js +14 -0
- package/amplify/functions/graphql-jwt-authorizer/resource.ts +15 -0
- package/amplify/functions/knowledge-query/handler.py +1 -0
- package/amplify/functions/knowledge-query/requirements.txt +3 -0
- package/amplify/functions/knowledge-query/resource.js +50 -0
- package/amplify/functions/knowledge-query/resource.ts +61 -0
- package/amplify/functions/manage-user-role/handler.ts +799 -0
- package/amplify/functions/manage-user-role/resource.js +8 -0
- package/amplify/functions/manage-user-role/resource.ts +9 -0
- package/amplify/functions/model-attachment-upload/handler.ts +387 -0
- package/amplify/functions/model-attachment-upload/resource.js +8 -0
- package/amplify/functions/model-attachment-upload/resource.ts +9 -0
- package/amplify/functions/newsroom-summary/handler.ts +321 -0
- package/amplify/functions/newsroom-summary/resource.js +8 -0
- package/amplify/functions/newsroom-summary/resource.ts +9 -0
- package/amplify/functions/procedure-action/handler.ts +621 -0
- package/amplify/functions/procedure-action/resource.js +8 -0
- package/amplify/functions/procedure-action/resource.ts +9 -0
- package/amplify/functions/reader-settings/handler.ts +322 -0
- package/amplify/functions/reader-settings/resource.js +8 -0
- package/amplify/functions/reader-settings/resource.ts +9 -0
- package/amplify/functions/ses-inbound-receive/handler.ts +493 -0
- package/amplify/functions/ses-inbound-receive/resource.js +8 -0
- package/amplify/functions/ses-inbound-receive/resource.ts +9 -0
- package/amplify/functions/shared/amplify-secrets.ts +65 -0
- package/amplify/functions/shared/console-chat-enqueue.ts +117 -0
- package/amplify/functions/shared/email-mime-intake.ts +196 -0
- package/amplify/functions/shared/email-submission.ts +415 -0
- package/amplify/functions/shared/inbound-email-intake.ts +37 -0
- package/amplify/functions/shared/lambda-data-client.ts +21 -0
- package/amplify/functions/shared/model-payloads.ts +186 -0
- package/amplify/functions/shared/python-bundle.js +130 -0
- package/amplify/functions/shared/python-bundle.ts +162 -0
- package/amplify/functions/shared/slack-events.ts +111 -0
- package/amplify/functions/slack-delivery/handler.py +112 -0
- package/amplify/functions/slack-delivery/requirements.txt +2 -0
- package/amplify/functions/slack-delivery/resource.js +38 -0
- package/amplify/functions/slack-delivery/resource.ts +51 -0
- package/amplify/functions/slack-events/handler.ts +155 -0
- package/amplify/functions/slack-events/resource.js +11 -0
- package/amplify/functions/slack-events/resource.ts +12 -0
- package/amplify/inbound-email/stack.js +46 -0
- package/amplify/inbound-email/stack.ts +61 -0
- package/amplify/package.json +3 -0
- package/amplify/rebuild-trigger-settings.js +22 -0
- package/amplify/rebuild-trigger-settings.ts +42 -0
- package/amplify/site-backend-config.js +1 -0
- package/amplify/site-backend-config.ts +36 -0
- package/amplify/site-backend.js +615 -0
- package/amplify/site-backend.ts +739 -0
- package/amplify/storage/resource.js +21 -0
- package/amplify/storage/resource.ts +22 -0
- package/app/%5F_preview/[[...path]]/route.ts +8 -0
- package/app/[year]/[month]/[day]/[articleSlug]/page.tsx +62 -0
- package/app/[year]/[month]/[day]/edition-route-page.tsx +53 -0
- package/app/[year]/[month]/[day]/page/[pageNumber]/page.tsx +32 -0
- package/app/[year]/[month]/[day]/page.tsx +22 -0
- package/app/[year]/[month]/[day]/section/[sectionKey]/page.tsx +32 -0
- package/app/api/archive/editions/route.ts +18 -0
- package/app/api/media/[...path]/route.ts +35 -0
- package/app/api/revalidate/route.ts +94 -0
- package/app/archive/page.tsx +24 -0
- package/app/articles/[slug]/page.tsx +35 -0
- package/app/globals.css +10345 -0
- package/app/layout.tsx +142 -0
- package/app/newsroom/[section]/[...selection]/page.tsx +50 -0
- package/app/newsroom/[section]/page.tsx +47 -0
- package/app/newsroom/articles/[id]/page.tsx +15 -0
- package/app/newsroom/articles/page.tsx +13 -0
- package/app/newsroom/forum/[threadId]/page.tsx +35 -0
- package/app/newsroom/insights/[threadId]/page.tsx +22 -0
- package/app/newsroom/insights/page.tsx +14 -0
- package/app/newsroom/layout.tsx +12 -0
- package/app/newsroom/page.tsx +31 -0
- package/app/newsroom/sections/[sectionId]/page.tsx +17 -0
- package/app/page.tsx +272 -0
- package/app/papyrus-theme.css +11 -0
- package/app/robots.ts +11 -0
- package/app/settings/page.tsx +14 -0
- package/app/tailwind.css +65 -0
- package/bin/papyrus-app.mjs +20 -0
- package/bin/papyrus-infra.mjs +95 -0
- package/components/ai-elements/conversation.tsx +168 -0
- package/components/ai-elements/message.tsx +360 -0
- package/components/ai-elements/model-selector.tsx +30 -0
- package/components/ai-elements/prompt-input.tsx +1461 -0
- package/components/ai-elements/shimmer.tsx +76 -0
- package/components/ai-elements/suggestion.tsx +54 -0
- package/components/ai-elements/tool.tsx +173 -0
- package/components/amplify-client-provider.tsx +140 -0
- package/components/archive-grid.tsx +89 -0
- package/components/archive-shell.tsx +41 -0
- package/components/article-video.tsx +156 -0
- package/components/blog-page-background.tsx +20 -0
- package/components/dev-sandbox-editor-sign-in.tsx +60 -0
- package/components/markus-ir-preview.tsx +300 -0
- package/components/news-desk-client-provider.tsx +211 -0
- package/components/news-desk-page.tsx +116 -0
- package/components/news-desk-taxonomy-client.ts +3684 -0
- package/components/newspaper.tsx +1929 -0
- package/components/newsroom-access-gate.tsx +66 -0
- package/components/newsroom-article-editor.tsx +741 -0
- package/components/newsroom-articles-view.tsx +129 -0
- package/components/newsroom-assignments-view.tsx +664 -0
- package/components/newsroom-ops-overview.tsx +226 -0
- package/components/newsroom-ops-shell.tsx +321 -0
- package/components/newsroom-references-view.tsx +598 -0
- package/components/newsroom-topics-view.tsx +425 -0
- package/components/papyrus-console-shell.tsx +1912 -0
- package/components/pictogram-figure.tsx +65 -0
- package/components/presentation-footer.tsx +146 -0
- package/components/reader-auth-control.tsx +162 -0
- package/components/reader-auth-state.ts +122 -0
- package/components/reader-settings.ts +332 -0
- package/components/reader-theme-control.tsx +85 -0
- package/components/reference-source-preview.tsx +163 -0
- package/components/settings-page.tsx +239 -0
- package/components/staging-banner.tsx +11 -0
- package/components/topic-steering-workspace.tsx +18005 -0
- package/components/ui/badge.tsx +30 -0
- package/components/ui/button-group.tsx +87 -0
- package/components/ui/button.tsx +58 -0
- package/components/ui/card.tsx +32 -0
- package/components/ui/command.tsx +194 -0
- package/components/ui/dialog.tsx +158 -0
- package/components/ui/dropdown-menu.tsx +266 -0
- package/components/ui/hover-card.tsx +51 -0
- package/components/ui/input-group.tsx +158 -0
- package/components/ui/input.tsx +20 -0
- package/components/ui/scroll-area.tsx +16 -0
- package/components/ui/select.tsx +199 -0
- package/components/ui/separator.tsx +23 -0
- package/components/ui/sheet.tsx +92 -0
- package/components/ui/spinner.tsx +10 -0
- package/components/ui/tabs.tsx +113 -0
- package/components/ui/textarea.tsx +18 -0
- package/components/ui/tooltip.tsx +66 -0
- package/components/use-resolved-papyrus-theme.ts +47 -0
- package/infra/amplify-app-shell.js +234 -0
- package/infra/amplify-app-shell.ts +284 -0
- package/infra/build-specs.js +85 -0
- package/infra/build-specs.ts +131 -0
- package/infra/github-oidc-provider.js +24 -0
- package/infra/github-oidc-provider.ts +30 -0
- package/infra/index.js +15 -0
- package/infra/site-config.js +186 -0
- package/infra/site-config.ts +235 -0
- package/lib/amplify-outputs-guard.ts +24 -0
- package/lib/amplify-outputs-path.ts +16 -0
- package/lib/amplify-server-runtime.ts +63 -0
- package/lib/archive-data.ts +30 -0
- package/lib/archive-types.ts +15 -0
- package/lib/articles.ts +320 -0
- package/lib/cached-content-repository.ts +90 -0
- package/lib/category-dashboard.ts +37 -0
- package/lib/category-repository.ts +1907 -0
- package/lib/console-chat-client.ts +1316 -0
- package/lib/console-web-context.ts +118 -0
- package/lib/content-actions-client.ts +98 -0
- package/lib/content-actions-demo.ts +190 -0
- package/lib/content-load-timing.ts +23 -0
- package/lib/content-repository.ts +43 -0
- package/lib/content-source-context.ts +26 -0
- package/lib/content-types.ts +104 -0
- package/lib/define-site.js +3 -0
- package/lib/define-site.ts +21 -0
- package/lib/demo-amplify-outputs.ts +15 -0
- package/lib/dev-sandbox-editor-auth.ts +18 -0
- package/lib/doctrine.ts +128 -0
- package/lib/edition-routes.ts +155 -0
- package/lib/edition-sections.ts +111 -0
- package/lib/empty-edition-layout-plan.ts +109 -0
- package/lib/empty-theme.css +1 -0
- package/lib/excerpts.ts +8 -0
- package/lib/graphql-content-repository.ts +1140 -0
- package/lib/image-url.ts +10 -0
- package/lib/layout-plan.ts +981 -0
- package/lib/layout-scenarios.ts +564 -0
- package/lib/markus-body.ts +168 -0
- package/lib/markus-ir.ts +235 -0
- package/lib/markus-projection.ts +243 -0
- package/lib/markus-to-article.ts +93 -0
- package/lib/news-desk-session.ts +160 -0
- package/lib/newspaper-layout.ts +3459 -0
- package/lib/newsroom-articles.ts +325 -0
- package/lib/newsroom-assignments.ts +173 -0
- package/lib/newsroom-base-path.ts +48 -0
- package/lib/newsroom-card-layout.ts +102 -0
- package/lib/newsroom-category-drilldown.ts +133 -0
- package/lib/newsroom-demo-articles.ts +90 -0
- package/lib/newsroom-demo-dashboard.ts +267 -0
- package/lib/newsroom-demo-profile.ts +46 -0
- package/lib/newsroom-forum-routes.ts +153 -0
- package/lib/newsroom-index-filters.ts +202 -0
- package/lib/newsroom-knowledge-query-request.ts +51 -0
- package/lib/newsroom-list-selection.ts +42 -0
- package/lib/newsroom-media-backend.ts +142 -0
- package/lib/newsroom-media.ts +182 -0
- package/lib/newsroom-nav.ts +44 -0
- package/lib/newsroom-references.ts +116 -0
- package/lib/newsroom-sections.ts +52 -0
- package/lib/newsroom-topics.ts +118 -0
- package/lib/papyrus-object-kinds.ts +24 -0
- package/lib/papyrus-web-locations.ts +480 -0
- package/lib/pilobol-sample.ts +167 -0
- package/lib/presentation-footer.ts +92 -0
- package/lib/pretext-layout.ts +179 -0
- package/lib/public-placeholder-config.ts +102 -0
- package/lib/publication-items.ts +181 -0
- package/lib/reader-route-config.ts +1 -0
- package/lib/reader-static-params.ts +56 -0
- package/lib/reader-storage-url.ts +63 -0
- package/lib/reference-display.ts +74 -0
- package/lib/reference-policy.ts +97 -0
- package/lib/reference-source-preview.ts +175 -0
- package/lib/renderer-config.ts +50 -0
- package/lib/renderer.ts +87 -0
- package/lib/reporting-story-budget.ts +638 -0
- package/lib/semantic-graph.ts +554 -0
- package/lib/site-brand-tenant.ts +22 -0
- package/lib/site-brand.ts +194 -0
- package/lib/site-env.ts +52 -0
- package/lib/site-renderer.ts +17 -0
- package/lib/site-stack.ts +195 -0
- package/lib/staging-gate.ts +37 -0
- package/lib/staging-preview-object.ts +98 -0
- package/lib/themed-image.ts +30 -0
- package/lib/utils.ts +6 -0
- package/lib/video-mode.ts +42 -0
- package/lib/video-script.ts +63 -0
- package/middleware.ts +103 -0
- package/package.json +318 -1
- package/renderers/markus/index.ts +25 -0
- package/renderers/markus/stubs.tsx +33 -0
- package/renderers/pretext/article-page.tsx +169 -0
- package/renderers/pretext/index.ts +30 -0
- package/renderers/pretext/layouts.ts +16 -0
- package/renderers/pretext/presentation-shell.tsx +470 -0
- package/routes.manifest.json +208 -0
- package/scripts/fixtures/pilobol-sample.ast.json +234 -0
- package/scripts/videoml/build-browser-bundle.mjs +22 -0
- package/scripts/videoml/build-preview-bundle.mjs +50 -0
- package/scripts/videoml/bundle-common.mjs +129 -0
- package/scripts/videoml/preview/preview-entry.tsx +381 -0
- package/scripts/videoml/preview/preview-stage-fit.ts +28 -0
- package/scripts/videoml/preview/preview-timing.ts +42 -0
- package/scripts/videoml/preview.html +77 -0
- package/scripts/videoml/standard-entry.tsx +46 -0
- package/src/backend.js +1 -0
- package/src/backend.ts +3 -0
- package/src/sync.mjs +87 -0
- package/src/with-papyrus.d.mts +2 -0
- package/src/with-papyrus.mjs +60 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* Default Papyrus theme pack.
|
|
2
|
+
Identity mapping: consume the shared Shadcn :root tokens.
|
|
3
|
+
Other publications override --theme-* / --background under their own
|
|
4
|
+
data-theme-pack. Shared ops chrome never names this pack. */
|
|
5
|
+
|
|
6
|
+
:root[data-theme-pack="papyrus"] {
|
|
7
|
+
--theme-paper: var(--background);
|
|
8
|
+
--theme-moss: var(--primary);
|
|
9
|
+
--theme-ochre: var(--accent);
|
|
10
|
+
--theme-ink: var(--foreground);
|
|
11
|
+
}
|
package/app/robots.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MetadataRoute } from "next";
|
|
2
|
+
import { isIndexable } from "../lib/site-env";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
export default function robots(): MetadataRoute.Robots {
|
|
7
|
+
if (isIndexable()) {
|
|
8
|
+
return { rules: { userAgent: "*", allow: "/" } };
|
|
9
|
+
}
|
|
10
|
+
return { rules: { userAgent: "*", disallow: "/" } };
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { SettingsPage } from "../../components/settings-page";
|
|
3
|
+
import { SITE_BRAND } from "../../lib/site-brand";
|
|
4
|
+
|
|
5
|
+
export const dynamic = "force-dynamic";
|
|
6
|
+
|
|
7
|
+
export const metadata: Metadata = {
|
|
8
|
+
title: `Settings | ${SITE_BRAND.articleTitleSuffix}`,
|
|
9
|
+
description: `Reader presentation and theme settings for ${SITE_BRAND.articleTitleSuffix}.`,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function Settings() {
|
|
13
|
+
return <SettingsPage />;
|
|
14
|
+
}
|
package/app/tailwind.css
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@source "../components/**/*.{ts,tsx}";
|
|
3
|
+
@source "../app/**/*.{ts,tsx}";
|
|
4
|
+
@source "../lib/**/*.{ts,tsx}";
|
|
5
|
+
@source "../../../streamdown/dist/*.js";
|
|
6
|
+
@source "../../../@streamdown/code/dist/*.js";
|
|
7
|
+
@source "../../../@streamdown/cjk/dist/*.js";
|
|
8
|
+
@source "../../../@streamdown/math/dist/*.js";
|
|
9
|
+
@source "../../../@streamdown/mermaid/dist/*.js";
|
|
10
|
+
@import "tw-animate-css";
|
|
11
|
+
@import "shadcn/tailwind.css";
|
|
12
|
+
@import "streamdown/styles.css";
|
|
13
|
+
|
|
14
|
+
@custom-variant dark (&:is(.dark *));
|
|
15
|
+
|
|
16
|
+
@theme inline {
|
|
17
|
+
--color-background: var(--background);
|
|
18
|
+
--color-foreground: var(--foreground);
|
|
19
|
+
--color-card: var(--card);
|
|
20
|
+
--color-card-foreground: var(--card-foreground);
|
|
21
|
+
--color-popover: var(--popover);
|
|
22
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
23
|
+
--color-primary: var(--primary);
|
|
24
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
25
|
+
--color-secondary: var(--secondary);
|
|
26
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
27
|
+
--color-muted: var(--muted);
|
|
28
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
29
|
+
--color-accent: var(--accent);
|
|
30
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
31
|
+
--color-destructive: var(--destructive);
|
|
32
|
+
--color-danger: var(--danger);
|
|
33
|
+
--color-danger-foreground: var(--danger-foreground);
|
|
34
|
+
--color-surface: var(--surface);
|
|
35
|
+
--color-surface-foreground: var(--surface-foreground);
|
|
36
|
+
--color-foreground-strong: var(--foreground-strong);
|
|
37
|
+
--color-foreground-muted: var(--foreground-muted);
|
|
38
|
+
--color-border: var(--border);
|
|
39
|
+
--color-input: var(--input);
|
|
40
|
+
--color-ring: var(--ring);
|
|
41
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
42
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
43
|
+
--radius-lg: var(--radius);
|
|
44
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
45
|
+
--font-heading: var(--font-sans);
|
|
46
|
+
--font-sans: var(--font-sans);
|
|
47
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
48
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
49
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
50
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
51
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
52
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
53
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
54
|
+
--color-sidebar: var(--sidebar);
|
|
55
|
+
--color-chart-5: var(--chart-5);
|
|
56
|
+
--color-chart-4: var(--chart-4);
|
|
57
|
+
--color-chart-3: var(--chart-3);
|
|
58
|
+
--color-chart-2: var(--chart-2);
|
|
59
|
+
--color-chart-1: var(--chart-1);
|
|
60
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
61
|
+
--radius-3xl: calc(var(--radius) * 2.2);
|
|
62
|
+
--radius-4xl: calc(var(--radius) * 2.6);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Shadcn tokens live on .papyrus-console-ui in globals.css so publication layout stays on paper/ink. */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { sync } from "../src/sync.mjs";
|
|
3
|
+
|
|
4
|
+
const [command, ...rest] = process.argv.slice(2);
|
|
5
|
+
if (command === "sync") {
|
|
6
|
+
sync();
|
|
7
|
+
} else if (command === "videoml-bundle") {
|
|
8
|
+
const preview = rest.includes("--preview");
|
|
9
|
+
const { buildBrowserBundle } = await import("../scripts/videoml/build-browser-bundle.mjs");
|
|
10
|
+
const { buildPreviewBundle } = await import("../scripts/videoml/build-preview-bundle.mjs");
|
|
11
|
+
try {
|
|
12
|
+
await (preview ? buildPreviewBundle() : buildBrowserBundle());
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(error.message);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
console.error("Usage: papyrus-app sync | papyrus-app videoml-bundle [--preview]");
|
|
19
|
+
process.exit(command ? 1 : 0);
|
|
20
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* papyrus-infra synth --site infra/site.json [--out cdk.out] [--account A] [--region R]
|
|
4
|
+
* papyrus-infra synth --account-stack github-oidc [--out cdk.out] [--account A] [--region R]
|
|
5
|
+
* papyrus-infra print-buildspec --site infra/site.json --app cms-production|cms-staging|reader
|
|
6
|
+
* Synthesizes the app-shell stack for a publication from its own site.json, or
|
|
7
|
+
* prints one of the generated Amplify build specs. Synth only: deploying is a
|
|
8
|
+
* separate, reviewed step.
|
|
9
|
+
*/
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { buildSpecFor } from "../infra/build-specs.js";
|
|
14
|
+
import { parseSiteConfig, resolveStackName } from "../infra/site-config.js";
|
|
15
|
+
|
|
16
|
+
const USAGE = [
|
|
17
|
+
"Usage: papyrus-infra synth --site infra/site.json [--out cdk.out] [--account A] [--region R]",
|
|
18
|
+
" papyrus-infra synth --account-stack github-oidc [--out cdk.out] [--account A] [--region R]",
|
|
19
|
+
" papyrus-infra print-buildspec --site infra/site.json --app cms-production|cms-staging|reader",
|
|
20
|
+
].join("\n");
|
|
21
|
+
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const opt = (name, fallback) => {
|
|
24
|
+
const i = args.indexOf(`--${name}`);
|
|
25
|
+
return i >= 0 ? args[i + 1] : fallback;
|
|
26
|
+
};
|
|
27
|
+
const command = args[0];
|
|
28
|
+
if (command !== "synth" && command !== "print-buildspec") {
|
|
29
|
+
console.error(USAGE);
|
|
30
|
+
process.exit(command ? 1 : 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const accountStack = opt("account-stack");
|
|
34
|
+
if (accountStack !== undefined) {
|
|
35
|
+
if (command !== "synth" || accountStack !== "github-oidc") {
|
|
36
|
+
console.error(USAGE);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
let GithubOidcProviderStack;
|
|
40
|
+
try {
|
|
41
|
+
({ GithubOidcProviderStack } = await import("../infra/index.js"));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`papyrus-infra: ${error instanceof Error ? error.message : error}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const { App } = createRequire(path.join(process.cwd(), "noop.js"))("aws-cdk-lib");
|
|
47
|
+
const app = new App({ outdir: path.resolve(opt("out", "cdk.out")) });
|
|
48
|
+
new GithubOidcProviderStack(app, "GithubOidcProviderStack", {
|
|
49
|
+
env: { account: opt("account", "335163751677"), region: opt("region", "us-east-1") },
|
|
50
|
+
stackName: "github-oidc-provider",
|
|
51
|
+
});
|
|
52
|
+
app.synth();
|
|
53
|
+
console.log(`synthesized github-oidc-provider -> ${path.resolve(opt("out", "cdk.out"))}`);
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let config;
|
|
58
|
+
try {
|
|
59
|
+
config = parseSiteConfig(JSON.parse(fs.readFileSync(path.resolve(opt("site", "infra/site.json")), "utf8")));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(`papyrus-infra: ${error instanceof Error ? error.message : error}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (command === "print-buildspec") {
|
|
66
|
+
const app = opt("app");
|
|
67
|
+
if (!["cms-production", "cms-staging", "reader"].includes(app)) {
|
|
68
|
+
console.error(USAGE);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
process.stdout.write(buildSpecFor(config, app));
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(`papyrus-infra: ${error instanceof Error ? error.message : error}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let AmplifyAppShellStack;
|
|
81
|
+
try {
|
|
82
|
+
({ AmplifyAppShellStack } = await import("../infra/index.js"));
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(`papyrus-infra: ${error instanceof Error ? error.message : error}`);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const { App } = createRequire(path.join(process.cwd(), "noop.js"))("aws-cdk-lib");
|
|
89
|
+
const app = new App({ outdir: path.resolve(opt("out", "cdk.out")) });
|
|
90
|
+
new AmplifyAppShellStack(app, `AmplifyAppShell-${config.siteId}`, config, {
|
|
91
|
+
env: { account: opt("account", "335163751677"), region: opt("region", "us-east-1") },
|
|
92
|
+
stackName: resolveStackName(config),
|
|
93
|
+
});
|
|
94
|
+
app.synth();
|
|
95
|
+
console.log(`synthesized ${resolveStackName(config)} -> ${path.resolve(opt("out", "cdk.out"))}`);
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Button } from "../ui/button";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
import type { UIMessage } from "ai";
|
|
6
|
+
import { ArrowDownIcon, DownloadIcon } from "lucide-react";
|
|
7
|
+
import type { ComponentProps } from "react";
|
|
8
|
+
import { useCallback } from "react";
|
|
9
|
+
import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
10
|
+
|
|
11
|
+
export type ConversationProps = ComponentProps<typeof StickToBottom>;
|
|
12
|
+
|
|
13
|
+
export const Conversation = ({ className, ...props }: ConversationProps) => (
|
|
14
|
+
<StickToBottom
|
|
15
|
+
className={cn("relative flex-1 overflow-y-hidden", className)}
|
|
16
|
+
initial="smooth"
|
|
17
|
+
resize="smooth"
|
|
18
|
+
role="log"
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export type ConversationContentProps = ComponentProps<
|
|
24
|
+
typeof StickToBottom.Content
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const ConversationContent = ({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: ConversationContentProps) => (
|
|
31
|
+
<StickToBottom.Content
|
|
32
|
+
className={cn("flex flex-col gap-8 p-4", className)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export type ConversationEmptyStateProps = ComponentProps<"div"> & {
|
|
38
|
+
title?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
icon?: React.ReactNode;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const ConversationEmptyState = ({
|
|
44
|
+
className,
|
|
45
|
+
title = "No messages yet",
|
|
46
|
+
description = "Start a conversation to see messages here",
|
|
47
|
+
icon,
|
|
48
|
+
children,
|
|
49
|
+
...props
|
|
50
|
+
}: ConversationEmptyStateProps) => (
|
|
51
|
+
<div
|
|
52
|
+
className={cn(
|
|
53
|
+
"flex size-full flex-col items-center justify-center gap-3 p-8 text-center",
|
|
54
|
+
className
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
>
|
|
58
|
+
{children ?? (
|
|
59
|
+
<>
|
|
60
|
+
{icon && <div className="text-muted-foreground">{icon}</div>}
|
|
61
|
+
<div className="space-y-1">
|
|
62
|
+
<h3 className="font-medium text-sm">{title}</h3>
|
|
63
|
+
{description && (
|
|
64
|
+
<p className="text-muted-foreground text-sm">{description}</p>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
</>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export type ConversationScrollButtonProps = ComponentProps<typeof Button>;
|
|
73
|
+
|
|
74
|
+
export const ConversationScrollButton = ({
|
|
75
|
+
className,
|
|
76
|
+
...props
|
|
77
|
+
}: ConversationScrollButtonProps) => {
|
|
78
|
+
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
79
|
+
|
|
80
|
+
const handleScrollToBottom = useCallback(() => {
|
|
81
|
+
scrollToBottom();
|
|
82
|
+
}, [scrollToBottom]);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
!isAtBottom && (
|
|
86
|
+
<Button
|
|
87
|
+
className={cn(
|
|
88
|
+
"absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full dark:bg-background dark:hover:bg-muted",
|
|
89
|
+
className
|
|
90
|
+
)}
|
|
91
|
+
onClick={handleScrollToBottom}
|
|
92
|
+
size="icon"
|
|
93
|
+
type="button"
|
|
94
|
+
variant="outline"
|
|
95
|
+
{...props}
|
|
96
|
+
>
|
|
97
|
+
<ArrowDownIcon className="size-4" />
|
|
98
|
+
</Button>
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const getMessageText = (message: UIMessage): string =>
|
|
104
|
+
message.parts
|
|
105
|
+
.filter((part) => part.type === "text")
|
|
106
|
+
.map((part) => part.text)
|
|
107
|
+
.join("");
|
|
108
|
+
|
|
109
|
+
export type ConversationDownloadProps = Omit<
|
|
110
|
+
ComponentProps<typeof Button>,
|
|
111
|
+
"onClick"
|
|
112
|
+
> & {
|
|
113
|
+
messages: UIMessage[];
|
|
114
|
+
filename?: string;
|
|
115
|
+
formatMessage?: (message: UIMessage, index: number) => string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const defaultFormatMessage = (message: UIMessage): string => {
|
|
119
|
+
const roleLabel =
|
|
120
|
+
message.role.charAt(0).toUpperCase() + message.role.slice(1);
|
|
121
|
+
return `**${roleLabel}:** ${getMessageText(message)}`;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const messagesToMarkdown = (
|
|
125
|
+
messages: UIMessage[],
|
|
126
|
+
formatMessage: (
|
|
127
|
+
message: UIMessage,
|
|
128
|
+
index: number
|
|
129
|
+
) => string = defaultFormatMessage
|
|
130
|
+
): string => messages.map((msg, i) => formatMessage(msg, i)).join("\n\n");
|
|
131
|
+
|
|
132
|
+
export const ConversationDownload = ({
|
|
133
|
+
messages,
|
|
134
|
+
filename = "conversation.md",
|
|
135
|
+
formatMessage = defaultFormatMessage,
|
|
136
|
+
className,
|
|
137
|
+
children,
|
|
138
|
+
...props
|
|
139
|
+
}: ConversationDownloadProps) => {
|
|
140
|
+
const handleDownload = useCallback(() => {
|
|
141
|
+
const markdown = messagesToMarkdown(messages, formatMessage);
|
|
142
|
+
const blob = new Blob([markdown], { type: "text/markdown" });
|
|
143
|
+
const url = URL.createObjectURL(blob);
|
|
144
|
+
const link = document.createElement("a");
|
|
145
|
+
link.href = url;
|
|
146
|
+
link.download = filename;
|
|
147
|
+
document.body.append(link);
|
|
148
|
+
link.click();
|
|
149
|
+
link.remove();
|
|
150
|
+
URL.revokeObjectURL(url);
|
|
151
|
+
}, [messages, filename, formatMessage]);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<Button
|
|
155
|
+
className={cn(
|
|
156
|
+
"absolute top-4 right-4 rounded-full dark:bg-background dark:hover:bg-muted",
|
|
157
|
+
className
|
|
158
|
+
)}
|
|
159
|
+
onClick={handleDownload}
|
|
160
|
+
size="icon"
|
|
161
|
+
type="button"
|
|
162
|
+
variant="outline"
|
|
163
|
+
{...props}
|
|
164
|
+
>
|
|
165
|
+
{children ?? <DownloadIcon className="size-4" />}
|
|
166
|
+
</Button>
|
|
167
|
+
);
|
|
168
|
+
};
|