@agent-native/core 0.96.0 → 0.97.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 +6 -0
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +39 -0
- package/corpus/core/docs/content/audit-log.mdx +2 -1
- package/corpus/core/docs/content/automations.mdx +7 -7
- package/corpus/core/docs/content/creating-templates.mdx +1 -1
- package/corpus/core/docs/content/internationalization.mdx +2 -1
- package/corpus/core/docs/content/locales/ar-SA/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ar-SA/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ar-SA/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ar-SA/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/ar-SA/security.mdx +8 -0
- package/corpus/core/docs/content/locales/de-DE/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/de-DE/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/de-DE/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/de-DE/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
- package/corpus/core/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/de-DE/security.mdx +8 -0
- package/corpus/core/docs/content/locales/es-ES/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/es-ES/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/es-ES/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/es-ES/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
- package/corpus/core/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/es-ES/security.mdx +8 -0
- package/corpus/core/docs/content/locales/fr-FR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/fr-FR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/fr-FR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/fr-FR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
- package/corpus/core/docs/content/locales/fr-FR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/hi-IN/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/hi-IN/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/hi-IN/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/hi-IN/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
- package/corpus/core/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/hi-IN/security.mdx +8 -0
- package/corpus/core/docs/content/locales/ja-JP/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ja-JP/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ja-JP/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ja-JP/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/ja-JP/security.mdx +8 -0
- package/corpus/core/docs/content/locales/ko-KR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/ko-KR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/ko-KR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/ko-KR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
- package/corpus/core/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/ko-KR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/pt-BR/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/pt-BR/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/pt-BR/getting-started.mdx +7 -1
- package/corpus/core/docs/content/locales/pt-BR/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
- package/corpus/core/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/pt-BR/security.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-CN/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/zh-CN/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/zh-CN/getting-started.mdx +6 -4
- package/corpus/core/docs/content/locales/zh-CN/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
- package/corpus/core/docs/content/locales/zh-CN/security.mdx +8 -0
- package/corpus/core/docs/content/locales/zh-TW/audit-log.mdx +2 -1
- package/corpus/core/docs/content/locales/zh-TW/automations.mdx +7 -7
- package/corpus/core/docs/content/locales/zh-TW/getting-started.mdx +6 -4
- package/corpus/core/docs/content/locales/zh-TW/internationalization.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
- package/corpus/core/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
- package/corpus/core/docs/content/locales/zh-TW/security.mdx +8 -0
- package/corpus/core/docs/content/package-lifecycle.mdx +51 -0
- package/corpus/core/docs/content/sandbox-adapters.mdx +16 -5
- package/corpus/core/package.json +9 -2
- package/corpus/core/src/a2a/auth-policy.ts +33 -0
- package/corpus/core/src/agent/durable-background.ts +15 -7
- package/corpus/core/src/agent/run-store.ts +13 -4
- package/corpus/core/src/audit/actions/export-audit-events.ts +162 -0
- package/corpus/core/src/audit/store.ts +8 -3
- package/corpus/core/src/audit/types.ts +3 -0
- package/corpus/core/src/cli/doctor.ts +396 -0
- package/corpus/core/src/cli/index.ts +56 -0
- package/corpus/core/src/cli/info.ts +3 -3
- package/corpus/core/src/cli/package-lifecycle.ts +821 -0
- package/corpus/core/src/client/agent-chat-adapter.ts +9 -9
- package/corpus/core/src/guards/db-tool-scoping.ts +129 -0
- package/corpus/core/src/guards/index.ts +23 -0
- package/corpus/core/src/guards/no-drizzle-push.ts +116 -0
- package/corpus/core/src/guards/no-env-credentials.ts +229 -0
- package/corpus/core/src/guards/no-env-mutation.ts +114 -0
- package/corpus/core/src/guards/no-localhost-fallback.ts +124 -0
- package/corpus/core/src/guards/no-unscoped-credentials.ts +227 -0
- package/corpus/core/src/guards/no-unscoped-queries.ts +834 -0
- package/corpus/core/src/guards/scan-utils.ts +105 -0
- package/corpus/core/src/guards/types.ts +30 -0
- package/corpus/core/src/org/accept-pending.ts +9 -1
- package/corpus/core/src/org/migrations.ts +41 -0
- package/corpus/core/src/package-lifecycle/index.ts +1 -0
- package/corpus/core/src/package-lifecycle/manifest.ts +120 -0
- package/corpus/core/src/provider-api/custom-registry.ts +56 -0
- package/corpus/core/src/provider-api/index.ts +2 -0
- package/corpus/core/src/secrets/storage.ts +47 -27
- package/corpus/core/src/server/action-discovery.ts +4 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +54 -12
- package/corpus/core/src/server/core-routes-plugin.ts +30 -14
- package/corpus/core/src/server/csrf.ts +24 -5
- package/corpus/core/src/server/framework-request-handler.ts +34 -0
- package/corpus/core/src/server/google-realtime-session.ts +1 -36
- package/corpus/core/src/server/poll.ts +24 -2
- package/corpus/core/src/server/realtime-voice.ts +9 -0
- package/corpus/core/src/server/request-origin.ts +63 -0
- package/corpus/core/src/server/transcribe-voice.ts +1 -50
- package/corpus/core/src/templates/default/package.json +2 -2
- package/corpus/core/src/templates/headless/package.json +0 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/package.json +0 -1
- package/corpus/core/src/templates/workspace-root/package.json +0 -1
- package/corpus/core/src/triggers/actions.ts +11 -3
- package/corpus/core/src/triggers/types.ts +7 -1
- package/corpus/templates/analytics/actions/compose-dashboard.ts +65 -37
- package/corpus/templates/analytics/actions/mutate-dashboard.ts +73 -24
- package/corpus/templates/analytics/actions/reorder-dashboard-panels.ts +16 -13
- package/corpus/templates/analytics/actions/update-dashboard.ts +53 -42
- package/corpus/templates/analytics/changelog/2026-07-10-dashboard-edits-from-the-agent-and-the-ui-at-the-same-time-n.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-timed-out-bigquery-jobs-are-now-cancelled-so-they-stop-consu.md +6 -0
- package/corpus/templates/analytics/package.json +1 -2
- package/corpus/templates/analytics/server/lib/bigquery.ts +3 -2
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +154 -11
- package/corpus/templates/assets/package.json +1 -2
- package/corpus/templates/brain/package.json +1 -2
- package/corpus/templates/calendar/package.json +1 -2
- package/corpus/templates/chat/package.json +1 -2
- package/corpus/templates/clips/changelog/2026-07-10-atomic-view-tracking.md +6 -0
- package/corpus/templates/clips/chrome-extension/package.json +3 -2
- package/corpus/templates/clips/desktop/package.json +6 -4
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +26 -13
- package/corpus/templates/clips/desktop/src/lib/voice-dictation.ts +4 -1
- package/corpus/templates/clips/package.json +1 -2
- package/corpus/templates/clips/server/db/schema.ts +29 -17
- package/corpus/templates/clips/server/plugins/db.ts +8 -0
- package/corpus/templates/clips/server/routes/api/view-event.post.ts +260 -105
- package/corpus/templates/content/.agents/skills/notion-integration/SKILL.md +16 -0
- package/corpus/templates/content/AGENTS.md +72 -62
- package/corpus/templates/content/actions/_content-database-source-adapters.ts +84 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +206 -96
- package/corpus/templates/content/actions/_notion-database-source-adapter.ts +216 -0
- package/corpus/templates/content/actions/_position-utils.ts +76 -0
- package/corpus/templates/content/actions/_property-utils.ts +31 -20
- package/corpus/templates/content/actions/add-database-item.ts +52 -39
- package/corpus/templates/content/actions/attach-content-database-source.ts +95 -11
- package/corpus/templates/content/actions/change-content-database-source-role.ts +24 -1
- package/corpus/templates/content/actions/configure-document-property.ts +36 -27
- package/corpus/templates/content/actions/create-content-database.ts +40 -30
- package/corpus/templates/content/actions/create-document.ts +39 -32
- package/corpus/templates/content/actions/duplicate-document-property.ts +37 -28
- package/corpus/templates/content/actions/list-notion-database-sources.ts +80 -0
- package/corpus/templates/content/actions/move-document.ts +64 -48
- package/corpus/templates/content/actions/refresh-content-database-source.ts +42 -3
- package/corpus/templates/content/actions/share-local-file-document.ts +36 -27
- package/corpus/templates/content/actions/suggest-source-join-key.ts +39 -16
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +89 -23
- package/corpus/templates/content/app/components/editor/database/settings.tsx +1 -1
- package/corpus/templates/content/app/hooks/use-content-database.ts +18 -1
- package/corpus/templates/content/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/content/app/i18n-data.ts +40 -0
- package/corpus/templates/content/changelog/2026-07-10-failed-row-creation-and-source-attach-now-show-an-error-inst.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-items-added-at-the-same-time-no-longer-end-up-with-identical.md +6 -0
- package/corpus/templates/content/changelog/2026-07-10-notion-databases-can-add-read-only-details-to-content-tables.md +6 -0
- package/corpus/templates/content/package.json +1 -2
- package/corpus/templates/content/parity/matrix.md +25 -25
- package/corpus/templates/content/parity/matrix.ts +1 -0
- package/corpus/templates/content/server/routes/api/documents/[id]/move.patch.ts +43 -26
- package/corpus/templates/content/shared/api.ts +16 -1
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +8 -4
- package/corpus/templates/design/AGENTS.md +12 -2
- package/corpus/templates/design/DEVELOPING.md +10 -6
- package/corpus/templates/design/actions/apply-visual-edit.ts +191 -6
- package/corpus/templates/design/actions/duplicate-design.ts +31 -25
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +5 -1
- package/corpus/templates/design/changelog/2026-07-10-duplicating-a-design-can-no-longer-produce-a-copy-with-missi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-local-visual-edits-can-now-save-safe-leaf-text-class-and.md +6 -0
- package/corpus/templates/design/package.json +1 -1
- package/corpus/templates/design/shared/local-jsx-visual-edit.ts +388 -0
- package/corpus/templates/dispatch/package.json +1 -2
- package/corpus/templates/forms/actions/patch-form-fields.ts +82 -44
- package/corpus/templates/forms/changelog/2026-07-10-simultaneous-edits-to-different-form-fields-no-longer-overwr.md +6 -0
- package/corpus/templates/forms/package.json +1 -2
- package/corpus/templates/macros/package.json +1 -2
- package/corpus/templates/mail/app/components/email/EmailThread.tsx +3 -1
- package/corpus/templates/mail/changelog/2026-07-10-fixed-calendar-rsvp-buttons-in-emails-firing-duplicate-respo.md +6 -0
- package/corpus/templates/mail/package.json +1 -2
- package/corpus/templates/plan/actions/restore-plan-version.ts +126 -96
- package/corpus/templates/plan/changelog/2026-07-10-restoring-a-plan-version-can-no-longer-leave-a-plan-half-res.md +6 -0
- package/corpus/templates/plan/package.json +1 -2
- package/corpus/templates/plan/server/plans.ts +9 -2
- package/corpus/templates/slides/actions/list-decks.ts +28 -0
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +41 -26
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +4 -8
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +2 -4
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +4 -8
- package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +5 -12
- package/corpus/templates/slides/app/components/editor/HistoryPanel.tsx +3 -6
- package/corpus/templates/slides/app/components/editor/ImageDropPromptPopover.tsx +3 -6
- package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +2 -5
- package/corpus/templates/slides/app/context/DeckContext.tsx +47 -4
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +11 -30
- package/corpus/templates/slides/app/pages/Index.tsx +2 -3
- package/corpus/templates/slides/app/root.tsx +0 -5
- package/corpus/templates/slides/changelog/2026-07-10-deck-lists-load-much-faster-and-no-longer-re-download-slide-.md +6 -0
- package/corpus/templates/slides/package.json +1 -2
- package/dist/a2a/auth-policy.d.ts +19 -0
- package/dist/a2a/auth-policy.d.ts.map +1 -1
- package/dist/a2a/auth-policy.js +32 -0
- package/dist/a2a/auth-policy.js.map +1 -1
- package/dist/agent/durable-background.d.ts +8 -5
- package/dist/agent/durable-background.d.ts.map +1 -1
- package/dist/agent/durable-background.js +15 -8
- package/dist/agent/durable-background.js.map +1 -1
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +9 -4
- package/dist/agent/run-store.js.map +1 -1
- package/dist/audit/actions/export-audit-events.d.ts +27 -0
- package/dist/audit/actions/export-audit-events.d.ts.map +1 -0
- package/dist/audit/actions/export-audit-events.js +144 -0
- package/dist/audit/actions/export-audit-events.js.map +1 -0
- package/dist/audit/store.d.ts +1 -0
- package/dist/audit/store.d.ts.map +1 -1
- package/dist/audit/store.js +8 -3
- package/dist/audit/store.js.map +1 -1
- package/dist/audit/types.d.ts +3 -0
- package/dist/audit/types.d.ts.map +1 -1
- package/dist/audit/types.js.map +1 -1
- package/dist/cli/doctor.d.ts +83 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +277 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/index.js +50 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/info.js +3 -3
- package/dist/cli/info.js.map +1 -1
- package/dist/cli/package-lifecycle.d.ts +50 -0
- package/dist/cli/package-lifecycle.d.ts.map +1 -0
- package/dist/cli/package-lifecycle.js +560 -0
- package/dist/cli/package-lifecycle.js.map +1 -0
- package/dist/client/agent-chat-adapter.js +7 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/guards/db-tool-scoping.d.ts +38 -0
- package/dist/guards/db-tool-scoping.d.ts.map +1 -0
- package/dist/guards/db-tool-scoping.js +114 -0
- package/dist/guards/db-tool-scoping.js.map +1 -0
- package/dist/guards/index.d.ts +23 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/index.js +19 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/guards/no-drizzle-push.d.ts +14 -0
- package/dist/guards/no-drizzle-push.d.ts.map +1 -0
- package/dist/guards/no-drizzle-push.js +97 -0
- package/dist/guards/no-drizzle-push.js.map +1 -0
- package/dist/guards/no-env-credentials.d.ts +36 -0
- package/dist/guards/no-env-credentials.d.ts.map +1 -0
- package/dist/guards/no-env-credentials.js +204 -0
- package/dist/guards/no-env-credentials.js.map +1 -0
- package/dist/guards/no-env-mutation.d.ts +23 -0
- package/dist/guards/no-env-mutation.d.ts.map +1 -0
- package/dist/guards/no-env-mutation.js +90 -0
- package/dist/guards/no-env-mutation.js.map +1 -0
- package/dist/guards/no-localhost-fallback.d.ts +30 -0
- package/dist/guards/no-localhost-fallback.d.ts.map +1 -0
- package/dist/guards/no-localhost-fallback.js +105 -0
- package/dist/guards/no-localhost-fallback.js.map +1 -0
- package/dist/guards/no-unscoped-credentials.d.ts +28 -0
- package/dist/guards/no-unscoped-credentials.d.ts.map +1 -0
- package/dist/guards/no-unscoped-credentials.js +199 -0
- package/dist/guards/no-unscoped-credentials.js.map +1 -0
- package/dist/guards/no-unscoped-queries.d.ts +32 -0
- package/dist/guards/no-unscoped-queries.d.ts.map +1 -0
- package/dist/guards/no-unscoped-queries.js +720 -0
- package/dist/guards/no-unscoped-queries.js.map +1 -0
- package/dist/guards/scan-utils.d.ts +28 -0
- package/dist/guards/scan-utils.d.ts.map +1 -0
- package/dist/guards/scan-utils.js +92 -0
- package/dist/guards/scan-utils.js.map +1 -0
- package/dist/guards/types.d.ts +28 -0
- package/dist/guards/types.d.ts.map +1 -0
- package/dist/guards/types.js +11 -0
- package/dist/guards/types.js.map +1 -0
- package/dist/org/accept-pending.d.ts.map +1 -1
- package/dist/org/accept-pending.js +9 -1
- package/dist/org/accept-pending.js.map +1 -1
- package/dist/org/migrations.d.ts +7 -2
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +41 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/package-lifecycle/index.d.ts +2 -0
- package/dist/package-lifecycle/index.d.ts.map +1 -0
- package/dist/package-lifecycle/index.js +2 -0
- package/dist/package-lifecycle/index.js.map +1 -0
- package/dist/package-lifecycle/manifest.d.ts +24 -0
- package/dist/package-lifecycle/manifest.d.ts.map +1 -0
- package/dist/package-lifecycle/manifest.js +81 -0
- package/dist/package-lifecycle/manifest.js.map +1 -0
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/custom-registry.d.ts +32 -1
- package/dist/provider-api/custom-registry.d.ts.map +1 -1
- package/dist/provider-api/custom-registry.js +41 -1
- package/dist/provider-api/custom-registry.js.map +1 -1
- package/dist/provider-api/index.d.ts +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +1 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +45 -27
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +4 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +47 -13
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +23 -12
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/csrf.d.ts.map +1 -1
- package/dist/server/csrf.js +18 -5
- package/dist/server/csrf.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +34 -0
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/google-realtime-session.d.ts.map +1 -1
- package/dist/server/google-realtime-session.js +2 -34
- package/dist/server/google-realtime-session.js.map +1 -1
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +24 -2
- package/dist/server/poll.js.map +1 -1
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +9 -0
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/request-origin.d.ts +10 -0
- package/dist/server/request-origin.d.ts.map +1 -0
- package/dist/server/request-origin.js +60 -0
- package/dist/server/request-origin.js.map +1 -0
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +2 -48
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/templates/default/package.json +2 -2
- package/dist/templates/headless/package.json +0 -1
- package/dist/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/dist/templates/workspace-core/package.json +0 -1
- package/dist/templates/workspace-root/package.json +0 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +8 -3
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/types.d.ts +7 -1
- package/dist/triggers/types.d.ts.map +1 -1
- package/dist/triggers/types.js.map +1 -1
- package/docs/content/audit-log.mdx +2 -1
- package/docs/content/automations.mdx +7 -7
- package/docs/content/creating-templates.mdx +1 -1
- package/docs/content/internationalization.mdx +2 -1
- package/docs/content/locales/ar-SA/audit-log.mdx +2 -1
- package/docs/content/locales/ar-SA/automations.mdx +7 -7
- package/docs/content/locales/ar-SA/getting-started.mdx +7 -1
- package/docs/content/locales/ar-SA/internationalization.mdx +1 -1
- package/docs/content/locales/ar-SA/package-lifecycle.mdx +19 -0
- package/docs/content/locales/ar-SA/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/ar-SA/security.mdx +8 -0
- package/docs/content/locales/de-DE/audit-log.mdx +2 -1
- package/docs/content/locales/de-DE/automations.mdx +7 -7
- package/docs/content/locales/de-DE/getting-started.mdx +7 -1
- package/docs/content/locales/de-DE/internationalization.mdx +1 -1
- package/docs/content/locales/de-DE/package-lifecycle.mdx +22 -0
- package/docs/content/locales/de-DE/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/de-DE/security.mdx +8 -0
- package/docs/content/locales/es-ES/audit-log.mdx +2 -1
- package/docs/content/locales/es-ES/automations.mdx +7 -7
- package/docs/content/locales/es-ES/getting-started.mdx +7 -1
- package/docs/content/locales/es-ES/internationalization.mdx +1 -1
- package/docs/content/locales/es-ES/package-lifecycle.mdx +22 -0
- package/docs/content/locales/es-ES/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/es-ES/security.mdx +8 -0
- package/docs/content/locales/fr-FR/audit-log.mdx +2 -1
- package/docs/content/locales/fr-FR/automations.mdx +7 -7
- package/docs/content/locales/fr-FR/getting-started.mdx +7 -1
- package/docs/content/locales/fr-FR/internationalization.mdx +1 -1
- package/docs/content/locales/fr-FR/package-lifecycle.mdx +21 -0
- package/docs/content/locales/fr-FR/sandbox-adapters.mdx +19 -8
- package/docs/content/locales/fr-FR/security.mdx +8 -0
- package/docs/content/locales/hi-IN/audit-log.mdx +2 -1
- package/docs/content/locales/hi-IN/automations.mdx +7 -7
- package/docs/content/locales/hi-IN/getting-started.mdx +7 -1
- package/docs/content/locales/hi-IN/internationalization.mdx +1 -1
- package/docs/content/locales/hi-IN/package-lifecycle.mdx +20 -0
- package/docs/content/locales/hi-IN/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/hi-IN/security.mdx +8 -0
- package/docs/content/locales/ja-JP/audit-log.mdx +2 -1
- package/docs/content/locales/ja-JP/automations.mdx +7 -7
- package/docs/content/locales/ja-JP/getting-started.mdx +7 -1
- package/docs/content/locales/ja-JP/internationalization.mdx +1 -1
- package/docs/content/locales/ja-JP/package-lifecycle.mdx +21 -0
- package/docs/content/locales/ja-JP/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/ja-JP/security.mdx +8 -0
- package/docs/content/locales/ko-KR/audit-log.mdx +2 -1
- package/docs/content/locales/ko-KR/automations.mdx +7 -7
- package/docs/content/locales/ko-KR/getting-started.mdx +7 -1
- package/docs/content/locales/ko-KR/internationalization.mdx +1 -1
- package/docs/content/locales/ko-KR/package-lifecycle.mdx +20 -0
- package/docs/content/locales/ko-KR/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/ko-KR/security.mdx +8 -0
- package/docs/content/locales/pt-BR/audit-log.mdx +2 -1
- package/docs/content/locales/pt-BR/automations.mdx +7 -7
- package/docs/content/locales/pt-BR/getting-started.mdx +7 -1
- package/docs/content/locales/pt-BR/internationalization.mdx +1 -1
- package/docs/content/locales/pt-BR/package-lifecycle.mdx +21 -0
- package/docs/content/locales/pt-BR/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/pt-BR/security.mdx +8 -0
- package/docs/content/locales/zh-CN/audit-log.mdx +2 -1
- package/docs/content/locales/zh-CN/automations.mdx +7 -7
- package/docs/content/locales/zh-CN/getting-started.mdx +6 -4
- package/docs/content/locales/zh-CN/internationalization.mdx +1 -1
- package/docs/content/locales/zh-CN/package-lifecycle.mdx +19 -0
- package/docs/content/locales/zh-CN/sandbox-adapters.mdx +17 -6
- package/docs/content/locales/zh-CN/security.mdx +8 -0
- package/docs/content/locales/zh-TW/audit-log.mdx +2 -1
- package/docs/content/locales/zh-TW/automations.mdx +7 -7
- package/docs/content/locales/zh-TW/getting-started.mdx +6 -4
- package/docs/content/locales/zh-TW/internationalization.mdx +1 -1
- package/docs/content/locales/zh-TW/package-lifecycle.mdx +19 -0
- package/docs/content/locales/zh-TW/sandbox-adapters.mdx +18 -7
- package/docs/content/locales/zh-TW/security.mdx +8 -0
- package/docs/content/package-lifecycle.mdx +51 -0
- package/docs/content/sandbox-adapters.mdx +16 -5
- package/package.json +10 -3
- package/src/templates/default/package.json +2 -2
- package/src/templates/headless/package.json +0 -1
- package/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +3 -0
- package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +1 -1
- package/src/templates/workspace-core/package.json +0 -1
- package/src/templates/workspace-root/package.json +0 -1
- package/corpus/templates/slides/app/components/ui/toast.tsx +0 -1
- package/corpus/templates/slides/app/components/ui/toaster.tsx +0 -1
- package/corpus/templates/slides/app/hooks/use-toast.ts +0 -1
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertAgentNativePackageManifest, } from "../package-lifecycle/manifest.js";
|
|
6
|
+
const defaultIO = {
|
|
7
|
+
out: (message) => console.log(message),
|
|
8
|
+
err: (message) => console.error(message),
|
|
9
|
+
};
|
|
10
|
+
export async function runPackageLifecycle(args, runtime = {}) {
|
|
11
|
+
const io = runtime.io ?? defaultIO;
|
|
12
|
+
const command = args[0];
|
|
13
|
+
const packageName = args[1];
|
|
14
|
+
if (!isCommand(command) || !packageName) {
|
|
15
|
+
io.err(packageLifecycleUsage());
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
const json = args.includes("--json");
|
|
19
|
+
const apply = args.includes("--apply");
|
|
20
|
+
if (apply && command === "inspect") {
|
|
21
|
+
io.err("package inspect is always read-only; remove --apply");
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
const cwd = path.resolve(flagValue(args, "--root") ?? runtime.cwd ?? process.cwd());
|
|
25
|
+
let loaded;
|
|
26
|
+
try {
|
|
27
|
+
loaded = await (runtime.loadPackage
|
|
28
|
+
? runtime.loadPackage(packageName, cwd)
|
|
29
|
+
: loadLifecyclePackage(packageName, cwd, runtime.spawn ?? spawnSync));
|
|
30
|
+
if (loaded.manifest.name !== packageName) {
|
|
31
|
+
throw new Error(`Manifest name ${loaded.manifest.name} does not match requested package ${packageName}`);
|
|
32
|
+
}
|
|
33
|
+
const target = resolveTarget(cwd, flagValue(args, "--app"));
|
|
34
|
+
const planned = command === "eject"
|
|
35
|
+
? planEject(loaded, target.root, target.layout)
|
|
36
|
+
: planAdd(loaded, target.root, target.layout, command === "inspect");
|
|
37
|
+
const report = reportFor(command, loaded, target, apply, planned);
|
|
38
|
+
if (report.collisions.length > 0) {
|
|
39
|
+
report.compatible = false;
|
|
40
|
+
}
|
|
41
|
+
if (json)
|
|
42
|
+
io.out(JSON.stringify(report, null, 2));
|
|
43
|
+
else
|
|
44
|
+
io.out(formatReport(report));
|
|
45
|
+
if (!report.compatible)
|
|
46
|
+
return 1;
|
|
47
|
+
if (command === "inspect" || !apply)
|
|
48
|
+
return 0;
|
|
49
|
+
await applyTransaction(target.root, planned.changes.filter((change) => change.action !== "noop"), runtime.spawn ?? spawnSync);
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
io.err(error instanceof Error ? error.message : String(error));
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
loaded?.cleanup?.();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isCommand(value) {
|
|
61
|
+
return value === "inspect" || value === "add" || value === "eject";
|
|
62
|
+
}
|
|
63
|
+
function flagValue(args, name) {
|
|
64
|
+
const index = args.indexOf(name);
|
|
65
|
+
return index >= 0 ? args[index + 1] : undefined;
|
|
66
|
+
}
|
|
67
|
+
export function packageLifecycleUsage() {
|
|
68
|
+
return [
|
|
69
|
+
"Usage:",
|
|
70
|
+
" agent-native package inspect <package> [--root <dir>] [--app <name>] [--json]",
|
|
71
|
+
" agent-native package add <package> [--root <dir>] [--app <name>] [--apply] [--json]",
|
|
72
|
+
" agent-native package eject <package> [--root <dir>] [--app <name>] [--apply] [--json]",
|
|
73
|
+
"",
|
|
74
|
+
"add and eject are dry-run by default; pass --apply to write and run the package manager.",
|
|
75
|
+
].join("\n");
|
|
76
|
+
}
|
|
77
|
+
export async function loadLifecyclePackage(name, cwd, spawn = spawnSync) {
|
|
78
|
+
const packageJsonPath = findInstalledPackageJson(name, cwd);
|
|
79
|
+
if (packageJsonPath) {
|
|
80
|
+
return loadStaticPackageDirectory(name, path.dirname(packageJsonPath));
|
|
81
|
+
}
|
|
82
|
+
if (!/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name)) {
|
|
83
|
+
throw new Error(`Invalid package name: ${name}`);
|
|
84
|
+
}
|
|
85
|
+
const stage = fs.mkdtempSync(path.join(os.tmpdir(), "agent-native-package-inspect-"));
|
|
86
|
+
try {
|
|
87
|
+
const packed = spawn("npm", ["pack", name, "--ignore-scripts", "--json", "--pack-destination", stage], { cwd, encoding: "utf8", stdio: "pipe" });
|
|
88
|
+
if (packed.status !== 0) {
|
|
89
|
+
throw new Error(`Unable to download package metadata for '${name}'`);
|
|
90
|
+
}
|
|
91
|
+
const entries = JSON.parse(String(packed.stdout || "[]"));
|
|
92
|
+
const filename = entries[0]?.filename;
|
|
93
|
+
if (!filename || path.basename(filename) !== filename) {
|
|
94
|
+
throw new Error(`npm pack returned an invalid archive name for '${name}'`);
|
|
95
|
+
}
|
|
96
|
+
const archive = path.join(stage, filename);
|
|
97
|
+
const listed = spawn("tar", ["-tzf", archive], {
|
|
98
|
+
cwd,
|
|
99
|
+
encoding: "utf8",
|
|
100
|
+
stdio: "pipe",
|
|
101
|
+
});
|
|
102
|
+
if (listed.status !== 0) {
|
|
103
|
+
throw new Error(`Unable to list package archive for '${name}'`);
|
|
104
|
+
}
|
|
105
|
+
const archiveEntries = String(listed.stdout || "")
|
|
106
|
+
.split(/\r?\n/)
|
|
107
|
+
.filter(Boolean);
|
|
108
|
+
if (archiveEntries.length === 0 ||
|
|
109
|
+
archiveEntries.some((entry) => entry.includes("\\") ||
|
|
110
|
+
entry.startsWith("/") ||
|
|
111
|
+
!entry.startsWith("package/") ||
|
|
112
|
+
entry.split("/").includes(".."))) {
|
|
113
|
+
throw new Error(`Package archive for '${name}' contains an unsafe path`);
|
|
114
|
+
}
|
|
115
|
+
const extracted = spawn("tar", [
|
|
116
|
+
"-xzf",
|
|
117
|
+
archive,
|
|
118
|
+
"-C",
|
|
119
|
+
stage,
|
|
120
|
+
"--no-same-owner",
|
|
121
|
+
"--no-same-permissions",
|
|
122
|
+
], {
|
|
123
|
+
cwd,
|
|
124
|
+
encoding: "utf8",
|
|
125
|
+
stdio: "pipe",
|
|
126
|
+
});
|
|
127
|
+
if (extracted.status !== 0) {
|
|
128
|
+
throw new Error(`Unable to inspect package archive for '${name}'`);
|
|
129
|
+
}
|
|
130
|
+
const loaded = loadStaticPackageDirectory(name, path.join(stage, "package"));
|
|
131
|
+
loaded.cleanup = () => fs.rmSync(stage, { recursive: true, force: true });
|
|
132
|
+
return loaded;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function loadStaticPackageDirectory(name, packageDir) {
|
|
140
|
+
const packageJsonPath = path.join(packageDir, "package.json");
|
|
141
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
142
|
+
if (packageJson.name !== name) {
|
|
143
|
+
throw new Error(`Installed package name ${String(packageJson.name)} does not match ${name}`);
|
|
144
|
+
}
|
|
145
|
+
if (!packageJson.version) {
|
|
146
|
+
throw new Error(`Package '${name}' has no version`);
|
|
147
|
+
}
|
|
148
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(packageJson.version)) {
|
|
149
|
+
throw new Error(`Package '${name}' has an invalid version`);
|
|
150
|
+
}
|
|
151
|
+
const relativeManifest = packageJson.agentNativeManifest;
|
|
152
|
+
if (!relativeManifest || path.isAbsolute(relativeManifest)) {
|
|
153
|
+
throw new Error(`Package '${name}' does not declare a static agentNativeManifest`);
|
|
154
|
+
}
|
|
155
|
+
const manifestPath = path.resolve(packageDir, relativeManifest);
|
|
156
|
+
if (manifestPath !== packageDir &&
|
|
157
|
+
!manifestPath.startsWith(`${path.resolve(packageDir)}${path.sep}`)) {
|
|
158
|
+
throw new Error(`Package '${name}' manifest escapes the package directory`);
|
|
159
|
+
}
|
|
160
|
+
const manifestStat = fs.lstatSync(manifestPath);
|
|
161
|
+
if (!manifestStat.isFile() || manifestStat.isSymbolicLink()) {
|
|
162
|
+
throw new Error(`Package '${name}' static manifest must be a regular file`);
|
|
163
|
+
}
|
|
164
|
+
const realPackageDir = fs.realpathSync(packageDir);
|
|
165
|
+
const realManifestPath = fs.realpathSync(manifestPath);
|
|
166
|
+
if (!realManifestPath.startsWith(`${realPackageDir}${path.sep}`)) {
|
|
167
|
+
throw new Error(`Package '${name}' static manifest escapes the package directory`);
|
|
168
|
+
}
|
|
169
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
170
|
+
assertAgentNativePackageManifest(manifest);
|
|
171
|
+
if (manifest.name !== name) {
|
|
172
|
+
throw new Error(`Manifest name ${manifest.name} does not match ${name}`);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
manifest,
|
|
176
|
+
packageVersion: packageJson.version,
|
|
177
|
+
packageDir,
|
|
178
|
+
packageJson,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function findInstalledPackageJson(name, from) {
|
|
182
|
+
let dir = from;
|
|
183
|
+
while (true) {
|
|
184
|
+
const candidate = path.join(dir, "node_modules", name, "package.json");
|
|
185
|
+
if (fs.existsSync(candidate))
|
|
186
|
+
return candidate;
|
|
187
|
+
const parent = path.dirname(dir);
|
|
188
|
+
if (parent === dir)
|
|
189
|
+
return null;
|
|
190
|
+
dir = parent;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function resolveTarget(root, appName) {
|
|
194
|
+
const packageJsonPath = path.join(root, "package.json");
|
|
195
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
196
|
+
throw new Error(`Target root has no package.json: ${root}`);
|
|
197
|
+
}
|
|
198
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
199
|
+
const workspace = typeof pkg?.["agent-native"]?.workspaceCore === "string" &&
|
|
200
|
+
fs.existsSync(path.join(root, "apps"));
|
|
201
|
+
if (!workspace)
|
|
202
|
+
return { root, layout: "standalone" };
|
|
203
|
+
if (!appName) {
|
|
204
|
+
return { root, layout: "workspace-root" };
|
|
205
|
+
}
|
|
206
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(appName)) {
|
|
207
|
+
throw new Error(`Invalid workspace app name: ${appName}`);
|
|
208
|
+
}
|
|
209
|
+
const appRoot = path.join(root, "apps", appName);
|
|
210
|
+
if (!fs.existsSync(path.join(appRoot, "package.json"))) {
|
|
211
|
+
throw new Error(`Workspace app not found: ${appRoot}`);
|
|
212
|
+
}
|
|
213
|
+
return { root: appRoot, layout: "workspace-app" };
|
|
214
|
+
}
|
|
215
|
+
function planAdd(loaded, targetRoot, layout, inspectOnly) {
|
|
216
|
+
const { manifest, packageDir } = loaded;
|
|
217
|
+
const collisions = [];
|
|
218
|
+
const warnings = [];
|
|
219
|
+
if (layout === "workspace-root") {
|
|
220
|
+
collisions.push("Workspace root is ambiguous; pass --app <name> for add");
|
|
221
|
+
return { changes: [], collisions, warnings };
|
|
222
|
+
}
|
|
223
|
+
const packageJsonPath = path.join(targetRoot, "package.json");
|
|
224
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
225
|
+
pkg.dependencies ??= {};
|
|
226
|
+
const wantedRange = `^${loaded.packageVersion}`;
|
|
227
|
+
const currentRange = pkg.dependencies[manifest.name];
|
|
228
|
+
if (currentRange !== wantedRange && currentRange !== "workspace:*") {
|
|
229
|
+
pkg.dependencies[manifest.name] = wantedRange;
|
|
230
|
+
}
|
|
231
|
+
const changes = [
|
|
232
|
+
textChange(targetRoot, packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, "dependency"),
|
|
233
|
+
];
|
|
234
|
+
for (const action of manifest.actions) {
|
|
235
|
+
const target = path.join(targetRoot, "actions", `${action}.ts`);
|
|
236
|
+
const content = `export { default } from "${manifest.name}/actions/${action}";\n`;
|
|
237
|
+
changes.push(collisionCheckedText(targetRoot, target, content, "action", collisions));
|
|
238
|
+
}
|
|
239
|
+
const schemaPath = path.join(targetRoot, "server", "db", "schema.ts");
|
|
240
|
+
if (!fs.existsSync(schemaPath)) {
|
|
241
|
+
collisions.push(`Required schema file is missing: ${relative(targetRoot, schemaPath)}`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
const current = fs.readFileSync(schemaPath, "utf8");
|
|
245
|
+
const marker = `// agent-native-package:${manifest.name}`;
|
|
246
|
+
const contribution = `${marker}\nexport * from "${manifest.schemaEntryPoint}";`;
|
|
247
|
+
if (current.includes(marker) && !current.includes(contribution)) {
|
|
248
|
+
collisions.push("Existing package-owned schema block has unexpected content");
|
|
249
|
+
}
|
|
250
|
+
const next = current.includes(contribution)
|
|
251
|
+
? current
|
|
252
|
+
: `${current.trimEnd()}\n\n${contribution}\n`;
|
|
253
|
+
changes.push(textChange(targetRoot, schemaPath, next, "schema"));
|
|
254
|
+
}
|
|
255
|
+
const ownedPaths = [];
|
|
256
|
+
for (const skill of manifest.docs.skills) {
|
|
257
|
+
const source = path.join(packageDir, "docs", "skills", skill);
|
|
258
|
+
if (!fs.existsSync(source)) {
|
|
259
|
+
collisions.push(`Manifest skill source is missing: docs/skills/${skill}`);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
for (const sourceFile of walkFiles(source)) {
|
|
263
|
+
const target = path.join(targetRoot, ".agents", "skills", skill, path.relative(source, sourceFile));
|
|
264
|
+
changes.push(collisionCheckedBuffer(targetRoot, target, fs.readFileSync(sourceFile), "skill", collisions));
|
|
265
|
+
ownedPaths.push(relative(targetRoot, target));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const provenancePath = path.join(targetRoot, ".agent-native", "packages", `${manifest.name.replaceAll("/", "__")}.json`);
|
|
269
|
+
const provenance = {
|
|
270
|
+
manifestVersion: manifest.manifestVersion,
|
|
271
|
+
package: manifest.name,
|
|
272
|
+
version: loaded.packageVersion,
|
|
273
|
+
actions: manifest.actions,
|
|
274
|
+
schemaEntryPoint: manifest.schemaEntryPoint,
|
|
275
|
+
skills: manifest.docs.skills,
|
|
276
|
+
files: ownedPaths.sort(),
|
|
277
|
+
};
|
|
278
|
+
changes.push(textChange(targetRoot, provenancePath, `${JSON.stringify(provenance, null, 2)}\n`, "provenance"));
|
|
279
|
+
if (inspectOnly)
|
|
280
|
+
warnings.push("inspect is read-only; shown changes are the add plan");
|
|
281
|
+
return { changes, collisions, warnings };
|
|
282
|
+
}
|
|
283
|
+
function planEject(loaded, targetRoot, layout) {
|
|
284
|
+
const collisions = [];
|
|
285
|
+
const warnings = [];
|
|
286
|
+
if (loaded.manifest.name !== "@agent-native/scheduling") {
|
|
287
|
+
collisions.push("Eject currently supports only @agent-native/scheduling");
|
|
288
|
+
return { changes: [], collisions, warnings };
|
|
289
|
+
}
|
|
290
|
+
if (!loaded.manifest.eject) {
|
|
291
|
+
collisions.push("Package manifest does not declare eject metadata");
|
|
292
|
+
return { changes: [], collisions, warnings };
|
|
293
|
+
}
|
|
294
|
+
const workspaceRoot = layout === "workspace-app" ? path.resolve(targetRoot, "../..") : targetRoot;
|
|
295
|
+
const pnpmWorkspace = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
296
|
+
if (!fs.existsSync(pnpmWorkspace)) {
|
|
297
|
+
collisions.push("Eject currently requires an existing pnpm workspace; refusing to create a workspace:* dependency for another package manager");
|
|
298
|
+
return { changes: [], collisions, warnings };
|
|
299
|
+
}
|
|
300
|
+
const targetDir = path.join(workspaceRoot, loaded.manifest.eject.targetDirectory);
|
|
301
|
+
if (fs.existsSync(targetDir)) {
|
|
302
|
+
collisions.push(`Eject target already exists: ${relative(workspaceRoot, targetDir)}`);
|
|
303
|
+
return { changes: [], collisions, warnings };
|
|
304
|
+
}
|
|
305
|
+
const sourceRoot = path.join(loaded.packageDir, loaded.manifest.eject.sourceRoot);
|
|
306
|
+
if (!fs.existsSync(sourceRoot)) {
|
|
307
|
+
collisions.push(`Published eject source is missing: ${loaded.manifest.eject.sourceRoot}`);
|
|
308
|
+
return { changes: [], collisions, warnings };
|
|
309
|
+
}
|
|
310
|
+
const changes = [];
|
|
311
|
+
for (const source of walkFiles(sourceRoot)) {
|
|
312
|
+
const target = path.join(targetDir, "src", path.relative(sourceRoot, source));
|
|
313
|
+
changes.push({
|
|
314
|
+
path: target,
|
|
315
|
+
action: "create",
|
|
316
|
+
kind: "eject",
|
|
317
|
+
content: fs.readFileSync(source),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
for (const name of ["tsconfig.json", "agent-native.package.json"]) {
|
|
321
|
+
const source = path.join(loaded.packageDir, name);
|
|
322
|
+
if (fs.existsSync(source)) {
|
|
323
|
+
changes.push({
|
|
324
|
+
path: path.join(targetDir, name),
|
|
325
|
+
action: "create",
|
|
326
|
+
kind: "eject",
|
|
327
|
+
content: fs.readFileSync(source),
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
changes.push({
|
|
332
|
+
path: path.join(targetDir, "package.json"),
|
|
333
|
+
action: "create",
|
|
334
|
+
kind: "eject",
|
|
335
|
+
content: `${JSON.stringify(normalizeEjectedPackageJson(loaded.packageJson, workspaceRoot), null, 2)}\n`,
|
|
336
|
+
});
|
|
337
|
+
const consumerPackageJson = path.join(targetRoot, "package.json");
|
|
338
|
+
const consumer = JSON.parse(fs.readFileSync(consumerPackageJson, "utf8"));
|
|
339
|
+
consumer.dependencies ??= {};
|
|
340
|
+
consumer.dependencies[loaded.manifest.name] = "workspace:*";
|
|
341
|
+
changes.push(textChange(workspaceRoot, consumerPackageJson, `${JSON.stringify(consumer, null, 2)}\n`, "dependency"));
|
|
342
|
+
if (fs.existsSync(pnpmWorkspace)) {
|
|
343
|
+
const text = fs.readFileSync(pnpmWorkspace, "utf8");
|
|
344
|
+
if (!text.includes("packages/*") && !text.includes("packages/**")) {
|
|
345
|
+
collisions.push("pnpm-workspace.yaml does not include packages/*; refusing to rewrite YAML");
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
changes.push({
|
|
350
|
+
path: pnpmWorkspace,
|
|
351
|
+
action: "create",
|
|
352
|
+
kind: "workspace",
|
|
353
|
+
content: 'packages:\n - "packages/*"\n',
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
warnings.push("Imports keep the canonical @agent-native/scheduling specifier; workspace resolution switches them to the local package.");
|
|
357
|
+
return { changes, collisions, warnings };
|
|
358
|
+
}
|
|
359
|
+
function normalizeEjectedPackageJson(input, workspaceRoot) {
|
|
360
|
+
const output = structuredClone(input);
|
|
361
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
362
|
+
const dependencies = output[field];
|
|
363
|
+
if (!dependencies)
|
|
364
|
+
continue;
|
|
365
|
+
for (const [name, range] of Object.entries(dependencies)) {
|
|
366
|
+
if (typeof range !== "string" ||
|
|
367
|
+
(!range.startsWith("workspace:") && !range.startsWith("catalog:"))) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
const installed = findInstalledPackageJson(name, workspaceRoot);
|
|
371
|
+
if (!installed) {
|
|
372
|
+
throw new Error(`Cannot normalize ${field}.${name}; the installed dependency version is unavailable`);
|
|
373
|
+
}
|
|
374
|
+
const version = JSON.parse(fs.readFileSync(installed, "utf8")).version;
|
|
375
|
+
if (!version)
|
|
376
|
+
throw new Error(`Installed dependency ${name} has no version`);
|
|
377
|
+
dependencies[name] = `^${version}`;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return output;
|
|
381
|
+
}
|
|
382
|
+
function collisionCheckedText(root, target, content, kind, collisions) {
|
|
383
|
+
return collisionCheckedBuffer(root, target, Buffer.from(content), kind, collisions);
|
|
384
|
+
}
|
|
385
|
+
function collisionCheckedBuffer(root, target, content, kind, collisions) {
|
|
386
|
+
if (!fs.existsSync(target)) {
|
|
387
|
+
return { path: target, action: "create", kind, content };
|
|
388
|
+
}
|
|
389
|
+
const current = fs.readFileSync(target);
|
|
390
|
+
if (current.equals(content))
|
|
391
|
+
return { path: target, action: "noop", kind };
|
|
392
|
+
collisions.push(`Refusing to overwrite ${relative(root, target)}`);
|
|
393
|
+
return { path: target, action: "noop", kind };
|
|
394
|
+
}
|
|
395
|
+
function textChange(root, target, content, kind) {
|
|
396
|
+
if (!fs.existsSync(target))
|
|
397
|
+
return { path: target, action: "create", kind, content };
|
|
398
|
+
return {
|
|
399
|
+
path: target,
|
|
400
|
+
action: fs.readFileSync(target, "utf8") === content ? "noop" : "update",
|
|
401
|
+
kind,
|
|
402
|
+
content,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function walkFiles(root) {
|
|
406
|
+
const files = [];
|
|
407
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
408
|
+
const full = path.join(root, entry.name);
|
|
409
|
+
if (entry.isSymbolicLink())
|
|
410
|
+
throw new Error(`Refusing package symlink: ${full}`);
|
|
411
|
+
if (entry.isDirectory())
|
|
412
|
+
files.push(...walkFiles(full));
|
|
413
|
+
else if (entry.isFile())
|
|
414
|
+
files.push(full);
|
|
415
|
+
}
|
|
416
|
+
return files.sort();
|
|
417
|
+
}
|
|
418
|
+
function reportFor(command, loaded, target, apply, planned) {
|
|
419
|
+
const { manifest } = loaded;
|
|
420
|
+
return {
|
|
421
|
+
command,
|
|
422
|
+
package: manifest.name,
|
|
423
|
+
packageVersion: loaded.packageVersion,
|
|
424
|
+
manifestVersion: manifest.manifestVersion,
|
|
425
|
+
targetRoot: target.root,
|
|
426
|
+
layout: target.layout,
|
|
427
|
+
apply,
|
|
428
|
+
compatible: planned.collisions.length === 0,
|
|
429
|
+
contributions: {
|
|
430
|
+
actions: manifest.actions,
|
|
431
|
+
schemaEntryPoint: manifest.schemaEntryPoint,
|
|
432
|
+
skills: manifest.docs.skills,
|
|
433
|
+
requiredSecretKeys: manifest.requiredSecrets.map((secret) => secret.key),
|
|
434
|
+
peerProviders: manifest.peerProviders,
|
|
435
|
+
},
|
|
436
|
+
changes: planned.changes.map(({ path: file, action, kind }) => ({
|
|
437
|
+
path: relative(target.root, file),
|
|
438
|
+
action,
|
|
439
|
+
kind,
|
|
440
|
+
})),
|
|
441
|
+
collisions: planned.collisions,
|
|
442
|
+
warnings: planned.warnings,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function formatReport(report) {
|
|
446
|
+
const lines = [
|
|
447
|
+
`# ${report.command} ${report.package}@${report.packageVersion}`,
|
|
448
|
+
`Manifest: v${report.manifestVersion}`,
|
|
449
|
+
`Target: ${report.targetRoot} (${report.layout})`,
|
|
450
|
+
`Mode: ${report.apply ? "apply" : "dry-run"}`,
|
|
451
|
+
`Compatible: ${report.compatible ? "yes" : "no"}`,
|
|
452
|
+
"",
|
|
453
|
+
`Actions: ${report.contributions.actions.length}`,
|
|
454
|
+
`Schema: ${report.contributions.schemaEntryPoint}`,
|
|
455
|
+
`Skills: ${report.contributions.skills.join(", ") || "none"}`,
|
|
456
|
+
`Required secret keys: ${report.contributions.requiredSecretKeys.join(", ") || "none"}`,
|
|
457
|
+
`Peer providers: ${report.contributions.peerProviders.join(", ") || "none"}`,
|
|
458
|
+
"",
|
|
459
|
+
"Changes:",
|
|
460
|
+
...report.changes.map((change) => ` ${change.action.padEnd(6)} ${change.path} (${change.kind})`),
|
|
461
|
+
];
|
|
462
|
+
if (report.collisions.length) {
|
|
463
|
+
lines.push("", "Collisions:", ...report.collisions.map((item) => ` - ${item}`));
|
|
464
|
+
}
|
|
465
|
+
if (report.warnings.length) {
|
|
466
|
+
lines.push("", "Notes:", ...report.warnings.map((item) => ` - ${item}`));
|
|
467
|
+
}
|
|
468
|
+
if (!report.apply && report.command !== "inspect") {
|
|
469
|
+
lines.push("", "Dry-run only. Re-run with --apply to write these changes.");
|
|
470
|
+
}
|
|
471
|
+
return lines.join("\n");
|
|
472
|
+
}
|
|
473
|
+
async function applyTransaction(root, changes, spawn) {
|
|
474
|
+
const stage = fs.mkdtempSync(path.join(root, ".agent-native-package-stage-"));
|
|
475
|
+
const snapshots = new Map();
|
|
476
|
+
const installRoot = findPackageManagerRoot(root);
|
|
477
|
+
const lockfiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock"].map((name) => path.join(installRoot, name));
|
|
478
|
+
try {
|
|
479
|
+
for (const change of changes) {
|
|
480
|
+
snapshots.set(change.path, fs.existsSync(change.path) ? fs.readFileSync(change.path) : null);
|
|
481
|
+
const staged = path.join(stage, String(snapshots.size));
|
|
482
|
+
fs.writeFileSync(staged, change.content);
|
|
483
|
+
}
|
|
484
|
+
for (const lockfile of lockfiles) {
|
|
485
|
+
snapshots.set(lockfile, fs.existsSync(lockfile) ? fs.readFileSync(lockfile) : null);
|
|
486
|
+
}
|
|
487
|
+
let index = 0;
|
|
488
|
+
for (const change of changes) {
|
|
489
|
+
index += 1;
|
|
490
|
+
fs.mkdirSync(path.dirname(change.path), { recursive: true });
|
|
491
|
+
fs.renameSync(path.join(stage, String(index)), change.path);
|
|
492
|
+
}
|
|
493
|
+
const packageManager = detectPackageManager(installRoot);
|
|
494
|
+
const result = spawn(packageManager, ["install"], {
|
|
495
|
+
cwd: installRoot,
|
|
496
|
+
stdio: "inherit",
|
|
497
|
+
});
|
|
498
|
+
if (result.status !== 0) {
|
|
499
|
+
throw new Error(`${packageManager} install failed with status ${result.status}`);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
for (const [file, snapshot] of [...snapshots.entries()].reverse()) {
|
|
504
|
+
if (snapshot === null)
|
|
505
|
+
fs.rmSync(file, { force: true, recursive: true });
|
|
506
|
+
else {
|
|
507
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
508
|
+
fs.writeFileSync(file, snapshot);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
for (const change of [...changes].reverse()) {
|
|
512
|
+
removeEmptyParents(path.dirname(change.path), root);
|
|
513
|
+
}
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
finally {
|
|
517
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function removeEmptyParents(directory, stop) {
|
|
521
|
+
let current = directory;
|
|
522
|
+
const boundary = path.resolve(stop);
|
|
523
|
+
while (current.startsWith(`${boundary}${path.sep}`)) {
|
|
524
|
+
try {
|
|
525
|
+
if (fs.readdirSync(current).length > 0)
|
|
526
|
+
return;
|
|
527
|
+
fs.rmdirSync(current);
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
current = path.dirname(current);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function detectPackageManager(root) {
|
|
536
|
+
if (fs.existsSync(path.join(root, "pnpm-lock.yaml")))
|
|
537
|
+
return "pnpm";
|
|
538
|
+
if (fs.existsSync(path.join(root, "yarn.lock")))
|
|
539
|
+
return "yarn";
|
|
540
|
+
return "npm";
|
|
541
|
+
}
|
|
542
|
+
function findPackageManagerRoot(from) {
|
|
543
|
+
let dir = from;
|
|
544
|
+
while (true) {
|
|
545
|
+
if (fs.existsSync(path.join(dir, "pnpm-lock.yaml")) ||
|
|
546
|
+
fs.existsSync(path.join(dir, "yarn.lock")) ||
|
|
547
|
+
fs.existsSync(path.join(dir, "package-lock.json"))) {
|
|
548
|
+
return dir;
|
|
549
|
+
}
|
|
550
|
+
const parent = path.dirname(dir);
|
|
551
|
+
if (parent === dir)
|
|
552
|
+
return from;
|
|
553
|
+
dir = parent;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function relative(root, file) {
|
|
557
|
+
const value = path.relative(root, file);
|
|
558
|
+
return value || ".";
|
|
559
|
+
}
|
|
560
|
+
//# sourceMappingURL=package-lifecycle.js.map
|