@k2b/cloud 0.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/package.json +128 -0
- package/public/logo.svg +1 -0
- package/scripts/app-favicon.test.ts +49 -0
- package/scripts/app-favicon.ts +51 -0
- package/scripts/build.ts +205 -0
- package/scripts/preload.ts +164 -0
- package/scripts/sync-recovery-smoke.ts +200 -0
- package/src/_internal/app-favicon.ts +2 -0
- package/src/_internal/app-presentation.ts +61 -0
- package/src/_internal/app-workspace-state.ts +24 -0
- package/src/_internal/bounded-json.ts +47 -0
- package/src/_internal/build-metadata.ts +9 -0
- package/src/_internal/capabilities.ts +1118 -0
- package/src/_internal/define-app.ts +801 -0
- package/src/_internal/heartbeat.ts +167 -0
- package/src/_internal/help-catalog.ts +241 -0
- package/src/_internal/help.ts +95 -0
- package/src/_internal/nats-connection.ts +34 -0
- package/src/_internal/page-responses.ts +40 -0
- package/src/_internal/process-sync.ts +117 -0
- package/src/_internal/readiness.ts +3 -0
- package/src/_internal/registry-validation.ts +136 -0
- package/src/_internal/registry-watch.ts +52 -0
- package/src/_internal/registry.ts +338 -0
- package/src/_internal/runtime-compatibility.ts +64 -0
- package/src/_internal/runtime-context.ts +84 -0
- package/src/_internal/runtime-watcher.ts +78 -0
- package/src/_internal/static-assets.ts +86 -0
- package/src/_internal/status-preserving-ssr.ts +49 -0
- package/src/access/PermissionEditor.tsx +486 -0
- package/src/access/ResourceApiKeys.tsx +271 -0
- package/src/access/messages.ts +121 -0
- package/src/access/ui.ts +16 -0
- package/src/account/Avatar.tsx +28 -0
- package/src/account/EntitySearch.tsx +363 -0
- package/src/account/avatar-upload-dialog.tsx +197 -0
- package/src/account/avatar-upload.ts +149 -0
- package/src/account/ui.ts +3 -0
- package/src/ai/admin.ts +47 -0
- package/src/ai/approval-routes.ts +130 -0
- package/src/ai/approvals.ts +139 -0
- package/src/ai/assistant-models.ts +61 -0
- package/src/ai/attachments.ts +40 -0
- package/src/ai/browser.ts +92 -0
- package/src/ai/capabilities.ts +714 -0
- package/src/ai/capability-execution.ts +151 -0
- package/src/ai/chat/blocks.render.test.tsx +1108 -0
- package/src/ai/chat/blocks.tsx +730 -0
- package/src/ai/chat/builtin-tools.tsx +428 -0
- package/src/ai/chat/capability-table.tsx +87 -0
- package/src/ai/chat/composer-adapter.ts +169 -0
- package/src/ai/chat/file-tools.tsx +81 -0
- package/src/ai/chat/message-actions.tsx +370 -0
- package/src/ai/chat/message-utils.ts +479 -0
- package/src/ai/chat/messages.ts +43 -0
- package/src/ai/chat/presentation.tsx +395 -0
- package/src/ai/chat/primitives.tsx +3 -0
- package/src/ai/chat/tool-disclosure.tsx +41 -0
- package/src/ai/chat/turn-navigator-utils.ts +28 -0
- package/src/ai/chat/turn-navigator.tsx +164 -0
- package/src/ai/chat/user-message.tsx +149 -0
- package/src/ai/chat/visual-tools.tsx +435 -0
- package/src/ai/chat/web-tools.tsx +202 -0
- package/src/ai/chat-task-contracts.ts +113 -0
- package/src/ai/chat-tasks.ts +952 -0
- package/src/ai/client/controller.ts +1211 -0
- package/src/ai/client/file-source.ts +95 -0
- package/src/ai/client/live-connection.ts +140 -0
- package/src/ai/client/projection.ts +178 -0
- package/src/ai/client/transport.ts +111 -0
- package/src/ai/compaction.ts +182 -0
- package/src/ai/credentials.ts +124 -0
- package/src/ai/default-tool-contracts.ts +108 -0
- package/src/ai/default-tools.ts +127 -0
- package/src/ai/enrich.ts +280 -0
- package/src/ai/executor.ts +1624 -0
- package/src/ai/fetch-file-tool.ts +313 -0
- package/src/ai/file-context.ts +92 -0
- package/src/ai/file-media-type.ts +28 -0
- package/src/ai/file-mount.ts +16 -0
- package/src/ai/file-tools.ts +566 -0
- package/src/ai/files-store.ts +390 -0
- package/src/ai/firecrawl-tools.ts +305 -0
- package/src/ai/grids-skill.ts +126 -0
- package/src/ai/http.ts +265 -0
- package/src/ai/index.ts +337 -0
- package/src/ai/kit-skill.ts +22 -0
- package/src/ai/limits.ts +5 -0
- package/src/ai/live-events.ts +289 -0
- package/src/ai/live-messages.ts +45 -0
- package/src/ai/live-outbox.ts +102 -0
- package/src/ai/live-routes.ts +412 -0
- package/src/ai/live.ts +2 -0
- package/src/ai/maintenance.ts +302 -0
- package/src/ai/markdown-pdf-tool.ts +95 -0
- package/src/ai/memories.ts +605 -0
- package/src/ai/memory-learning-runs.ts +222 -0
- package/src/ai/memory-learning.ts +619 -0
- package/src/ai/memory-tool.ts +120 -0
- package/src/ai/memory-workflow-evidence.ts +158 -0
- package/src/ai/migrate.ts +2082 -0
- package/src/ai/model-access-migrate.ts +30 -0
- package/src/ai/model-access.ts +191 -0
- package/src/ai/personal-agent.ts +6 -0
- package/src/ai/prefs.ts +72 -0
- package/src/ai/project-tool.ts +94 -0
- package/src/ai/projects-routes.ts +277 -0
- package/src/ai/projects.ts +902 -0
- package/src/ai/protocol.ts +279 -0
- package/src/ai/provider.ts +73 -0
- package/src/ai/public-projection.ts +25 -0
- package/src/ai/resource-markers.ts +31 -0
- package/src/ai/resource-refs.ts +70 -0
- package/src/ai/routes.ts +1131 -0
- package/src/ai/runtime-tools.ts +39 -0
- package/src/ai/runtime.ts +544 -0
- package/src/ai/settings.ts +529 -0
- package/src/ai/short-id.ts +45 -0
- package/src/ai/skill-catalog.ts +73 -0
- package/src/ai/skill-format.ts +145 -0
- package/src/ai/skill-seeds.ts +430 -0
- package/src/ai/skill-tool.ts +81 -0
- package/src/ai/skills-routes.ts +143 -0
- package/src/ai/skills.ts +934 -0
- package/src/ai/solid.ts +27 -0
- package/src/ai/store.ts +3113 -0
- package/src/ai/stream.ts +308 -0
- package/src/ai/structured-runs.ts +66 -0
- package/src/ai/structured.ts +186 -0
- package/src/ai/system-prompt.ts +170 -0
- package/src/ai/task-prompt.ts +22 -0
- package/src/ai/timeline.ts +148 -0
- package/src/ai/tool-audit.ts +177 -0
- package/src/ai/tool-result-budget.ts +16 -0
- package/src/ai/tools.ts +155 -0
- package/src/ai/types.ts +967 -0
- package/src/ai/ui.tsx +39 -0
- package/src/ai/usage-migrate.ts +81 -0
- package/src/ai/usage.ts +315 -0
- package/src/ai/validate.ts +54 -0
- package/src/ai/vision-tool.ts +79 -0
- package/src/api/accounts-entities.ts +174 -0
- package/src/api/admin-ai-projects.ts +74 -0
- package/src/api/admin-ai-skills.ts +76 -0
- package/src/api/admin-ai-usage.ts +42 -0
- package/src/api/admin-core-settings.ts +508 -0
- package/src/api/admin-identity.ts +148 -0
- package/src/api/admin-lifecycle.ts +206 -0
- package/src/api/admin-linux-identities.ts +66 -0
- package/src/api/announcements.ts +131 -0
- package/src/api/app-approval.ts +129 -0
- package/src/api/apps.ts +51 -0
- package/src/api/auth/schemas.ts +54 -0
- package/src/api/auth.ts +370 -0
- package/src/api/capabilities.ts +658 -0
- package/src/api/help-messages.ts +19 -0
- package/src/api/help.ts +78 -0
- package/src/api/index.ts +108 -0
- package/src/api/mcp.ts +744 -0
- package/src/api/me-rail.ts +45 -0
- package/src/api/me.ts +753 -0
- package/src/api/search/schemas.ts +79 -0
- package/src/api/search.bench.ts +185 -0
- package/src/api/search.ts +407 -0
- package/src/api/sync-ops.ts +79 -0
- package/src/api/widgets.ts +143 -0
- package/src/browser/CloudResourceSearch.behavior.test.tsx +74 -0
- package/src/browser/CloudResourceSearch.tsx +791 -0
- package/src/browser/app-approval-vault.ts +305 -0
- package/src/browser/app-approval.ts +234 -0
- package/src/browser/live-websocket.ts +268 -0
- package/src/browser/locale-preference.ts +25 -0
- package/src/browser/notification-target.ts +27 -0
- package/src/browser/notification-timeout.ts +14 -0
- package/src/browser/notifications.ts +181 -0
- package/src/browser/resource-clipboard.ts +70 -0
- package/src/browser/resource-picker.tsx +39 -0
- package/src/browser/resource-search-messages.ts +55 -0
- package/src/browser/resource-search.ts +27 -0
- package/src/capabilities/client.ts +149 -0
- package/src/capabilities/response.ts +39 -0
- package/src/capabilities/server.ts +215 -0
- package/src/capabilities/signals.ts +4 -0
- package/src/capabilities/testing.ts +12 -0
- package/src/capabilities/types.ts +32 -0
- package/src/cli/access.ts +499 -0
- package/src/cli/account.ts +382 -0
- package/src/cli/admin/account-administration.ts +45 -0
- package/src/cli/admin/account-categories.ts +49 -0
- package/src/cli/admin/ai-usage.ts +118 -0
- package/src/cli/admin/app-sign-in.ts +49 -0
- package/src/cli/admin/data.ts +343 -0
- package/src/cli/admin/documentation.ts +34 -0
- package/src/cli/admin/gateway.ts +155 -0
- package/src/cli/admin/index.ts +61 -0
- package/src/cli/admin/instance.ts +250 -0
- package/src/cli/admin/jobs.ts +223 -0
- package/src/cli/admin/legal.ts +122 -0
- package/src/cli/admin/linux.ts +53 -0
- package/src/cli/admin/logs.ts +324 -0
- package/src/cli/admin/metrics.ts +142 -0
- package/src/cli/admin/nats.ts +167 -0
- package/src/cli/admin/notifications.ts +516 -0
- package/src/cli/admin/shared.ts +113 -0
- package/src/cli/admin/sync.ts +188 -0
- package/src/cli/admin/telemetry.ts +314 -0
- package/src/cli/admin/webhooks.ts +222 -0
- package/src/cli/admin/workflows.ts +367 -0
- package/src/cli/apps.ts +40 -0
- package/src/cli/capabilities.ts +239 -0
- package/src/cli/commands.ts +604 -0
- package/src/cli/index.ts +61 -0
- package/src/cli/locale.ts +31 -0
- package/src/cli/output.ts +58 -0
- package/src/clients/core.ts +20 -0
- package/src/config/env.ts +54 -0
- package/src/config/index.ts +6 -0
- package/src/contracts/account-categories.ts +62 -0
- package/src/contracts/announcements.ts +121 -0
- package/src/contracts/app-approval.ts +197 -0
- package/src/contracts/app.ts +162 -0
- package/src/contracts/capabilities.ts +484 -0
- package/src/contracts/index.ts +14 -0
- package/src/contracts/notification-live.ts +66 -0
- package/src/contracts/notification-types.ts +235 -0
- package/src/contracts/posix.ts +69 -0
- package/src/contracts/profile.ts +85 -0
- package/src/contracts/rail-preferences.ts +53 -0
- package/src/contracts/registry.ts +110 -0
- package/src/contracts/resource-clipboard.ts +33 -0
- package/src/contracts/settings-types.ts +98 -0
- package/src/contracts/shared.ts +408 -0
- package/src/contracts/user-notifications.ts +101 -0
- package/src/contracts/widgets.ts +183 -0
- package/src/desktop/index.ts +704 -0
- package/src/desktop/solid.tsx +938 -0
- package/src/index.ts +58 -0
- package/src/server/actor.ts +41 -0
- package/src/server/api/index.ts +2 -0
- package/src/server/api/respond.ts +96 -0
- package/src/server/api-client.ts +54 -0
- package/src/server/app-context.ts +39 -0
- package/src/server/help.ts +187 -0
- package/src/server/index.ts +89 -0
- package/src/server/locale.ts +55 -0
- package/src/server/middleware/auth.ts +386 -0
- package/src/server/middleware/index.ts +28 -0
- package/src/server/middleware/invocation.ts +55 -0
- package/src/server/middleware/middleware.ts +65 -0
- package/src/server/middleware/openapi.ts +126 -0
- package/src/server/middleware/rate-limit.ts +125 -0
- package/src/server/middleware/request-logger.ts +41 -0
- package/src/server/middleware/route-template.ts +46 -0
- package/src/server/middleware/runtime.ts +22 -0
- package/src/server/middleware/settings.ts +55 -0
- package/src/server/middleware/validator.ts +49 -0
- package/src/server/middleware/workload.ts +22 -0
- package/src/server/ratelimit.ts +151 -0
- package/src/server/request-cookies.ts +18 -0
- package/src/server/services/access.ts +644 -0
- package/src/server/services/freeipa/client.ts +137 -0
- package/src/server/services/freeipa/index.ts +9 -0
- package/src/server/services/freeipa/session.ts +123 -0
- package/src/server/services/freeipa/test-certificates.ts +44 -0
- package/src/server/services/freeipa/tls.ts +44 -0
- package/src/server/services/freeipa/transport.ts +116 -0
- package/src/server/services/freeipa/util.ts +59 -0
- package/src/server/services/geo.ts +198 -0
- package/src/server/services/index.ts +48 -0
- package/src/server/services/pagination.ts +22 -0
- package/src/server/services/services.ts +13 -0
- package/src/server/time.ts +33 -0
- package/src/services/account-category-policy.ts +51 -0
- package/src/services/account-lifecycle/audit.ts +41 -0
- package/src/services/account-lifecycle/index.ts +940 -0
- package/src/services/account-lifecycle/ipa-backfill.ts +152 -0
- package/src/services/account-lifecycle/notification-sender.ts +13 -0
- package/src/services/account-lifecycle/scheduler.ts +506 -0
- package/src/services/account-model.ts +22 -0
- package/src/services/accounts/app.ts +1671 -0
- package/src/services/accounts/authz.ts +44 -0
- package/src/services/accounts/avatar.ts +120 -0
- package/src/services/accounts/base-group.ts +11 -0
- package/src/services/accounts/base-user.ts +46 -0
- package/src/services/accounts/duplicate-emails.ts +82 -0
- package/src/services/accounts/entities.ts +622 -0
- package/src/services/accounts/group-sql.ts +106 -0
- package/src/services/accounts/groups.ts +272 -0
- package/src/services/accounts/index.ts +14 -0
- package/src/services/accounts/ipa-data.ts +66 -0
- package/src/services/accounts/lifecycle.ts +2 -0
- package/src/services/accounts/local-groups.ts +499 -0
- package/src/services/accounts/model.ts +129 -0
- package/src/services/accounts/notification-sender.ts +31 -0
- package/src/services/accounts/posix.ts +386 -0
- package/src/services/accounts/request-policy.ts +11 -0
- package/src/services/accounts/switching.ts +126 -0
- package/src/services/accounts/users.ts +745 -0
- package/src/services/announcements/index.ts +224 -0
- package/src/services/app-approval.ts +498 -0
- package/src/services/audit/index.ts +438 -0
- package/src/services/auth-flows/index.ts +15 -0
- package/src/services/auth-flows/ipa.ts +197 -0
- package/src/services/auth-flows/magic-link.ts +185 -0
- package/src/services/auth-flows/notification-sender.ts +10 -0
- package/src/services/auth-flows/password-reset.ts +268 -0
- package/src/services/auth-flows/proxy-return.ts +49 -0
- package/src/services/document-extraction.ts +148 -0
- package/src/services/freeipa-config.ts +179 -0
- package/src/services/gateway.ts +186 -0
- package/src/services/identity/constants.ts +18 -0
- package/src/services/identity/index.ts +52 -0
- package/src/services/identity/invocation-actor.ts +120 -0
- package/src/services/identity/invocation-authority.ts +53 -0
- package/src/services/identity/invocation-operations.ts +15 -0
- package/src/services/identity/invocation-token.ts +276 -0
- package/src/services/identity/key-config.ts +41 -0
- package/src/services/identity/key-ring.ts +530 -0
- package/src/services/identity/metrics.ts +29 -0
- package/src/services/identity/routes.ts +18 -0
- package/src/services/identity/runtime-config.ts +88 -0
- package/src/services/identity/session-token.ts +152 -0
- package/src/services/identity/signer-refresh.ts +44 -0
- package/src/services/identity/workload-auth.ts +64 -0
- package/src/services/index.ts +187 -0
- package/src/services/ipa/auth.ts +216 -0
- package/src/services/ipa/connection.ts +57 -0
- package/src/services/ipa/effective-groups.ts +70 -0
- package/src/services/ipa/groups.ts +722 -0
- package/src/services/ipa/guard.ts +17 -0
- package/src/services/ipa/index.ts +17 -0
- package/src/services/ipa/posix.ts +19 -0
- package/src/services/ipa/profile.ts +132 -0
- package/src/services/ipa/runtime.ts +28 -0
- package/src/services/ipa/search.ts +154 -0
- package/src/services/ipa/service-account.ts +15 -0
- package/src/services/ipa/sync-planning.ts +100 -0
- package/src/services/ipa/sync.ts +862 -0
- package/src/services/ipa/users.ts +806 -0
- package/src/services/legal-consent.ts +76 -0
- package/src/services/logging/index.ts +477 -0
- package/src/services/logging/redaction.ts +20 -0
- package/src/services/logging/trace.ts +1231 -0
- package/src/services/mandates/index.ts +855 -0
- package/src/services/mandates/policy.ts +85 -0
- package/src/services/network-security.ts +31 -0
- package/src/services/notifications/batches.ts +722 -0
- package/src/services/notifications/browser.ts +252 -0
- package/src/services/notifications/catalog.ts +113 -0
- package/src/services/notifications/channels.ts +104 -0
- package/src/services/notifications/dispatcher.ts +139 -0
- package/src/services/notifications/email.ts +118 -0
- package/src/services/notifications/index.ts +633 -0
- package/src/services/notifications/live.ts +50 -0
- package/src/services/notifications/observability.ts +407 -0
- package/src/services/notifications/platform.ts +421 -0
- package/src/services/notifications/runtime.ts +120 -0
- package/src/services/notifications/user.ts +248 -0
- package/src/services/notifications/web-push-transport.ts +135 -0
- package/src/services/oauth-tokens.ts +209 -0
- package/src/services/outbox.ts +187 -0
- package/src/services/pdf/gotenberg.ts +290 -0
- package/src/services/pdf/index.ts +43 -0
- package/src/services/pdf/markdown.ts +209 -0
- package/src/services/pdf/template-preview.ts +122 -0
- package/src/services/postgres.ts +76 -0
- package/src/services/providers/index.ts +27 -0
- package/src/services/providers/local/auth.ts +51 -0
- package/src/services/providers/local/index.ts +4 -0
- package/src/services/providers/local/users.ts +263 -0
- package/src/services/rail-preferences.ts +27 -0
- package/src/services/runtime-lifecycle.ts +191 -0
- package/src/services/secrets.ts +10 -0
- package/src/services/service-account-credentials.ts +891 -0
- package/src/services/service-accounts.ts +184 -0
- package/src/services/session/index.ts +236 -0
- package/src/services/session/test-fixture.ts +18 -0
- package/src/services/session/user.ts +144 -0
- package/src/services/settings/api.ts +61 -0
- package/src/services/settings/app.ts +86 -0
- package/src/services/settings/core-settings.ts +796 -0
- package/src/services/settings/crypto.ts +69 -0
- package/src/services/settings/defaults.ts +374 -0
- package/src/services/settings/index.ts +215 -0
- package/src/services/settings/namespace.ts +9 -0
- package/src/services/settings/snapshot.ts +49 -0
- package/src/services/settings/store.ts +241 -0
- package/src/services/settings/templates.ts +4 -0
- package/src/services/sync-ops.ts +403 -0
- package/src/services/topic-cursor.ts +22 -0
- package/src/services/weather/forecast.ts +323 -0
- package/src/services/weather/geo.ts +119 -0
- package/src/services/weather/index.ts +67 -0
- package/src/services/weather/location.ts +24 -0
- package/src/services/weather/locations.ts +133 -0
- package/src/services/weather/migrate.ts +45 -0
- package/src/services/weather/settings.ts +66 -0
- package/src/services/weather/short-id.ts +57 -0
- package/src/services/weather/types.ts +61 -0
- package/src/services/weather/ui.ts +50 -0
- package/src/services/webauthn.ts +385 -0
- package/src/shared/account-action-notice.ts +70 -0
- package/src/shared/account-display.ts +15 -0
- package/src/shared/account-session.ts +15 -0
- package/src/shared/ai-platform-prompt.ts +134 -0
- package/src/shared/ai-usage.ts +49 -0
- package/src/shared/app-presentation.ts +48 -0
- package/src/shared/app-url.ts +12 -0
- package/src/shared/branding.ts +14 -0
- package/src/shared/capability-messages.ts +70 -0
- package/src/shared/email-html.ts +54 -0
- package/src/shared/format.ts +91 -0
- package/src/shared/help.ts +68 -0
- package/src/shared/icons.ts +400 -0
- package/src/shared/index.ts +54 -0
- package/src/shared/locale.ts +48 -0
- package/src/shared/login-method.ts +44 -0
- package/src/shared/markdown/client.ts +130 -0
- package/src/shared/markdown/extensions/code.ts +105 -0
- package/src/shared/markdown/extensions/guided-help.ts +100 -0
- package/src/shared/markdown/extensions/images.ts +79 -0
- package/src/shared/markdown/extensions/info-blocks.ts +97 -0
- package/src/shared/markdown/extensions/katex.ts +120 -0
- package/src/shared/markdown/extensions/links.ts +43 -0
- package/src/shared/markdown/extensions/mark.ts +48 -0
- package/src/shared/markdown/extensions/sub-sup.ts +60 -0
- package/src/shared/markdown/extensions/tables.ts +109 -0
- package/src/shared/markdown/extensions/task-list.ts +53 -0
- package/src/shared/markdown/formula.ts +1187 -0
- package/src/shared/markdown/index.ts +193 -0
- package/src/shared/markdown/shared.ts +36 -0
- package/src/shared/mock-cover.ts +130 -0
- package/src/shared/network-address.ts +106 -0
- package/src/shared/redirect.ts +56 -0
- package/src/shared/template-rendering.ts +140 -0
- package/src/shared/theme.ts +68 -0
- package/src/shared/time.ts +13 -0
- package/src/ssr/AdminLayout.tsx +53 -0
- package/src/ssr/AdminSidebar.tsx +50 -0
- package/src/ssr/AppLaunchpad.island.tsx +236 -0
- package/src/ssr/AppWorkspaceController.island.tsx +21 -0
- package/src/ssr/BrowserNotifications.island.tsx +135 -0
- package/src/ssr/GlobalAnnouncements.island.tsx +142 -0
- package/src/ssr/GlobalSearchDialog.behavior.test.tsx +96 -0
- package/src/ssr/GlobalSearchDialog.tsx +35 -0
- package/src/ssr/GlobalSearchHelpDialog.tsx +104 -0
- package/src/ssr/GlobalSearchTrigger.island.tsx +55 -0
- package/src/ssr/HotkeysHelpRail.island.tsx +55 -0
- package/src/ssr/Layout.render.test.tsx +148 -0
- package/src/ssr/Layout.tsx +292 -0
- package/src/ssr/LayoutBreadcrumbs.island.tsx +44 -0
- package/src/ssr/LayoutFooter.tsx +22 -0
- package/src/ssr/LayoutHeader.tsx +81 -0
- package/src/ssr/LayoutHelp.tsx +869 -0
- package/src/ssr/LayoutPreferences.island.tsx +36 -0
- package/src/ssr/LayoutRail.tsx +58 -0
- package/src/ssr/MinimalLayout.tsx +46 -0
- package/src/ssr/PageError.tsx +29 -0
- package/src/ssr/ProfilePreferences.island.tsx +92 -0
- package/src/ssr/RailApps.island.tsx +61 -0
- package/src/ssr/RailEditor.tsx +293 -0
- package/src/ssr/RegisteredHelpDocuments.island.tsx +3 -0
- package/src/ssr/TimezoneCookie.island.tsx +23 -0
- package/src/ssr/admin-active-link.ts +47 -0
- package/src/ssr/admin-navigation.ts +78 -0
- package/src/ssr/app-appearance.ts +23 -0
- package/src/ssr/app-navigation.ts +41 -0
- package/src/ssr/help-messages.ts +104 -0
- package/src/ssr/index.ts +14 -0
- package/src/ssr/islands/SearchBar.island.tsx +80 -0
- package/src/ssr/islands/index.ts +16 -0
- package/src/ssr/layout-context.ts +17 -0
- package/src/ssr/layout-help-markdown.ts +9 -0
- package/src/ssr/layout-help-navigation.ts +24 -0
- package/src/ssr/layout-help-url.ts +5 -0
- package/src/ssr/layout-runtime.ts +22 -0
- package/src/ssr/page-error-messages.ts +25 -0
- package/src/ssr/platform-messages.ts +135 -0
- package/src/ssr/preference-controller.ts +44 -0
- package/src/ssr/profile-preferences-messages.ts +29 -0
- package/src/ssr/rail-context.ts +21 -0
- package/src/ssr/rail-messages.ts +66 -0
- package/src/ssr/rail-navigation.ts +60 -0
- package/src/ssr/runtime.ts +31 -0
- package/src/ssr/url-filter.ts +127 -0
- package/src/styles/base-popover.css +36 -0
- package/src/styles/effects.css +851 -0
- package/src/styles/global.css +268 -0
- package/src/styles/input.css +58 -0
- package/src/styles/tokens.css +230 -0
- package/src/styles/utilities-buttons.css +405 -0
- package/src/styles/utilities-data.css +33 -0
- package/src/styles/utilities-feedback.css +232 -0
- package/src/styles/utilities-layout.css +603 -0
- package/src/styles/utilities-markdown-editor.css +525 -0
- package/src/styles/utilities-markdown-table.css +234 -0
- package/src/styles/utilities-navigation.css +1054 -0
- package/src/types/ambient.d.ts +24 -0
- package/src/workflows/ai/index.ts +17 -0
- package/src/workflows/ai/runtime.ts +286 -0
- package/src/workflows/ai/store.ts +314 -0
- package/src/workflows/ai/types.ts +111 -0
- package/src/workflows/ai-actions.ts +269 -0
- package/src/workflows/authoring.ts +88 -0
- package/src/workflows/builtins.ts +193 -0
- package/src/workflows/contracts.ts +280 -0
- package/src/workflows/definition.ts +334 -0
- package/src/workflows/editor.ts +113 -0
- package/src/workflows/index.ts +71 -0
- package/src/workflows/language/binder.ts +45 -0
- package/src/workflows/language/canonical.ts +29 -0
- package/src/workflows/language/compiler.ts +396 -0
- package/src/workflows/language/expressions.ts +34 -0
- package/src/workflows/language/index.ts +20 -0
- package/src/workflows/language/references.ts +55 -0
- package/src/workflows/language/schema.ts +134 -0
- package/src/workflows/language/strict-yaml.ts +131 -0
- package/src/workflows/manifest.ts +24 -0
- package/src/workflows/module.ts +12 -0
- package/src/workflows/runtime/coordinator.ts +115 -0
- package/src/workflows/runtime/executor.ts +1003 -0
- package/src/workflows/runtime/index.ts +60 -0
- package/src/workflows/runtime/instant.ts +8 -0
- package/src/workflows/runtime/ports.ts +213 -0
- package/src/workflows/runtime/schedule.ts +203 -0
- package/src/workflows/runtime/trigger.ts +37 -0
- package/src/workflows/runtime/wake.ts +13 -0
- package/src/workflows/store/actions.ts +438 -0
- package/src/workflows/store/budget.ts +145 -0
- package/src/workflows/store/definitions.ts +345 -0
- package/src/workflows/store/events.ts +383 -0
- package/src/workflows/store/index.ts +107 -0
- package/src/workflows/store/observability.ts +594 -0
- package/src/workflows/store/runs.ts +975 -0
- package/src/workflows/store/transaction.ts +23 -0
- package/src/workflows/store/worker.ts +439 -0
- package/src/workflows/testing/conformance.ts +72 -0
- package/src/workflows/testing/index.ts +11 -0
- package/src/workflows/testing/process-fixtures.ts +275 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AccessSubject, RequestActor, User } from "./shared";
|
|
3
|
+
|
|
4
|
+
export const CAPABILITY_PROTOCOL_VERSION = 1 as const;
|
|
5
|
+
export const CAPABILITY_MAX_REQUEST_BYTES = 256 * 1024;
|
|
6
|
+
export const CAPABILITY_MAX_RESULT_BYTES = 256 * 1024;
|
|
7
|
+
export const CAPABILITY_MAX_CATALOG_BYTES = 2 * 1024 * 1024;
|
|
8
|
+
|
|
9
|
+
export const CAPABILITY_FRAMEWORK_ERROR_CODES = {
|
|
10
|
+
appUnavailable: "APP_UNAVAILABLE",
|
|
11
|
+
capabilityNotFound: "CAPABILITY_NOT_FOUND",
|
|
12
|
+
validationFailed: "VALIDATION_FAILED",
|
|
13
|
+
schemaMismatch: "SCHEMA_MISMATCH",
|
|
14
|
+
idempotencyKeyRequired: "IDEMPOTENCY_KEY_REQUIRED",
|
|
15
|
+
idempotencyKeyNotAllowed: "IDEMPOTENCY_KEY_NOT_ALLOWED",
|
|
16
|
+
idempotencyConflict: "IDEMPOTENCY_CONFLICT",
|
|
17
|
+
deadlineExceeded: "DEADLINE_EXCEEDED",
|
|
18
|
+
actionOutcomeUnknown: "ACTION_OUTCOME_UNKNOWN",
|
|
19
|
+
requestCancelled: "REQUEST_CANCELLED",
|
|
20
|
+
invalidAppResponse: "INVALID_APP_RESPONSE",
|
|
21
|
+
responseTooLarge: "RESPONSE_TOO_LARGE",
|
|
22
|
+
internal: "INTERNAL",
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
export const capabilityIdempotencyConflict = (
|
|
26
|
+
message: string,
|
|
27
|
+
details?: Record<string, unknown>,
|
|
28
|
+
): CapabilityError & { code: "IDEMPOTENCY_CONFLICT"; status: 409 } => ({
|
|
29
|
+
code: CAPABILITY_FRAMEWORK_ERROR_CODES.idempotencyConflict,
|
|
30
|
+
message,
|
|
31
|
+
status: 409,
|
|
32
|
+
...(details ? { details } : {}),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const CapabilityIdempotencyKeySchema = z
|
|
36
|
+
.string()
|
|
37
|
+
.trim()
|
|
38
|
+
.min(1)
|
|
39
|
+
.max(200)
|
|
40
|
+
.regex(/^[\x21-\x7e]+$/, "Idempotency keys must contain only visible ASCII characters");
|
|
41
|
+
|
|
42
|
+
const CAPABILITY_LOCAL_ID_PATTERN = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;
|
|
43
|
+
const CAPABILITY_QUALIFIED_ID_PATTERN = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;
|
|
44
|
+
const CLOUD_PATH_PATTERN = /^\/(?![\\/])[^\\\u0000-\u001f\u007f]*$/;
|
|
45
|
+
|
|
46
|
+
export const CapabilityLocalIdSchema = z
|
|
47
|
+
.string()
|
|
48
|
+
.min(1)
|
|
49
|
+
.max(100)
|
|
50
|
+
.regex(CAPABILITY_LOCAL_ID_PATTERN, "Use a stable lower-case capability id");
|
|
51
|
+
|
|
52
|
+
export const CapabilityQualifiedIdSchema = z
|
|
53
|
+
.string()
|
|
54
|
+
.min(3)
|
|
55
|
+
.max(180)
|
|
56
|
+
.regex(CAPABILITY_QUALIFIED_ID_PATTERN, "Expected a namespaced capability id such as contacts.contact");
|
|
57
|
+
|
|
58
|
+
export const CloudResourceRefSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
type: CapabilityQualifiedIdSchema.describe("Namespaced resource type declared by the owning app."),
|
|
61
|
+
id: z.string().min(1).max(512).describe("Stable app-owned resource identifier."),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
|
|
65
|
+
export type CloudResourceRef = z.infer<typeof CloudResourceRefSchema>;
|
|
66
|
+
|
|
67
|
+
export const CloudResourceReferenceSchema = CloudResourceRefSchema.extend({
|
|
68
|
+
title: z.string().min(1).max(500).optional().describe("Optional current user-facing resource label."),
|
|
69
|
+
preview: z.string().max(2000).optional().describe("Optional short plain-text context for the resource."),
|
|
70
|
+
icon: z.string().min(1).max(120).optional().describe("Optional presentation icon for the resource."),
|
|
71
|
+
}).strict();
|
|
72
|
+
|
|
73
|
+
export type CloudResourceReference = z.infer<typeof CloudResourceReferenceSchema>;
|
|
74
|
+
|
|
75
|
+
export const CapabilitySemanticLinkSchema = z
|
|
76
|
+
.object({
|
|
77
|
+
rel: z.enum(["open", "edit", "status", "preview", "download"]).describe("Semantic relationship; clients decide how to present it."),
|
|
78
|
+
href: z
|
|
79
|
+
.string()
|
|
80
|
+
.min(1)
|
|
81
|
+
.max(2048)
|
|
82
|
+
.regex(CLOUD_PATH_PATTERN, "Capability links must be root-relative same-origin Cloud paths")
|
|
83
|
+
.describe("Root-relative Cloud URL."),
|
|
84
|
+
title: z.string().min(1).max(120).optional().describe("Optional human-readable link label."),
|
|
85
|
+
})
|
|
86
|
+
.strict();
|
|
87
|
+
|
|
88
|
+
export type CapabilitySemanticLink = z.infer<typeof CapabilitySemanticLinkSchema>;
|
|
89
|
+
|
|
90
|
+
const CapabilityReviewDateTimeSchema = z.string().datetime({ offset: true });
|
|
91
|
+
const CapabilityReviewDateSchema = z.union([z.iso.date(), CapabilityReviewDateTimeSchema]);
|
|
92
|
+
const CapabilityActionReviewDetailSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
label: z.string().min(1).max(120),
|
|
95
|
+
value: z.string().max(10_000),
|
|
96
|
+
display: z.enum(["inline", "block"]).optional(),
|
|
97
|
+
format: z.enum(["date", "date-time"]).optional(),
|
|
98
|
+
})
|
|
99
|
+
.strict()
|
|
100
|
+
.superRefine((detail, context) => {
|
|
101
|
+
const schema =
|
|
102
|
+
detail.format === "date" ? CapabilityReviewDateSchema : detail.format === "date-time" ? CapabilityReviewDateTimeSchema : null;
|
|
103
|
+
if (schema?.safeParse(detail.value).success === false) {
|
|
104
|
+
context.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
path: ["value"],
|
|
107
|
+
message:
|
|
108
|
+
detail.format === "date" ? "Date review values must use YYYY-MM-DD or RFC 3339" : "Date-time review values must use RFC 3339",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const CapabilityActionReviewSchema = z
|
|
114
|
+
.object({
|
|
115
|
+
message: z.string().min(1).max(1000).describe("Plain-text description of the concrete Action consequence."),
|
|
116
|
+
details: z.array(CapabilityActionReviewDetailSchema).max(20).optional(),
|
|
117
|
+
links: z.array(CapabilitySemanticLinkSchema).max(10).optional(),
|
|
118
|
+
approvalScope: z.string().min(1).max(200).optional().describe("Opaque app-owned scope for a rememberable Action approval."),
|
|
119
|
+
})
|
|
120
|
+
.strict();
|
|
121
|
+
|
|
122
|
+
export type CapabilityActionReview = z.infer<typeof CapabilityActionReviewSchema>;
|
|
123
|
+
|
|
124
|
+
export const CapabilityPageSchema = z.discriminatedUnion("hasMore", [
|
|
125
|
+
z
|
|
126
|
+
.object({
|
|
127
|
+
hasMore: z.literal(true).describe("Another page is available."),
|
|
128
|
+
nextCursor: z.string().min(1).max(2048).describe("Opaque cursor for the next page."),
|
|
129
|
+
})
|
|
130
|
+
.strict(),
|
|
131
|
+
z
|
|
132
|
+
.object({
|
|
133
|
+
hasMore: z.literal(false).describe("This is the final page."),
|
|
134
|
+
})
|
|
135
|
+
.strict(),
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
export type CapabilityPage = z.infer<typeof CapabilityPageSchema>;
|
|
139
|
+
|
|
140
|
+
export const capabilityPage = (nextCursor?: string | null): CapabilityPage =>
|
|
141
|
+
nextCursor === undefined || nextCursor === null ? { hasMore: false } : { hasMore: true, nextCursor };
|
|
142
|
+
|
|
143
|
+
// Presentation work is bounded independently of the result's byte envelope.
|
|
144
|
+
const CapabilityDataPathSchema = z.array(z.string().max(500)).max(16);
|
|
145
|
+
export const CapabilityTablePresentationSchema = z
|
|
146
|
+
.object({
|
|
147
|
+
kind: z.literal("table"),
|
|
148
|
+
rowsPath: CapabilityDataPathSchema,
|
|
149
|
+
columns: z
|
|
150
|
+
.array(
|
|
151
|
+
z
|
|
152
|
+
.object({
|
|
153
|
+
path: CapabilityDataPathSchema,
|
|
154
|
+
label: z.string().max(500),
|
|
155
|
+
format: z.enum(["text", "number", "date", "datetime"]).optional(),
|
|
156
|
+
})
|
|
157
|
+
.strict(),
|
|
158
|
+
)
|
|
159
|
+
.min(1)
|
|
160
|
+
.max(100),
|
|
161
|
+
rowLinksPath: CapabilityDataPathSchema.optional(),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
export type CapabilityTablePresentation = z.infer<typeof CapabilityTablePresentationSchema>;
|
|
165
|
+
|
|
166
|
+
/** Resolve own JSON properties only. Paths are data, never expressions. */
|
|
167
|
+
export const capabilityDataAtPath = (data: unknown, path: readonly string[]): unknown => {
|
|
168
|
+
let value = data;
|
|
169
|
+
for (const segment of path) {
|
|
170
|
+
if (value === null || typeof value !== "object" || !Object.hasOwn(value, segment)) return undefined;
|
|
171
|
+
value = Object.getOwnPropertyDescriptor(value, segment)?.value;
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type CapabilityResult<T> = {
|
|
177
|
+
data: T;
|
|
178
|
+
/** Provider-authored, user-facing summary of the successful result. Render as escaped plain text. */
|
|
179
|
+
summary?: string;
|
|
180
|
+
refs?: CloudResourceReference[];
|
|
181
|
+
page?: CapabilityPage;
|
|
182
|
+
links?: CapabilitySemanticLink[];
|
|
183
|
+
presentation?: CapabilityTablePresentation;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const capabilityResultSchema = <T extends z.ZodType>(
|
|
187
|
+
data: T,
|
|
188
|
+
options?: { consumer?: boolean },
|
|
189
|
+
): z.ZodType<CapabilityResult<z.output<T>>> =>
|
|
190
|
+
z
|
|
191
|
+
.object({
|
|
192
|
+
data,
|
|
193
|
+
summary: z.string().trim().min(1).max(500).optional(),
|
|
194
|
+
refs: z.array(CloudResourceReferenceSchema).max(100).optional(),
|
|
195
|
+
page: CapabilityPageSchema.optional(),
|
|
196
|
+
links: z.array(CapabilitySemanticLinkSchema).max(20).optional(),
|
|
197
|
+
presentation: options?.consumer
|
|
198
|
+
? CapabilityTablePresentationSchema.optional().catch(undefined)
|
|
199
|
+
: CapabilityTablePresentationSchema.optional(),
|
|
200
|
+
})
|
|
201
|
+
.strict()
|
|
202
|
+
.superRefine((result, context) => {
|
|
203
|
+
if (
|
|
204
|
+
!options?.consumer &&
|
|
205
|
+
result.presentation &&
|
|
206
|
+
!Array.isArray(capabilityDataAtPath(capabilityDataAtPath(result, ["data"]), result.presentation.rowsPath))
|
|
207
|
+
) {
|
|
208
|
+
context.addIssue({
|
|
209
|
+
code: "custom",
|
|
210
|
+
path: ["presentation", "rowsPath"],
|
|
211
|
+
message: "Table rowsPath must reference an array in data.",
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}) as unknown as z.ZodType<CapabilityResult<z.output<T>>>;
|
|
215
|
+
|
|
216
|
+
export const capabilityResultJsonSchema = (dataSchema: Record<string, unknown>): Record<string, unknown> =>
|
|
217
|
+
z.toJSONSchema(capabilityResultSchema(z.fromJSONSchema(structuredClone(dataSchema))), { io: "output" }) as Record<string, unknown>;
|
|
218
|
+
|
|
219
|
+
export const CapabilityErrorSchema = z
|
|
220
|
+
.object({
|
|
221
|
+
code: z.string().min(1).max(100),
|
|
222
|
+
message: z.string().min(1).max(1000),
|
|
223
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
224
|
+
})
|
|
225
|
+
.strict();
|
|
226
|
+
|
|
227
|
+
export const CAPABILITY_ERROR_STATUSES = [400, 401, 403, 404, 409, 429, 499, 500, 502, 503, 504] as const;
|
|
228
|
+
export type CapabilityErrorStatus = (typeof CAPABILITY_ERROR_STATUSES)[number];
|
|
229
|
+
export type CapabilityError = {
|
|
230
|
+
code: string;
|
|
231
|
+
message: string;
|
|
232
|
+
status: CapabilityErrorStatus;
|
|
233
|
+
details?: Record<string, unknown>;
|
|
234
|
+
};
|
|
235
|
+
export type CapabilityInvocationResult<T> = { ok: true; data: CapabilityResult<T> } | { ok: false; error: CapabilityError };
|
|
236
|
+
export type CapabilityActionReviewResult = { ok: true; data: CapabilityActionReview } | { ok: false; error: CapabilityError };
|
|
237
|
+
|
|
238
|
+
export const CloudResourceViewSchema = z
|
|
239
|
+
.object({
|
|
240
|
+
ref: CloudResourceRefSchema.describe("Stable identity of the result."),
|
|
241
|
+
title: z.string().min(1).max(500).describe("Primary result label."),
|
|
242
|
+
preview: z.string().max(2000).optional().describe("Short plain-text result preview."),
|
|
243
|
+
icon: z.string().min(1).max(120).optional().describe("Optional presentation icon."),
|
|
244
|
+
priority: z.number().int().min(0).max(9).optional().describe("App-local relevance hint from zero to nine."),
|
|
245
|
+
metadata: z
|
|
246
|
+
.array(
|
|
247
|
+
z
|
|
248
|
+
.object({
|
|
249
|
+
label: z.string().min(1).max(120),
|
|
250
|
+
value: z.string().max(1000),
|
|
251
|
+
})
|
|
252
|
+
.strict(),
|
|
253
|
+
)
|
|
254
|
+
.max(20)
|
|
255
|
+
.optional()
|
|
256
|
+
.describe("Small structured metadata shown with the result."),
|
|
257
|
+
links: z.array(CapabilitySemanticLinkSchema).min(1).max(10).describe("Semantic links for the resource."),
|
|
258
|
+
})
|
|
259
|
+
.strict();
|
|
260
|
+
|
|
261
|
+
export type CloudResourceView = z.infer<typeof CloudResourceViewSchema>;
|
|
262
|
+
|
|
263
|
+
export const UniversalSearchInputSchema = z
|
|
264
|
+
.object({
|
|
265
|
+
query: z.string().max(500).describe("User-entered search text. Empty text is allowed when a facet narrows the query."),
|
|
266
|
+
tags: z.array(z.string().min(1).max(64)).max(20).describe("Canonical search facets supported by this query."),
|
|
267
|
+
limit: z.number().int().min(1).max(100).describe("Maximum number of results to return."),
|
|
268
|
+
})
|
|
269
|
+
.strict();
|
|
270
|
+
|
|
271
|
+
export type UniversalSearchInput = z.infer<typeof UniversalSearchInputSchema>;
|
|
272
|
+
|
|
273
|
+
export const UniversalSearchDataSchema = z.array(CloudResourceViewSchema).max(100);
|
|
274
|
+
export type UniversalSearchData = z.infer<typeof UniversalSearchDataSchema>;
|
|
275
|
+
|
|
276
|
+
export type CapabilityExecutionContext = {
|
|
277
|
+
actor: RequestActor;
|
|
278
|
+
accessSubject: AccessSubject;
|
|
279
|
+
user: User | null;
|
|
280
|
+
idempotencyKey?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Canonical BCP 47 locale of the originating request, transported as
|
|
283
|
+
* invocation metadata (never inside the input schema or auth token). Use it
|
|
284
|
+
* for human-facing formatting or `@k2b/stdlib` message catalogs; stable
|
|
285
|
+
* error codes and data must not depend on it.
|
|
286
|
+
*/
|
|
287
|
+
locale: string;
|
|
288
|
+
signal: AbortSignal;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export type CapabilityResourceTypeDefinition = {
|
|
292
|
+
title: string;
|
|
293
|
+
description: string;
|
|
294
|
+
icon?: string;
|
|
295
|
+
reader?: string;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
export type CapabilitySearchTagDefinition = {
|
|
299
|
+
tag: string;
|
|
300
|
+
title: string;
|
|
301
|
+
description: string;
|
|
302
|
+
aliases?: readonly string[];
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export type CapabilityUniversalSearchDefinition = {
|
|
306
|
+
tags: readonly CapabilitySearchTagDefinition[];
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export type CapabilitySchemaPresentation = Readonly<Record<string, string>>;
|
|
310
|
+
|
|
311
|
+
export type CapabilityOperationPresentationTranslation = {
|
|
312
|
+
title?: string;
|
|
313
|
+
description?: string;
|
|
314
|
+
/** Human descriptions keyed by a stable dotted field path such as `filter.tags[]`. */
|
|
315
|
+
input?: CapabilitySchemaPresentation;
|
|
316
|
+
/** Human descriptions keyed by a stable dotted field path such as `items[].name`. */
|
|
317
|
+
data?: CapabilitySchemaPresentation;
|
|
318
|
+
/** Search-tag presentation keyed by the stable tag token. */
|
|
319
|
+
searchTags?: Readonly<Record<string, { title?: string; description?: string }>>;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export type CapabilityPresentationTranslation = {
|
|
323
|
+
types?: Readonly<Record<string, { title?: string; description?: string }>>;
|
|
324
|
+
queries?: Readonly<Record<string, CapabilityOperationPresentationTranslation>>;
|
|
325
|
+
actions?: Readonly<Record<string, CapabilityOperationPresentationTranslation>>;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export type CapabilityPresentationCatalog = {
|
|
329
|
+
/** Locale of the complete Type, Query, Action, search-tag, and schema presentation. */
|
|
330
|
+
baseLocale: string;
|
|
331
|
+
/** Partial presentation overlays with exact -> ancestor -> base fallback. */
|
|
332
|
+
translations: Readonly<Record<string, CapabilityPresentationTranslation>>;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type CapabilityQueryDefinition<Input extends z.ZodType = z.ZodType<any>, Data extends z.ZodType = z.ZodType<any>> = {
|
|
336
|
+
title: string;
|
|
337
|
+
description: string;
|
|
338
|
+
input: Input;
|
|
339
|
+
data: Data;
|
|
340
|
+
openWorld: boolean;
|
|
341
|
+
universalSearch?: CapabilityUniversalSearchDefinition;
|
|
342
|
+
run: (
|
|
343
|
+
input: z.output<Input>,
|
|
344
|
+
context: CapabilityExecutionContext,
|
|
345
|
+
) => CapabilityInvocationResult<z.output<Data>> | Promise<CapabilityInvocationResult<z.output<Data>>>;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export type CapabilityIdempotencyPolicy = "none" | "required";
|
|
349
|
+
export type CapabilityActionApprovalPolicy = "rememberable";
|
|
350
|
+
|
|
351
|
+
export type CapabilityActionDefinition<Input extends z.ZodType = z.ZodType<any>, Data extends z.ZodType = z.ZodType<any>> = {
|
|
352
|
+
title: string;
|
|
353
|
+
description: string;
|
|
354
|
+
input: Input;
|
|
355
|
+
data: Data;
|
|
356
|
+
destructive: boolean;
|
|
357
|
+
openWorld: boolean;
|
|
358
|
+
idempotency: CapabilityIdempotencyPolicy;
|
|
359
|
+
approval?: CapabilityActionApprovalPolicy;
|
|
360
|
+
review?: (
|
|
361
|
+
input: z.output<Input>,
|
|
362
|
+
context: CapabilityExecutionContext,
|
|
363
|
+
) => CapabilityActionReviewResult | Promise<CapabilityActionReviewResult>;
|
|
364
|
+
run: (
|
|
365
|
+
input: z.output<Input>,
|
|
366
|
+
context: CapabilityExecutionContext,
|
|
367
|
+
) => CapabilityInvocationResult<z.output<Data>> | Promise<CapabilityInvocationResult<z.output<Data>>>;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
type CapabilityDefinitionCatalog<T> = Readonly<Record<string, T>>;
|
|
371
|
+
|
|
372
|
+
export type CapabilityDefinitions = {
|
|
373
|
+
protocolVersion: typeof CAPABILITY_PROTOCOL_VERSION;
|
|
374
|
+
presentation?: CapabilityPresentationCatalog;
|
|
375
|
+
types?: CapabilityDefinitionCatalog<CapabilityResourceTypeDefinition>;
|
|
376
|
+
queries?: CapabilityDefinitionCatalog<CapabilityQueryDefinition>;
|
|
377
|
+
actions?: CapabilityDefinitionCatalog<CapabilityActionDefinition>;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Declares one app's public capability surface. Runtime compilation happens
|
|
382
|
+
* in defineApp.start(), where the app id is available for namespacing.
|
|
383
|
+
*/
|
|
384
|
+
export const defineCapabilities = <const T extends CapabilityDefinitions>(definitions: T): T => definitions;
|
|
385
|
+
|
|
386
|
+
export const CapabilityResourceTypeManifestSchema = z
|
|
387
|
+
.object({
|
|
388
|
+
localId: CapabilityLocalIdSchema,
|
|
389
|
+
title: z.string().min(1).max(120),
|
|
390
|
+
description: z.string().min(1).max(500),
|
|
391
|
+
icon: z.string().min(1).max(120).optional(),
|
|
392
|
+
reader: CapabilityLocalIdSchema.optional(),
|
|
393
|
+
})
|
|
394
|
+
.strict();
|
|
395
|
+
|
|
396
|
+
export const CapabilitySearchTagManifestSchema = z
|
|
397
|
+
.object({
|
|
398
|
+
tag: z.string().min(1).max(64),
|
|
399
|
+
title: z.string().min(1).max(120),
|
|
400
|
+
description: z.string().min(1).max(500),
|
|
401
|
+
aliases: z.array(z.string().min(1).max(64)).max(20).optional(),
|
|
402
|
+
})
|
|
403
|
+
.strict();
|
|
404
|
+
|
|
405
|
+
const CapabilityOperationManifestBaseSchema = z
|
|
406
|
+
.object({
|
|
407
|
+
localId: CapabilityLocalIdSchema,
|
|
408
|
+
title: z.string().min(1).max(120),
|
|
409
|
+
description: z.string().min(1).max(1000),
|
|
410
|
+
inputSchema: z.record(z.string(), z.unknown()),
|
|
411
|
+
dataSchema: z.record(z.string(), z.unknown()),
|
|
412
|
+
schemaHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
413
|
+
})
|
|
414
|
+
.strict();
|
|
415
|
+
|
|
416
|
+
export const CapabilityQueryManifestSchema = CapabilityOperationManifestBaseSchema.extend({
|
|
417
|
+
openWorld: z.boolean(),
|
|
418
|
+
universalSearch: z
|
|
419
|
+
.object({ tags: z.array(CapabilitySearchTagManifestSchema).max(100) })
|
|
420
|
+
.strict()
|
|
421
|
+
.optional(),
|
|
422
|
+
}).strict();
|
|
423
|
+
|
|
424
|
+
export const CapabilityActionManifestSchema = CapabilityOperationManifestBaseSchema.extend({
|
|
425
|
+
destructive: z.boolean(),
|
|
426
|
+
openWorld: z.boolean(),
|
|
427
|
+
idempotency: z.enum(["none", "required"]),
|
|
428
|
+
approval: z.literal("rememberable").optional(),
|
|
429
|
+
review: z.literal(true).optional(),
|
|
430
|
+
}).strict();
|
|
431
|
+
|
|
432
|
+
export const CapabilityAppIdSchema = z
|
|
433
|
+
.string()
|
|
434
|
+
.min(1)
|
|
435
|
+
.max(80)
|
|
436
|
+
.regex(/^[a-z][a-z0-9-]*$/);
|
|
437
|
+
|
|
438
|
+
export const CapabilityManifestSchema = z
|
|
439
|
+
.object({
|
|
440
|
+
protocolVersion: z.literal(CAPABILITY_PROTOCOL_VERSION),
|
|
441
|
+
appId: CapabilityAppIdSchema,
|
|
442
|
+
manifestHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
443
|
+
types: z.array(CapabilityResourceTypeManifestSchema).max(200),
|
|
444
|
+
queries: z.array(CapabilityQueryManifestSchema).max(200),
|
|
445
|
+
actions: z.array(CapabilityActionManifestSchema).max(200),
|
|
446
|
+
})
|
|
447
|
+
.strict();
|
|
448
|
+
|
|
449
|
+
export type CapabilityResourceTypeManifest = z.infer<typeof CapabilityResourceTypeManifestSchema>;
|
|
450
|
+
export type CapabilityQueryManifest = z.infer<typeof CapabilityQueryManifestSchema>;
|
|
451
|
+
export type CapabilityActionManifest = z.infer<typeof CapabilityActionManifestSchema>;
|
|
452
|
+
export type CapabilitySearchTagManifest = z.infer<typeof CapabilitySearchTagManifestSchema>;
|
|
453
|
+
export type CapabilityManifest = z.infer<typeof CapabilityManifestSchema>;
|
|
454
|
+
|
|
455
|
+
export const cloudResourceRefAppId = (ref: CloudResourceRef): string => ref.type.slice(0, ref.type.indexOf("."));
|
|
456
|
+
|
|
457
|
+
/** Resolves a resource reference against one current, validated app manifest. */
|
|
458
|
+
export const resolveCapabilityResourceReader = (manifest: CapabilityManifest, ref: CloudResourceRef): CapabilityQueryManifest | null => {
|
|
459
|
+
if (cloudResourceRefAppId(ref) !== manifest.appId) return null;
|
|
460
|
+
const prefix = `${manifest.appId}.`;
|
|
461
|
+
const type = manifest.types.find((candidate) => candidate.localId === ref.type.slice(prefix.length));
|
|
462
|
+
if (!type?.reader) return null;
|
|
463
|
+
return manifest.queries.find((candidate) => candidate.localId === type.reader) ?? null;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
export const CapabilityCatalogAppSchema = z
|
|
467
|
+
.object({
|
|
468
|
+
appId: CapabilityAppIdSchema,
|
|
469
|
+
appName: z.string().min(1).max(200),
|
|
470
|
+
appIcon: z.string().min(1).max(120),
|
|
471
|
+
appDescription: z.string().max(1000),
|
|
472
|
+
manifest: CapabilityManifestSchema,
|
|
473
|
+
})
|
|
474
|
+
.strict();
|
|
475
|
+
|
|
476
|
+
export const CapabilityCatalogSchema = z
|
|
477
|
+
.object({
|
|
478
|
+
protocolVersion: z.literal(CAPABILITY_PROTOCOL_VERSION),
|
|
479
|
+
apps: z.array(CapabilityCatalogAppSchema).max(25),
|
|
480
|
+
page: CapabilityPageSchema,
|
|
481
|
+
})
|
|
482
|
+
.strict();
|
|
483
|
+
|
|
484
|
+
export type CapabilityCatalog = z.infer<typeof CapabilityCatalogSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./account-categories";
|
|
2
|
+
export * from "./announcements";
|
|
3
|
+
export * from "./app";
|
|
4
|
+
export * from "./capabilities";
|
|
5
|
+
export * from "./notification-live";
|
|
6
|
+
export * from "./notification-types";
|
|
7
|
+
export * from "./posix";
|
|
8
|
+
export * from "./profile";
|
|
9
|
+
export * from "./registry";
|
|
10
|
+
export * from "./resource-clipboard";
|
|
11
|
+
export * from "./shared";
|
|
12
|
+
export * from "./user-notifications";
|
|
13
|
+
export * from "./widgets";
|
|
14
|
+
export * from "./app-approval";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isSafeNotificationTargetHref } from "./notification-types";
|
|
3
|
+
|
|
4
|
+
export const NOTIFICATION_LIVE_WS_TYPE = {
|
|
5
|
+
subscribe: "notifications.live.subscribe",
|
|
6
|
+
ready: "notifications.live.ready",
|
|
7
|
+
event: "notifications.live.event",
|
|
8
|
+
revoked: "notifications.live.revoked",
|
|
9
|
+
error: "notifications.live.error",
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export const NotificationStreamCursorSchema = z
|
|
13
|
+
.string()
|
|
14
|
+
.regex(/^s6t\.[A-Za-z0-9_-]+\.\d+$/)
|
|
15
|
+
.max(80);
|
|
16
|
+
|
|
17
|
+
const NotificationTargetHrefSchema = z.custom<`/${string}`>(
|
|
18
|
+
(value) => typeof value === "string" && isSafeNotificationTargetHref(value),
|
|
19
|
+
"Notification target must be a canonical same-origin path",
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const NotificationLiveEventSchema = z.object({
|
|
23
|
+
type: z.literal("cloud-notification"),
|
|
24
|
+
eventId: z.string().min(1),
|
|
25
|
+
title: z.string(),
|
|
26
|
+
targetHref: NotificationTargetHrefSchema.optional(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type NotificationLiveEvent = z.infer<typeof NotificationLiveEventSchema>;
|
|
30
|
+
|
|
31
|
+
export const NotificationLiveClientMessageSchema = z.object({
|
|
32
|
+
type: z.literal(NOTIFICATION_LIVE_WS_TYPE.subscribe),
|
|
33
|
+
payload: z.object({ fromCursor: NotificationStreamCursorSchema.nullable() }),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type NotificationLiveClientMessage = z.infer<typeof NotificationLiveClientMessageSchema>;
|
|
37
|
+
|
|
38
|
+
export const NotificationLiveServerMessageSchema = z.discriminatedUnion("type", [
|
|
39
|
+
z.object({
|
|
40
|
+
type: z.literal(NOTIFICATION_LIVE_WS_TYPE.ready),
|
|
41
|
+
payload: z.object({ cursor: NotificationStreamCursorSchema }),
|
|
42
|
+
}),
|
|
43
|
+
z.object({
|
|
44
|
+
type: z.literal(NOTIFICATION_LIVE_WS_TYPE.event),
|
|
45
|
+
payload: z.object({ cursor: NotificationStreamCursorSchema, event: NotificationLiveEventSchema }),
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
type: z.literal(NOTIFICATION_LIVE_WS_TYPE.revoked),
|
|
49
|
+
payload: z.object({ code: z.string().min(1), message: z.string().min(1) }),
|
|
50
|
+
}),
|
|
51
|
+
z.object({
|
|
52
|
+
type: z.literal(NOTIFICATION_LIVE_WS_TYPE.error),
|
|
53
|
+
payload: z.object({ code: z.string().min(1), message: z.string().min(1) }),
|
|
54
|
+
}),
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
export type NotificationLiveServerMessage = z.infer<typeof NotificationLiveServerMessageSchema>;
|
|
58
|
+
|
|
59
|
+
export const parseNotificationLiveServerMessage = (raw: string): NotificationLiveServerMessage | null => {
|
|
60
|
+
try {
|
|
61
|
+
const parsed = NotificationLiveServerMessageSchema.safeParse(JSON.parse(raw));
|
|
62
|
+
return parsed.success ? parsed.data : null;
|
|
63
|
+
} catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|