@agent-native/core 0.95.1 → 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 +64 -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 +11 -2
- package/corpus/core/src/a2a/auth-policy.ts +33 -0
- package/corpus/core/src/a2a/client.ts +11 -1
- package/corpus/core/src/agent/durable-background.ts +15 -7
- package/corpus/core/src/agent/production-agent.ts +87 -27
- package/corpus/core/src/agent/run-store.ts +13 -4
- package/corpus/core/src/agent/thread-data-builder.ts +7 -5
- 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/chat-threads/store.ts +20 -1
- package/corpus/core/src/cli/code-agent-executor.ts +1 -0
- package/corpus/core/src/cli/code-agent-runs.ts +14 -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/AgentPanel.tsx +32 -25
- package/corpus/core/src/client/AssistantChat.tsx +36 -20
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +141 -90
- package/corpus/core/src/client/agent-chat-adapter.ts +9 -9
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +404 -0
- package/corpus/core/src/client/chat/index.ts +6 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +37 -3
- package/corpus/core/src/client/code-agent-chat-adapter.ts +72 -4
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +52 -11
- package/corpus/core/src/client/composer/TiptapComposer.tsx +157 -20
- package/corpus/core/src/client/composer/VoiceButton.tsx +28 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +5 -0
- package/corpus/core/src/client/conversation/code-agent-transcript.ts +4 -5
- package/corpus/core/src/client/guided-questions.tsx +2 -1
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/client/use-chat-threads.ts +10 -1
- package/corpus/core/src/client/voice-provider-status.ts +44 -0
- package/corpus/core/src/code-agents/transcript-normalizer.ts +76 -0
- package/corpus/core/src/deploy/build.ts +12 -11
- 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/integrations/a2a-continuation-processor.ts +35 -5
- package/corpus/core/src/integrations/adapters/slack.ts +74 -21
- package/corpus/core/src/integrations/webhook-handler.ts +14 -0
- package/corpus/core/src/localization/default-messages.ts +6 -0
- package/corpus/core/src/observability/hosted-model-experiment.ts +118 -0
- package/corpus/core/src/observability/routes.ts +17 -0
- package/corpus/core/src/observability/store.ts +4 -1
- package/corpus/core/src/observability/traces.ts +41 -2
- 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/scripts/agent-engines/list-agent-engines.ts +19 -1
- package/corpus/core/src/scripts/call-agent.ts +53 -3
- package/corpus/core/src/scripts/chat/search-chats.ts +11 -8
- package/corpus/core/src/secrets/register-framework-secrets.ts +1 -1
- 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 +95 -18
- package/corpus/core/src/server/core-routes-plugin.ts +45 -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 +80 -24
- package/corpus/core/src/server/request-origin.ts +63 -0
- package/corpus/core/src/server/transcribe-voice.ts +1 -50
- package/corpus/core/src/server/voice-providers-status.ts +4 -3
- package/corpus/core/src/shared/cache-control.ts +2 -8
- package/corpus/core/src/styles/agent-native.css +1 -0
- package/corpus/core/src/styles/chat-history-list.css +313 -0
- 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/.agents/skills/observability/SKILL.md +20 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- 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/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/AGENTS.md +7 -0
- package/corpus/templates/analytics/actions/bigquery.ts +26 -2
- package/corpus/templates/analytics/actions/compose-dashboard.ts +65 -37
- package/corpus/templates/analytics/actions/data-source-status.ts +18 -0
- 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/app/components/layout/Sidebar.tsx +5 -4
- package/corpus/templates/analytics/app/global.css +10 -0
- package/corpus/templates/analytics/app/pages/Ask.tsx +25 -2
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-answers-simple-time-bounded-metrics-without-unnece.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-chat-reliably-uses-connected-data-sources-across-s.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-chat-threads-now-stay-clear-of-top-actions-and-fade-smoothly.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-context-chips-can-now-be-selected-and-removed-one-at-a-time-.md +6 -0
- 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-the-ask-composer-no-longer-carries-dashboard-or-panel-contex.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-section-stays-highlighted-while-its-chat-history-is-.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 +91 -14
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +154 -11
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +82 -7
- 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/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +2 -1
- package/dist/a2a/client.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/production-agent.d.ts +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +63 -26
- package/dist/agent/production-agent.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/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +6 -5
- package/dist/agent/thread-data-builder.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/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +6 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +1 -0
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +12 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +1 -0
- package/dist/cli/code-agent-runs.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/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +3 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +11 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +7 -4
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +83 -10
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.js +7 -3
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +88 -0
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -0
- package/dist/client/chat/ChatHistoryList.js +83 -0
- package/dist/client/chat/ChatHistoryList.js.map +1 -0
- package/dist/client/chat/index.d.ts +1 -0
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +1 -0
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +13 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +10 -2
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/code-agent-chat-adapter.d.ts +17 -1
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +47 -3
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +11 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +5 -3
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +25 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +96 -5
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +21 -1
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/conversation/code-agent-transcript.d.ts +2 -0
- package/dist/client/conversation/code-agent-transcript.d.ts.map +1 -1
- package/dist/client/conversation/code-agent-transcript.js +3 -5
- package/dist/client/conversation/code-agent-transcript.js.map +1 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +2 -1
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +9 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/voice-provider-status.d.ts +10 -0
- package/dist/client/voice-provider-status.d.ts.map +1 -0
- package/dist/client/voice-provider-status.js +32 -0
- package/dist/client/voice-provider-status.js.map +1 -0
- package/dist/code-agents/transcript-normalizer.d.ts +29 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +55 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +13 -11
- package/dist/deploy/build.js.map +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/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +25 -5
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +55 -21
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +11 -0
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +5 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +5 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/hosted-model-experiment.d.ts +39 -0
- package/dist/observability/hosted-model-experiment.d.ts.map +1 -0
- package/dist/observability/hosted-model-experiment.js +90 -0
- package/dist/observability/hosted-model-experiment.js.map +1 -0
- package/dist/observability/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +16 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +4 -1
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +6 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +28 -2
- package/dist/observability/traces.js.map +1 -1
- 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/resources/handlers.d.ts +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +19 -1
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +43 -3
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +11 -8
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/secrets/register-framework-secrets.js +1 -1
- package/dist/secrets/register-framework-secrets.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 +11 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +74 -19
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/core-routes-plugin.d.ts +3 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +36 -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 +64 -21
- 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/server/voice-providers-status.d.ts.map +1 -1
- package/dist/server/voice-providers-status.js +2 -3
- package/dist/server/voice-providers-status.js.map +1 -1
- package/dist/shared/cache-control.d.ts +4 -6
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +2 -7
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/chat-history-list.css +313 -0
- 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/.agents/skills/observability/SKILL.md +20 -0
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- 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/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.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 +12 -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/.agents/skills/observability/SKILL.md +20 -0
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- 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,821 @@
|
|
|
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
|
+
|
|
6
|
+
import {
|
|
7
|
+
assertAgentNativePackageManifest,
|
|
8
|
+
type AgentNativePackageManifest,
|
|
9
|
+
} from "../package-lifecycle/manifest.js";
|
|
10
|
+
|
|
11
|
+
export interface PackageLifecycleIO {
|
|
12
|
+
out(message: string): void;
|
|
13
|
+
err(message: string): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LoadedLifecyclePackage {
|
|
17
|
+
manifest: AgentNativePackageManifest;
|
|
18
|
+
packageVersion: string;
|
|
19
|
+
packageDir: string;
|
|
20
|
+
packageJson: Record<string, unknown>;
|
|
21
|
+
cleanup?: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PackageLifecycleRuntime {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
io?: PackageLifecycleIO;
|
|
27
|
+
loadPackage?: (name: string, cwd: string) => Promise<LoadedLifecyclePackage>;
|
|
28
|
+
spawn?: typeof spawnSync;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface Change {
|
|
32
|
+
path: string;
|
|
33
|
+
action: "create" | "update" | "noop";
|
|
34
|
+
kind:
|
|
35
|
+
| "dependency"
|
|
36
|
+
| "action"
|
|
37
|
+
| "schema"
|
|
38
|
+
| "skill"
|
|
39
|
+
| "provenance"
|
|
40
|
+
| "eject"
|
|
41
|
+
| "workspace";
|
|
42
|
+
content?: string | Buffer;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PackageLifecycleReport {
|
|
46
|
+
command: "inspect" | "add" | "eject";
|
|
47
|
+
package: string;
|
|
48
|
+
packageVersion: string;
|
|
49
|
+
manifestVersion: number;
|
|
50
|
+
targetRoot: string;
|
|
51
|
+
layout: "standalone" | "workspace-app" | "workspace-root";
|
|
52
|
+
apply: boolean;
|
|
53
|
+
compatible: boolean;
|
|
54
|
+
contributions: {
|
|
55
|
+
actions: string[];
|
|
56
|
+
schemaEntryPoint: string;
|
|
57
|
+
skills: string[];
|
|
58
|
+
requiredSecretKeys: string[];
|
|
59
|
+
peerProviders: string[];
|
|
60
|
+
};
|
|
61
|
+
changes: Array<Omit<Change, "content">>;
|
|
62
|
+
collisions: string[];
|
|
63
|
+
warnings: string[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const defaultIO: PackageLifecycleIO = {
|
|
67
|
+
out: (message) => console.log(message),
|
|
68
|
+
err: (message) => console.error(message),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export async function runPackageLifecycle(
|
|
72
|
+
args: string[],
|
|
73
|
+
runtime: PackageLifecycleRuntime = {},
|
|
74
|
+
): Promise<number> {
|
|
75
|
+
const io = runtime.io ?? defaultIO;
|
|
76
|
+
const command = args[0];
|
|
77
|
+
const packageName = args[1];
|
|
78
|
+
if (!isCommand(command) || !packageName) {
|
|
79
|
+
io.err(packageLifecycleUsage());
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
const json = args.includes("--json");
|
|
83
|
+
const apply = args.includes("--apply");
|
|
84
|
+
if (apply && command === "inspect") {
|
|
85
|
+
io.err("package inspect is always read-only; remove --apply");
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
const cwd = path.resolve(
|
|
89
|
+
flagValue(args, "--root") ?? runtime.cwd ?? process.cwd(),
|
|
90
|
+
);
|
|
91
|
+
let loaded: LoadedLifecyclePackage | undefined;
|
|
92
|
+
try {
|
|
93
|
+
loaded = await (runtime.loadPackage
|
|
94
|
+
? runtime.loadPackage(packageName, cwd)
|
|
95
|
+
: loadLifecyclePackage(packageName, cwd, runtime.spawn ?? spawnSync));
|
|
96
|
+
if (loaded.manifest.name !== packageName) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`Manifest name ${loaded.manifest.name} does not match requested package ${packageName}`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
const target = resolveTarget(cwd, flagValue(args, "--app"));
|
|
102
|
+
const planned =
|
|
103
|
+
command === "eject"
|
|
104
|
+
? planEject(loaded, target.root, target.layout)
|
|
105
|
+
: planAdd(loaded, target.root, target.layout, command === "inspect");
|
|
106
|
+
const report = reportFor(command, loaded, target, apply, planned);
|
|
107
|
+
if (report.collisions.length > 0) {
|
|
108
|
+
report.compatible = false;
|
|
109
|
+
}
|
|
110
|
+
if (json) io.out(JSON.stringify(report, null, 2));
|
|
111
|
+
else io.out(formatReport(report));
|
|
112
|
+
if (!report.compatible) return 1;
|
|
113
|
+
if (command === "inspect" || !apply) return 0;
|
|
114
|
+
|
|
115
|
+
await applyTransaction(
|
|
116
|
+
target.root,
|
|
117
|
+
planned.changes.filter((change) => change.action !== "noop"),
|
|
118
|
+
runtime.spawn ?? spawnSync,
|
|
119
|
+
);
|
|
120
|
+
return 0;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
io.err(error instanceof Error ? error.message : String(error));
|
|
123
|
+
return 1;
|
|
124
|
+
} finally {
|
|
125
|
+
loaded?.cleanup?.();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function isCommand(
|
|
130
|
+
value: string | undefined,
|
|
131
|
+
): value is "inspect" | "add" | "eject" {
|
|
132
|
+
return value === "inspect" || value === "add" || value === "eject";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function flagValue(args: string[], name: string): string | undefined {
|
|
136
|
+
const index = args.indexOf(name);
|
|
137
|
+
return index >= 0 ? args[index + 1] : undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function packageLifecycleUsage(): string {
|
|
141
|
+
return [
|
|
142
|
+
"Usage:",
|
|
143
|
+
" agent-native package inspect <package> [--root <dir>] [--app <name>] [--json]",
|
|
144
|
+
" agent-native package add <package> [--root <dir>] [--app <name>] [--apply] [--json]",
|
|
145
|
+
" agent-native package eject <package> [--root <dir>] [--app <name>] [--apply] [--json]",
|
|
146
|
+
"",
|
|
147
|
+
"add and eject are dry-run by default; pass --apply to write and run the package manager.",
|
|
148
|
+
].join("\n");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export async function loadLifecyclePackage(
|
|
152
|
+
name: string,
|
|
153
|
+
cwd: string,
|
|
154
|
+
spawn: typeof spawnSync = spawnSync,
|
|
155
|
+
): Promise<LoadedLifecyclePackage> {
|
|
156
|
+
const packageJsonPath = findInstalledPackageJson(name, cwd);
|
|
157
|
+
if (packageJsonPath) {
|
|
158
|
+
return loadStaticPackageDirectory(name, path.dirname(packageJsonPath));
|
|
159
|
+
}
|
|
160
|
+
if (!/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name)) {
|
|
161
|
+
throw new Error(`Invalid package name: ${name}`);
|
|
162
|
+
}
|
|
163
|
+
const stage = fs.mkdtempSync(
|
|
164
|
+
path.join(os.tmpdir(), "agent-native-package-inspect-"),
|
|
165
|
+
);
|
|
166
|
+
try {
|
|
167
|
+
const packed = spawn(
|
|
168
|
+
"npm",
|
|
169
|
+
["pack", name, "--ignore-scripts", "--json", "--pack-destination", stage],
|
|
170
|
+
{ cwd, encoding: "utf8", stdio: "pipe" },
|
|
171
|
+
);
|
|
172
|
+
if (packed.status !== 0) {
|
|
173
|
+
throw new Error(`Unable to download package metadata for '${name}'`);
|
|
174
|
+
}
|
|
175
|
+
const entries = JSON.parse(String(packed.stdout || "[]")) as Array<{
|
|
176
|
+
filename?: string;
|
|
177
|
+
}>;
|
|
178
|
+
const filename = entries[0]?.filename;
|
|
179
|
+
if (!filename || path.basename(filename) !== filename) {
|
|
180
|
+
throw new Error(
|
|
181
|
+
`npm pack returned an invalid archive name for '${name}'`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const archive = path.join(stage, filename);
|
|
185
|
+
const listed = spawn("tar", ["-tzf", archive], {
|
|
186
|
+
cwd,
|
|
187
|
+
encoding: "utf8",
|
|
188
|
+
stdio: "pipe",
|
|
189
|
+
});
|
|
190
|
+
if (listed.status !== 0) {
|
|
191
|
+
throw new Error(`Unable to list package archive for '${name}'`);
|
|
192
|
+
}
|
|
193
|
+
const archiveEntries = String(listed.stdout || "")
|
|
194
|
+
.split(/\r?\n/)
|
|
195
|
+
.filter(Boolean);
|
|
196
|
+
if (
|
|
197
|
+
archiveEntries.length === 0 ||
|
|
198
|
+
archiveEntries.some(
|
|
199
|
+
(entry) =>
|
|
200
|
+
entry.includes("\\") ||
|
|
201
|
+
entry.startsWith("/") ||
|
|
202
|
+
!entry.startsWith("package/") ||
|
|
203
|
+
entry.split("/").includes(".."),
|
|
204
|
+
)
|
|
205
|
+
) {
|
|
206
|
+
throw new Error(`Package archive for '${name}' contains an unsafe path`);
|
|
207
|
+
}
|
|
208
|
+
const extracted = spawn(
|
|
209
|
+
"tar",
|
|
210
|
+
[
|
|
211
|
+
"-xzf",
|
|
212
|
+
archive,
|
|
213
|
+
"-C",
|
|
214
|
+
stage,
|
|
215
|
+
"--no-same-owner",
|
|
216
|
+
"--no-same-permissions",
|
|
217
|
+
],
|
|
218
|
+
{
|
|
219
|
+
cwd,
|
|
220
|
+
encoding: "utf8",
|
|
221
|
+
stdio: "pipe",
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
if (extracted.status !== 0) {
|
|
225
|
+
throw new Error(`Unable to inspect package archive for '${name}'`);
|
|
226
|
+
}
|
|
227
|
+
const loaded = loadStaticPackageDirectory(
|
|
228
|
+
name,
|
|
229
|
+
path.join(stage, "package"),
|
|
230
|
+
);
|
|
231
|
+
loaded.cleanup = () => fs.rmSync(stage, { recursive: true, force: true });
|
|
232
|
+
return loaded;
|
|
233
|
+
} catch (error) {
|
|
234
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function loadStaticPackageDirectory(
|
|
240
|
+
name: string,
|
|
241
|
+
packageDir: string,
|
|
242
|
+
): LoadedLifecyclePackage {
|
|
243
|
+
const packageJsonPath = path.join(packageDir, "package.json");
|
|
244
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")) as {
|
|
245
|
+
name?: string;
|
|
246
|
+
version?: string;
|
|
247
|
+
agentNativeManifest?: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
};
|
|
250
|
+
if (packageJson.name !== name) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Installed package name ${String(packageJson.name)} does not match ${name}`,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
if (!packageJson.version) {
|
|
256
|
+
throw new Error(`Package '${name}' has no version`);
|
|
257
|
+
}
|
|
258
|
+
if (
|
|
259
|
+
!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(
|
|
260
|
+
packageJson.version,
|
|
261
|
+
)
|
|
262
|
+
) {
|
|
263
|
+
throw new Error(`Package '${name}' has an invalid version`);
|
|
264
|
+
}
|
|
265
|
+
const relativeManifest = packageJson.agentNativeManifest;
|
|
266
|
+
if (!relativeManifest || path.isAbsolute(relativeManifest)) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Package '${name}' does not declare a static agentNativeManifest`,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
const manifestPath = path.resolve(packageDir, relativeManifest);
|
|
272
|
+
if (
|
|
273
|
+
manifestPath !== packageDir &&
|
|
274
|
+
!manifestPath.startsWith(`${path.resolve(packageDir)}${path.sep}`)
|
|
275
|
+
) {
|
|
276
|
+
throw new Error(`Package '${name}' manifest escapes the package directory`);
|
|
277
|
+
}
|
|
278
|
+
const manifestStat = fs.lstatSync(manifestPath);
|
|
279
|
+
if (!manifestStat.isFile() || manifestStat.isSymbolicLink()) {
|
|
280
|
+
throw new Error(`Package '${name}' static manifest must be a regular file`);
|
|
281
|
+
}
|
|
282
|
+
const realPackageDir = fs.realpathSync(packageDir);
|
|
283
|
+
const realManifestPath = fs.realpathSync(manifestPath);
|
|
284
|
+
if (!realManifestPath.startsWith(`${realPackageDir}${path.sep}`)) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`Package '${name}' static manifest escapes the package directory`,
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
290
|
+
assertAgentNativePackageManifest(manifest);
|
|
291
|
+
if (manifest.name !== name) {
|
|
292
|
+
throw new Error(`Manifest name ${manifest.name} does not match ${name}`);
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
manifest,
|
|
296
|
+
packageVersion: packageJson.version,
|
|
297
|
+
packageDir,
|
|
298
|
+
packageJson,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function findInstalledPackageJson(name: string, from: string): string | null {
|
|
303
|
+
let dir = from;
|
|
304
|
+
while (true) {
|
|
305
|
+
const candidate = path.join(dir, "node_modules", name, "package.json");
|
|
306
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
307
|
+
const parent = path.dirname(dir);
|
|
308
|
+
if (parent === dir) return null;
|
|
309
|
+
dir = parent;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function resolveTarget(
|
|
314
|
+
root: string,
|
|
315
|
+
appName?: string,
|
|
316
|
+
): { root: string; layout: PackageLifecycleReport["layout"] } {
|
|
317
|
+
const packageJsonPath = path.join(root, "package.json");
|
|
318
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
319
|
+
throw new Error(`Target root has no package.json: ${root}`);
|
|
320
|
+
}
|
|
321
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
322
|
+
const workspace =
|
|
323
|
+
typeof pkg?.["agent-native"]?.workspaceCore === "string" &&
|
|
324
|
+
fs.existsSync(path.join(root, "apps"));
|
|
325
|
+
if (!workspace) return { root, layout: "standalone" };
|
|
326
|
+
if (!appName) {
|
|
327
|
+
return { root, layout: "workspace-root" };
|
|
328
|
+
}
|
|
329
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(appName)) {
|
|
330
|
+
throw new Error(`Invalid workspace app name: ${appName}`);
|
|
331
|
+
}
|
|
332
|
+
const appRoot = path.join(root, "apps", appName);
|
|
333
|
+
if (!fs.existsSync(path.join(appRoot, "package.json"))) {
|
|
334
|
+
throw new Error(`Workspace app not found: ${appRoot}`);
|
|
335
|
+
}
|
|
336
|
+
return { root: appRoot, layout: "workspace-app" };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function planAdd(
|
|
340
|
+
loaded: LoadedLifecyclePackage,
|
|
341
|
+
targetRoot: string,
|
|
342
|
+
layout: PackageLifecycleReport["layout"],
|
|
343
|
+
inspectOnly: boolean,
|
|
344
|
+
): { changes: Change[]; collisions: string[]; warnings: string[] } {
|
|
345
|
+
const { manifest, packageDir } = loaded;
|
|
346
|
+
const collisions: string[] = [];
|
|
347
|
+
const warnings: string[] = [];
|
|
348
|
+
if (layout === "workspace-root") {
|
|
349
|
+
collisions.push("Workspace root is ambiguous; pass --app <name> for add");
|
|
350
|
+
return { changes: [], collisions, warnings };
|
|
351
|
+
}
|
|
352
|
+
const packageJsonPath = path.join(targetRoot, "package.json");
|
|
353
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
354
|
+
pkg.dependencies ??= {};
|
|
355
|
+
const wantedRange = `^${loaded.packageVersion}`;
|
|
356
|
+
const currentRange = pkg.dependencies[manifest.name];
|
|
357
|
+
if (currentRange !== wantedRange && currentRange !== "workspace:*") {
|
|
358
|
+
pkg.dependencies[manifest.name] = wantedRange;
|
|
359
|
+
}
|
|
360
|
+
const changes: Change[] = [
|
|
361
|
+
textChange(
|
|
362
|
+
targetRoot,
|
|
363
|
+
packageJsonPath,
|
|
364
|
+
`${JSON.stringify(pkg, null, 2)}\n`,
|
|
365
|
+
"dependency",
|
|
366
|
+
),
|
|
367
|
+
];
|
|
368
|
+
for (const action of manifest.actions) {
|
|
369
|
+
const target = path.join(targetRoot, "actions", `${action}.ts`);
|
|
370
|
+
const content = `export { default } from "${manifest.name}/actions/${action}";\n`;
|
|
371
|
+
changes.push(
|
|
372
|
+
collisionCheckedText(targetRoot, target, content, "action", collisions),
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const schemaPath = path.join(targetRoot, "server", "db", "schema.ts");
|
|
377
|
+
if (!fs.existsSync(schemaPath)) {
|
|
378
|
+
collisions.push(
|
|
379
|
+
`Required schema file is missing: ${relative(targetRoot, schemaPath)}`,
|
|
380
|
+
);
|
|
381
|
+
} else {
|
|
382
|
+
const current = fs.readFileSync(schemaPath, "utf8");
|
|
383
|
+
const marker = `// agent-native-package:${manifest.name}`;
|
|
384
|
+
const contribution = `${marker}\nexport * from "${manifest.schemaEntryPoint}";`;
|
|
385
|
+
if (current.includes(marker) && !current.includes(contribution)) {
|
|
386
|
+
collisions.push(
|
|
387
|
+
"Existing package-owned schema block has unexpected content",
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
const next = current.includes(contribution)
|
|
391
|
+
? current
|
|
392
|
+
: `${current.trimEnd()}\n\n${contribution}\n`;
|
|
393
|
+
changes.push(textChange(targetRoot, schemaPath, next, "schema"));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const ownedPaths: string[] = [];
|
|
397
|
+
for (const skill of manifest.docs.skills) {
|
|
398
|
+
const source = path.join(packageDir, "docs", "skills", skill);
|
|
399
|
+
if (!fs.existsSync(source)) {
|
|
400
|
+
collisions.push(`Manifest skill source is missing: docs/skills/${skill}`);
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
for (const sourceFile of walkFiles(source)) {
|
|
404
|
+
const target = path.join(
|
|
405
|
+
targetRoot,
|
|
406
|
+
".agents",
|
|
407
|
+
"skills",
|
|
408
|
+
skill,
|
|
409
|
+
path.relative(source, sourceFile),
|
|
410
|
+
);
|
|
411
|
+
changes.push(
|
|
412
|
+
collisionCheckedBuffer(
|
|
413
|
+
targetRoot,
|
|
414
|
+
target,
|
|
415
|
+
fs.readFileSync(sourceFile),
|
|
416
|
+
"skill",
|
|
417
|
+
collisions,
|
|
418
|
+
),
|
|
419
|
+
);
|
|
420
|
+
ownedPaths.push(relative(targetRoot, target));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const provenancePath = path.join(
|
|
424
|
+
targetRoot,
|
|
425
|
+
".agent-native",
|
|
426
|
+
"packages",
|
|
427
|
+
`${manifest.name.replaceAll("/", "__")}.json`,
|
|
428
|
+
);
|
|
429
|
+
const provenance = {
|
|
430
|
+
manifestVersion: manifest.manifestVersion,
|
|
431
|
+
package: manifest.name,
|
|
432
|
+
version: loaded.packageVersion,
|
|
433
|
+
actions: manifest.actions,
|
|
434
|
+
schemaEntryPoint: manifest.schemaEntryPoint,
|
|
435
|
+
skills: manifest.docs.skills,
|
|
436
|
+
files: ownedPaths.sort(),
|
|
437
|
+
};
|
|
438
|
+
changes.push(
|
|
439
|
+
textChange(
|
|
440
|
+
targetRoot,
|
|
441
|
+
provenancePath,
|
|
442
|
+
`${JSON.stringify(provenance, null, 2)}\n`,
|
|
443
|
+
"provenance",
|
|
444
|
+
),
|
|
445
|
+
);
|
|
446
|
+
if (inspectOnly)
|
|
447
|
+
warnings.push("inspect is read-only; shown changes are the add plan");
|
|
448
|
+
return { changes, collisions, warnings };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function planEject(
|
|
452
|
+
loaded: LoadedLifecyclePackage,
|
|
453
|
+
targetRoot: string,
|
|
454
|
+
layout: PackageLifecycleReport["layout"],
|
|
455
|
+
): { changes: Change[]; collisions: string[]; warnings: string[] } {
|
|
456
|
+
const collisions: string[] = [];
|
|
457
|
+
const warnings: string[] = [];
|
|
458
|
+
if (loaded.manifest.name !== "@agent-native/scheduling") {
|
|
459
|
+
collisions.push("Eject currently supports only @agent-native/scheduling");
|
|
460
|
+
return { changes: [], collisions, warnings };
|
|
461
|
+
}
|
|
462
|
+
if (!loaded.manifest.eject) {
|
|
463
|
+
collisions.push("Package manifest does not declare eject metadata");
|
|
464
|
+
return { changes: [], collisions, warnings };
|
|
465
|
+
}
|
|
466
|
+
const workspaceRoot =
|
|
467
|
+
layout === "workspace-app" ? path.resolve(targetRoot, "../..") : targetRoot;
|
|
468
|
+
const pnpmWorkspace = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
469
|
+
if (!fs.existsSync(pnpmWorkspace)) {
|
|
470
|
+
collisions.push(
|
|
471
|
+
"Eject currently requires an existing pnpm workspace; refusing to create a workspace:* dependency for another package manager",
|
|
472
|
+
);
|
|
473
|
+
return { changes: [], collisions, warnings };
|
|
474
|
+
}
|
|
475
|
+
const targetDir = path.join(
|
|
476
|
+
workspaceRoot,
|
|
477
|
+
loaded.manifest.eject.targetDirectory,
|
|
478
|
+
);
|
|
479
|
+
if (fs.existsSync(targetDir)) {
|
|
480
|
+
collisions.push(
|
|
481
|
+
`Eject target already exists: ${relative(workspaceRoot, targetDir)}`,
|
|
482
|
+
);
|
|
483
|
+
return { changes: [], collisions, warnings };
|
|
484
|
+
}
|
|
485
|
+
const sourceRoot = path.join(
|
|
486
|
+
loaded.packageDir,
|
|
487
|
+
loaded.manifest.eject.sourceRoot,
|
|
488
|
+
);
|
|
489
|
+
if (!fs.existsSync(sourceRoot)) {
|
|
490
|
+
collisions.push(
|
|
491
|
+
`Published eject source is missing: ${loaded.manifest.eject.sourceRoot}`,
|
|
492
|
+
);
|
|
493
|
+
return { changes: [], collisions, warnings };
|
|
494
|
+
}
|
|
495
|
+
const changes: Change[] = [];
|
|
496
|
+
for (const source of walkFiles(sourceRoot)) {
|
|
497
|
+
const target = path.join(
|
|
498
|
+
targetDir,
|
|
499
|
+
"src",
|
|
500
|
+
path.relative(sourceRoot, source),
|
|
501
|
+
);
|
|
502
|
+
changes.push({
|
|
503
|
+
path: target,
|
|
504
|
+
action: "create",
|
|
505
|
+
kind: "eject",
|
|
506
|
+
content: fs.readFileSync(source),
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
for (const name of ["tsconfig.json", "agent-native.package.json"]) {
|
|
510
|
+
const source = path.join(loaded.packageDir, name);
|
|
511
|
+
if (fs.existsSync(source)) {
|
|
512
|
+
changes.push({
|
|
513
|
+
path: path.join(targetDir, name),
|
|
514
|
+
action: "create",
|
|
515
|
+
kind: "eject",
|
|
516
|
+
content: fs.readFileSync(source),
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
changes.push({
|
|
521
|
+
path: path.join(targetDir, "package.json"),
|
|
522
|
+
action: "create",
|
|
523
|
+
kind: "eject",
|
|
524
|
+
content: `${JSON.stringify(
|
|
525
|
+
normalizeEjectedPackageJson(loaded.packageJson, workspaceRoot),
|
|
526
|
+
null,
|
|
527
|
+
2,
|
|
528
|
+
)}\n`,
|
|
529
|
+
});
|
|
530
|
+
const consumerPackageJson = path.join(targetRoot, "package.json");
|
|
531
|
+
const consumer = JSON.parse(fs.readFileSync(consumerPackageJson, "utf8"));
|
|
532
|
+
consumer.dependencies ??= {};
|
|
533
|
+
consumer.dependencies[loaded.manifest.name] = "workspace:*";
|
|
534
|
+
changes.push(
|
|
535
|
+
textChange(
|
|
536
|
+
workspaceRoot,
|
|
537
|
+
consumerPackageJson,
|
|
538
|
+
`${JSON.stringify(consumer, null, 2)}\n`,
|
|
539
|
+
"dependency",
|
|
540
|
+
),
|
|
541
|
+
);
|
|
542
|
+
if (fs.existsSync(pnpmWorkspace)) {
|
|
543
|
+
const text = fs.readFileSync(pnpmWorkspace, "utf8");
|
|
544
|
+
if (!text.includes("packages/*") && !text.includes("packages/**")) {
|
|
545
|
+
collisions.push(
|
|
546
|
+
"pnpm-workspace.yaml does not include packages/*; refusing to rewrite YAML",
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
changes.push({
|
|
551
|
+
path: pnpmWorkspace,
|
|
552
|
+
action: "create",
|
|
553
|
+
kind: "workspace",
|
|
554
|
+
content: 'packages:\n - "packages/*"\n',
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
warnings.push(
|
|
558
|
+
"Imports keep the canonical @agent-native/scheduling specifier; workspace resolution switches them to the local package.",
|
|
559
|
+
);
|
|
560
|
+
return { changes, collisions, warnings };
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function normalizeEjectedPackageJson(
|
|
564
|
+
input: Record<string, unknown>,
|
|
565
|
+
workspaceRoot: string,
|
|
566
|
+
): Record<string, unknown> {
|
|
567
|
+
const output = structuredClone(input) as Record<string, any>;
|
|
568
|
+
for (const field of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
569
|
+
const dependencies = output[field] as Record<string, unknown> | undefined;
|
|
570
|
+
if (!dependencies) continue;
|
|
571
|
+
for (const [name, range] of Object.entries(dependencies)) {
|
|
572
|
+
if (
|
|
573
|
+
typeof range !== "string" ||
|
|
574
|
+
(!range.startsWith("workspace:") && !range.startsWith("catalog:"))
|
|
575
|
+
) {
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
const installed = findInstalledPackageJson(name, workspaceRoot);
|
|
579
|
+
if (!installed) {
|
|
580
|
+
throw new Error(
|
|
581
|
+
`Cannot normalize ${field}.${name}; the installed dependency version is unavailable`,
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
const version = JSON.parse(fs.readFileSync(installed, "utf8")).version;
|
|
585
|
+
if (!version)
|
|
586
|
+
throw new Error(`Installed dependency ${name} has no version`);
|
|
587
|
+
dependencies[name] = `^${version}`;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return output;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function collisionCheckedText(
|
|
594
|
+
root: string,
|
|
595
|
+
target: string,
|
|
596
|
+
content: string,
|
|
597
|
+
kind: Change["kind"],
|
|
598
|
+
collisions: string[],
|
|
599
|
+
): Change {
|
|
600
|
+
return collisionCheckedBuffer(
|
|
601
|
+
root,
|
|
602
|
+
target,
|
|
603
|
+
Buffer.from(content),
|
|
604
|
+
kind,
|
|
605
|
+
collisions,
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function collisionCheckedBuffer(
|
|
610
|
+
root: string,
|
|
611
|
+
target: string,
|
|
612
|
+
content: Buffer,
|
|
613
|
+
kind: Change["kind"],
|
|
614
|
+
collisions: string[],
|
|
615
|
+
): Change {
|
|
616
|
+
if (!fs.existsSync(target)) {
|
|
617
|
+
return { path: target, action: "create", kind, content };
|
|
618
|
+
}
|
|
619
|
+
const current = fs.readFileSync(target);
|
|
620
|
+
if (current.equals(content)) return { path: target, action: "noop", kind };
|
|
621
|
+
collisions.push(`Refusing to overwrite ${relative(root, target)}`);
|
|
622
|
+
return { path: target, action: "noop", kind };
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function textChange(
|
|
626
|
+
root: string,
|
|
627
|
+
target: string,
|
|
628
|
+
content: string,
|
|
629
|
+
kind: Change["kind"],
|
|
630
|
+
): Change {
|
|
631
|
+
if (!fs.existsSync(target))
|
|
632
|
+
return { path: target, action: "create", kind, content };
|
|
633
|
+
return {
|
|
634
|
+
path: target,
|
|
635
|
+
action: fs.readFileSync(target, "utf8") === content ? "noop" : "update",
|
|
636
|
+
kind,
|
|
637
|
+
content,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function walkFiles(root: string): string[] {
|
|
642
|
+
const files: string[] = [];
|
|
643
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
644
|
+
const full = path.join(root, entry.name);
|
|
645
|
+
if (entry.isSymbolicLink())
|
|
646
|
+
throw new Error(`Refusing package symlink: ${full}`);
|
|
647
|
+
if (entry.isDirectory()) files.push(...walkFiles(full));
|
|
648
|
+
else if (entry.isFile()) files.push(full);
|
|
649
|
+
}
|
|
650
|
+
return files.sort();
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function reportFor(
|
|
654
|
+
command: PackageLifecycleReport["command"],
|
|
655
|
+
loaded: LoadedLifecyclePackage,
|
|
656
|
+
target: { root: string; layout: PackageLifecycleReport["layout"] },
|
|
657
|
+
apply: boolean,
|
|
658
|
+
planned: { changes: Change[]; collisions: string[]; warnings: string[] },
|
|
659
|
+
): PackageLifecycleReport {
|
|
660
|
+
const { manifest } = loaded;
|
|
661
|
+
return {
|
|
662
|
+
command,
|
|
663
|
+
package: manifest.name,
|
|
664
|
+
packageVersion: loaded.packageVersion,
|
|
665
|
+
manifestVersion: manifest.manifestVersion,
|
|
666
|
+
targetRoot: target.root,
|
|
667
|
+
layout: target.layout,
|
|
668
|
+
apply,
|
|
669
|
+
compatible: planned.collisions.length === 0,
|
|
670
|
+
contributions: {
|
|
671
|
+
actions: manifest.actions,
|
|
672
|
+
schemaEntryPoint: manifest.schemaEntryPoint,
|
|
673
|
+
skills: manifest.docs.skills,
|
|
674
|
+
requiredSecretKeys: manifest.requiredSecrets.map((secret) => secret.key),
|
|
675
|
+
peerProviders: manifest.peerProviders,
|
|
676
|
+
},
|
|
677
|
+
changes: planned.changes.map(({ path: file, action, kind }) => ({
|
|
678
|
+
path: relative(target.root, file),
|
|
679
|
+
action,
|
|
680
|
+
kind,
|
|
681
|
+
})),
|
|
682
|
+
collisions: planned.collisions,
|
|
683
|
+
warnings: planned.warnings,
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function formatReport(report: PackageLifecycleReport): string {
|
|
688
|
+
const lines = [
|
|
689
|
+
`# ${report.command} ${report.package}@${report.packageVersion}`,
|
|
690
|
+
`Manifest: v${report.manifestVersion}`,
|
|
691
|
+
`Target: ${report.targetRoot} (${report.layout})`,
|
|
692
|
+
`Mode: ${report.apply ? "apply" : "dry-run"}`,
|
|
693
|
+
`Compatible: ${report.compatible ? "yes" : "no"}`,
|
|
694
|
+
"",
|
|
695
|
+
`Actions: ${report.contributions.actions.length}`,
|
|
696
|
+
`Schema: ${report.contributions.schemaEntryPoint}`,
|
|
697
|
+
`Skills: ${report.contributions.skills.join(", ") || "none"}`,
|
|
698
|
+
`Required secret keys: ${report.contributions.requiredSecretKeys.join(", ") || "none"}`,
|
|
699
|
+
`Peer providers: ${report.contributions.peerProviders.join(", ") || "none"}`,
|
|
700
|
+
"",
|
|
701
|
+
"Changes:",
|
|
702
|
+
...report.changes.map(
|
|
703
|
+
(change) =>
|
|
704
|
+
` ${change.action.padEnd(6)} ${change.path} (${change.kind})`,
|
|
705
|
+
),
|
|
706
|
+
];
|
|
707
|
+
if (report.collisions.length) {
|
|
708
|
+
lines.push(
|
|
709
|
+
"",
|
|
710
|
+
"Collisions:",
|
|
711
|
+
...report.collisions.map((item) => ` - ${item}`),
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
if (report.warnings.length) {
|
|
715
|
+
lines.push("", "Notes:", ...report.warnings.map((item) => ` - ${item}`));
|
|
716
|
+
}
|
|
717
|
+
if (!report.apply && report.command !== "inspect") {
|
|
718
|
+
lines.push("", "Dry-run only. Re-run with --apply to write these changes.");
|
|
719
|
+
}
|
|
720
|
+
return lines.join("\n");
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
async function applyTransaction(
|
|
724
|
+
root: string,
|
|
725
|
+
changes: Change[],
|
|
726
|
+
spawn: typeof spawnSync,
|
|
727
|
+
): Promise<void> {
|
|
728
|
+
const stage = fs.mkdtempSync(path.join(root, ".agent-native-package-stage-"));
|
|
729
|
+
const snapshots = new Map<string, Buffer | null>();
|
|
730
|
+
const installRoot = findPackageManagerRoot(root);
|
|
731
|
+
const lockfiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock"].map(
|
|
732
|
+
(name) => path.join(installRoot, name),
|
|
733
|
+
);
|
|
734
|
+
try {
|
|
735
|
+
for (const change of changes) {
|
|
736
|
+
snapshots.set(
|
|
737
|
+
change.path,
|
|
738
|
+
fs.existsSync(change.path) ? fs.readFileSync(change.path) : null,
|
|
739
|
+
);
|
|
740
|
+
const staged = path.join(stage, String(snapshots.size));
|
|
741
|
+
fs.writeFileSync(staged, change.content!);
|
|
742
|
+
}
|
|
743
|
+
for (const lockfile of lockfiles) {
|
|
744
|
+
snapshots.set(
|
|
745
|
+
lockfile,
|
|
746
|
+
fs.existsSync(lockfile) ? fs.readFileSync(lockfile) : null,
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
let index = 0;
|
|
750
|
+
for (const change of changes) {
|
|
751
|
+
index += 1;
|
|
752
|
+
fs.mkdirSync(path.dirname(change.path), { recursive: true });
|
|
753
|
+
fs.renameSync(path.join(stage, String(index)), change.path);
|
|
754
|
+
}
|
|
755
|
+
const packageManager = detectPackageManager(installRoot);
|
|
756
|
+
const result = spawn(packageManager, ["install"], {
|
|
757
|
+
cwd: installRoot,
|
|
758
|
+
stdio: "inherit",
|
|
759
|
+
});
|
|
760
|
+
if (result.status !== 0) {
|
|
761
|
+
throw new Error(
|
|
762
|
+
`${packageManager} install failed with status ${result.status}`,
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
} catch (error) {
|
|
766
|
+
for (const [file, snapshot] of [...snapshots.entries()].reverse()) {
|
|
767
|
+
if (snapshot === null) fs.rmSync(file, { force: true, recursive: true });
|
|
768
|
+
else {
|
|
769
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
770
|
+
fs.writeFileSync(file, snapshot);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
for (const change of [...changes].reverse()) {
|
|
774
|
+
removeEmptyParents(path.dirname(change.path), root);
|
|
775
|
+
}
|
|
776
|
+
throw error;
|
|
777
|
+
} finally {
|
|
778
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function removeEmptyParents(directory: string, stop: string): void {
|
|
783
|
+
let current = directory;
|
|
784
|
+
const boundary = path.resolve(stop);
|
|
785
|
+
while (current.startsWith(`${boundary}${path.sep}`)) {
|
|
786
|
+
try {
|
|
787
|
+
if (fs.readdirSync(current).length > 0) return;
|
|
788
|
+
fs.rmdirSync(current);
|
|
789
|
+
} catch {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
current = path.dirname(current);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function detectPackageManager(root: string): "pnpm" | "yarn" | "npm" {
|
|
797
|
+
if (fs.existsSync(path.join(root, "pnpm-lock.yaml"))) return "pnpm";
|
|
798
|
+
if (fs.existsSync(path.join(root, "yarn.lock"))) return "yarn";
|
|
799
|
+
return "npm";
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function findPackageManagerRoot(from: string): string {
|
|
803
|
+
let dir = from;
|
|
804
|
+
while (true) {
|
|
805
|
+
if (
|
|
806
|
+
fs.existsSync(path.join(dir, "pnpm-lock.yaml")) ||
|
|
807
|
+
fs.existsSync(path.join(dir, "yarn.lock")) ||
|
|
808
|
+
fs.existsSync(path.join(dir, "package-lock.json"))
|
|
809
|
+
) {
|
|
810
|
+
return dir;
|
|
811
|
+
}
|
|
812
|
+
const parent = path.dirname(dir);
|
|
813
|
+
if (parent === dir) return from;
|
|
814
|
+
dir = parent;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function relative(root: string, file: string): string {
|
|
819
|
+
const value = path.relative(root, file);
|
|
820
|
+
return value || ".";
|
|
821
|
+
}
|