@agent-native/core 0.111.4 → 0.113.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/corpus/README.md +4 -2
- package/corpus/core/CHANGELOG.md +34 -0
- package/corpus/core/docs/AGENTS.md +7 -0
- package/corpus/core/docs/content/integrations.mdx +63 -2
- package/corpus/core/docs/design/provider-integration-authority.md +117 -0
- package/corpus/core/package.json +8 -1
- package/corpus/core/scripts/materialize-source-corpus.mjs +9 -2
- package/corpus/core/src/cli/atomic-json-file.ts +324 -0
- package/corpus/core/src/cli/claude-code-participant.ts +515 -0
- package/corpus/core/src/cli/code-agent-executor.ts +35 -15
- package/corpus/core/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/corpus/core/src/cli/code-agent-runs.ts +70 -36
- package/corpus/core/src/cli/codex-cli-participant.ts +496 -0
- package/corpus/core/src/cli/multi-frontier-runs.ts +1952 -0
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +7 -404
- package/corpus/core/src/coding-tools/index.ts +27 -8
- package/corpus/core/src/embeddings/index.ts +233 -0
- package/corpus/core/src/index.ts +2 -0
- package/corpus/core/src/integrations/index.ts +10 -0
- package/corpus/core/src/integrations/slack-oauth.ts +1 -0
- package/corpus/core/src/integrations/webhook-delivery.ts +55 -0
- package/corpus/core/src/notifications/channels.ts +4 -10
- package/corpus/core/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/corpus/core/src/provider-api/actions/delete-staged-dataset.ts +3 -42
- package/corpus/core/src/provider-api/actions/list-staged-datasets.ts +3 -45
- package/corpus/core/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +460 -0
- package/corpus/core/src/provider-api/actions/query-staged-dataset.ts +3 -140
- package/corpus/core/src/provider-api/actions/staged-datasets.ts +359 -0
- package/corpus/core/src/provider-api/gong.ts +108 -0
- package/corpus/core/src/scripts/docs/source-search.ts +2 -1
- package/corpus/core/src/search/index.ts +413 -0
- package/corpus/core/src/server/google-oauth-credentials.ts +80 -3
- package/corpus/core/src/server/index.ts +6 -0
- package/corpus/core/src/styles/chat-history-list.css +1 -313
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/default/AGENTS.md +25 -18
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/headless/AGENTS.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +4 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +4 -0
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/analytics/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/analytics/actions/delete-staged-dataset.ts +3 -23
- package/corpus/templates/analytics/actions/list-staged-datasets.ts +3 -27
- package/corpus/templates/analytics/actions/provider-api-catalog.ts +16 -19
- package/corpus/templates/analytics/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/analytics/actions/provider-api-request.ts +162 -185
- package/corpus/templates/analytics/actions/query-staged-dataset.ts +3 -47
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +52 -161
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/assets/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +63 -160
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +48 -5
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +46 -14
- package/corpus/templates/brain/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/brain/README.md +34 -3
- package/corpus/templates/brain/actions/_schemas.ts +13 -7
- package/corpus/templates/brain/actions/approve-proposal.ts +2 -0
- package/corpus/templates/brain/actions/claim-distillation.ts +24 -27
- package/corpus/templates/brain/actions/create-source.ts +1 -1
- package/corpus/templates/brain/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/brain/actions/get-knowledge.ts +6 -2
- package/corpus/templates/brain/actions/get-pilot-report.ts +44 -8
- package/corpus/templates/brain/actions/import-capture.ts +21 -9
- package/corpus/templates/brain/actions/import-transcript.ts +42 -14
- package/corpus/templates/brain/actions/list-captures.ts +10 -1
- package/corpus/templates/brain/actions/list-distillation-queue.ts +39 -14
- package/corpus/templates/brain/actions/list-projects.ts +51 -0
- package/corpus/templates/brain/actions/list-proposals.ts +80 -4
- package/corpus/templates/brain/actions/list-sources.ts +17 -3
- package/corpus/templates/brain/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/brain/actions/manage-project.ts +118 -0
- package/corpus/templates/brain/actions/mark-capture-distilled.ts +68 -20
- package/corpus/templates/brain/actions/navigate.ts +1 -0
- package/corpus/templates/brain/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/brain/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/brain/actions/provider-api-request.ts +3 -37
- package/corpus/templates/brain/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/brain/actions/reject-proposal.ts +6 -1
- package/corpus/templates/brain/actions/resanitize-captures.ts +159 -33
- package/corpus/templates/brain/actions/review-proposal.ts +2 -0
- package/corpus/templates/brain/actions/search-everything.ts +10 -1
- package/corpus/templates/brain/actions/search-knowledge.ts +1 -1
- package/corpus/templates/brain/actions/set-settings.ts +36 -1
- package/corpus/templates/brain/actions/update-proposal.ts +2 -0
- package/corpus/templates/brain/actions/update-source.ts +5 -1
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +48 -154
- package/corpus/templates/brain/app/hooks/use-distillation-bridge.ts +18 -9
- package/corpus/templates/brain/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/brain/app/i18n-data.ts +731 -2
- package/corpus/templates/brain/app/lib/brain.ts +88 -1
- package/corpus/templates/brain/app/lib/ingest-handoff.ts +35 -0
- package/corpus/templates/brain/app/routes/ops.tsx +47 -0
- package/corpus/templates/brain/app/routes/review.tsx +41 -2
- package/corpus/templates/brain/app/routes/search.tsx +33 -2
- package/corpus/templates/brain/app/routes/settings.tsx +158 -0
- package/corpus/templates/brain/app/routes/sources.tsx +31 -0
- package/corpus/templates/brain/changelog/2026-07-19-added-private-source-safe-semantic-search.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-can-now-join-configured-public-channels-befo.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-continue-across-the-configured-number-of.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-start-with-a-safe-four-week-window-and-r.md +6 -0
- package/corpus/templates/brain/jobs/process-ingest-queue.ts +270 -36
- package/corpus/templates/brain/package.json +1 -0
- package/corpus/templates/brain/server/db/index.ts +18 -0
- package/corpus/templates/brain/server/db/schema.ts +197 -1
- package/corpus/templates/brain/server/jobs/distillation-queue.ts +12 -5
- package/corpus/templates/brain/server/lib/audiences.ts +708 -0
- package/corpus/templates/brain/server/lib/brain-health.ts +251 -38
- package/corpus/templates/brain/server/lib/brain.ts +877 -50
- package/corpus/templates/brain/server/lib/capture-sanitization.ts +217 -53
- package/corpus/templates/brain/server/lib/connectors.ts +609 -72
- package/corpus/templates/brain/server/lib/demo.ts +17 -4
- package/corpus/templates/brain/server/lib/hybrid-search.ts +363 -0
- package/corpus/templates/brain/server/lib/ingest-queue.ts +104 -0
- package/corpus/templates/brain/server/lib/privacy-readiness.ts +24 -0
- package/corpus/templates/brain/server/lib/search-index-contracts.ts +72 -0
- package/corpus/templates/brain/server/lib/search-index.ts +714 -0
- package/corpus/templates/brain/server/lib/search.ts +120 -4
- package/corpus/templates/brain/server/lib/sensitivity-policy.ts +174 -0
- package/corpus/templates/brain/server/lib/slack-channel-membership.ts +44 -0
- package/corpus/templates/brain/server/lib/slack-events.ts +281 -0
- package/corpus/templates/brain/server/onboarding.ts +29 -0
- package/corpus/templates/brain/server/plugins/db.ts +204 -0
- package/corpus/templates/brain/server/register-secrets.ts +46 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +36 -16
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/slack-events.post.ts +28 -0
- package/corpus/templates/brain/shared/slack-source-config.ts +60 -0
- package/corpus/templates/brain/shared/types.ts +10 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/calendar/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/calendar/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/calendar/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/calendar/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/calendar/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/calendar/actions/provider-api-request.ts +3 -37
- package/corpus/templates/calendar/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/calendar/server/handlers/gong.ts +6 -61
- package/corpus/templates/calendar/server/handlers/google-auth.ts +10 -8
- package/corpus/templates/calendar/server/lib/google-calendar.ts +7 -45
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/chat/AGENTS.md +5 -2
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/clips/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/clips/AGENTS.md +11 -0
- package/corpus/templates/clips/actions/export-to-brain.ts +505 -171
- package/corpus/templates/clips/changelog/2026-07-19-ready-clips-transcripts-can-be-backfilled-to-brain-for-a-bou.md +6 -0
- package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +1 -1
- package/corpus/templates/clips/server/lib/google-calendar-client.ts +12 -22
- package/corpus/templates/clips/server/lib/google-calendar-oauth.ts +9 -6
- package/corpus/templates/clips/server/lib/slack-oauth.ts +12 -47
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +2 -6
- package/corpus/templates/clips/server/routes/api/auth/google-calendar.get.ts +4 -4
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/content/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/content/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/content/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/content/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/content/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/content/actions/provider-api-request.ts +3 -37
- package/corpus/templates/content/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/design/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/design/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/design/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/design/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/design/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/design/actions/provider-api-request.ts +140 -164
- package/corpus/templates/design/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/dispatch/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/dispatch/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/dispatch/actions/list-staged-datasets.ts +4 -30
- package/corpus/templates/dispatch/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/dispatch/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/dispatch/actions/provider-api-request.ts +138 -163
- package/corpus/templates/dispatch/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/forms/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/forms/server/lib/integrations.ts +23 -22
- package/corpus/templates/macros/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/mail/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/mail/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/mail/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/mail/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/mail/actions/provider-api-request.ts +146 -173
- package/corpus/templates/mail/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/mail/server/handlers/gong.ts +6 -61
- package/corpus/templates/mail/server/lib/google-auth.ts +10 -13
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/plan/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +47 -156
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/slides/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/slides/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/slides/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/slides/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/slides/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/slides/actions/provider-api-request.ts +145 -172
- package/corpus/templates/slides/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/slides/server/lib/google-docs-oauth.ts +11 -36
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/corpus/templates/tasks/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +125 -0
- package/corpus/toolkit/README.md +60 -0
- package/corpus/toolkit/export-snapshot.json +35 -0
- package/corpus/toolkit/migration-manifest.json +4 -0
- package/corpus/toolkit/package.json +281 -0
- package/corpus/toolkit/scripts/finalize-build.mjs +55 -0
- package/corpus/toolkit/src/app-shell/header-actions.tsx +84 -0
- package/corpus/toolkit/src/app-shell/index.ts +1 -0
- package/corpus/toolkit/src/chat-history/ChatHistoryList.tsx +469 -0
- package/corpus/toolkit/src/chat-history/index.ts +7 -0
- package/corpus/toolkit/src/chat-history.css +314 -0
- package/corpus/toolkit/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/corpus/toolkit/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/corpus/toolkit/src/collab-ui/PresenceBar.tsx +346 -0
- package/corpus/toolkit/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/corpus/toolkit/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/corpus/toolkit/src/collab-ui/agent-identity.ts +16 -0
- package/corpus/toolkit/src/collab-ui/index.ts +39 -0
- package/corpus/toolkit/src/collab-ui/lead-client.ts +32 -0
- package/corpus/toolkit/src/collab-ui/types.ts +96 -0
- package/corpus/toolkit/src/composer/AgentComposerFrame.tsx +59 -0
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +983 -0
- package/corpus/toolkit/src/composer/MentionPopover.tsx +412 -0
- package/corpus/toolkit/src/composer/PastedTextChip.tsx +150 -0
- package/corpus/toolkit/src/composer/PromptComposer.tsx +718 -0
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +2936 -0
- package/corpus/toolkit/src/composer/VoiceButton.tsx +255 -0
- package/corpus/toolkit/src/composer/asset-picker-url.ts +80 -0
- package/corpus/toolkit/src/composer/attachment-accept.ts +71 -0
- package/corpus/toolkit/src/composer/draft-key.ts +7 -0
- package/corpus/toolkit/src/composer/extensions/FileReference.tsx +55 -0
- package/corpus/toolkit/src/composer/extensions/MentionReference.tsx +93 -0
- package/corpus/toolkit/src/composer/extensions/SkillReference.tsx +56 -0
- package/corpus/toolkit/src/composer/index.ts +79 -0
- package/corpus/toolkit/src/composer/pasted-text.ts +160 -0
- package/corpus/toolkit/src/composer/prompt-attachments.ts +93 -0
- package/corpus/toolkit/src/composer/realtime-voice-audio-level.ts +64 -0
- package/corpus/toolkit/src/composer/realtime-voice-transcript.ts +134 -0
- package/corpus/toolkit/src/composer/runtime-adapters.tsx +343 -0
- package/corpus/toolkit/src/composer/types.ts +66 -0
- package/corpus/toolkit/src/composer/use-file-search.ts +64 -0
- package/corpus/toolkit/src/composer/use-mention-search.ts +90 -0
- package/corpus/toolkit/src/composer/use-skills.ts +45 -0
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/corpus/toolkit/src/composer/useVoiceDictation.ts +1191 -0
- package/corpus/toolkit/src/context-ui/ContextMeter.tsx +101 -0
- package/corpus/toolkit/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/corpus/toolkit/src/context-ui/ContextTreemap.tsx +125 -0
- package/corpus/toolkit/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/corpus/toolkit/src/context-ui/format.ts +42 -0
- package/corpus/toolkit/src/context-ui/index.ts +15 -0
- package/corpus/toolkit/src/context-ui/types.ts +43 -0
- package/corpus/toolkit/src/design-tweaks/index.ts +1 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/corpus/toolkit/src/editor/BubbleToolbar.tsx +253 -0
- package/corpus/toolkit/src/editor/CodeBlockNode.tsx +254 -0
- package/corpus/toolkit/src/editor/DragHandle.ts +1437 -0
- package/corpus/toolkit/src/editor/ImageExtension.ts +306 -0
- package/corpus/toolkit/src/editor/RegistryBlockContext.tsx +107 -0
- package/corpus/toolkit/src/editor/RegistryBlockNode.tsx +652 -0
- package/corpus/toolkit/src/editor/RichMarkdownEditor.tsx +81 -0
- package/corpus/toolkit/src/editor/RunId.ts +61 -0
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +321 -0
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +310 -0
- package/corpus/toolkit/src/editor/extensions.ts +402 -0
- package/corpus/toolkit/src/editor/gfmDoc.ts +92 -0
- package/corpus/toolkit/src/editor/index.ts +93 -0
- package/corpus/toolkit/src/editor/registrySlashCommands.ts +131 -0
- package/corpus/toolkit/src/editor/surgical-apply.ts +192 -0
- package/corpus/toolkit/src/editor/useCollabReconcile.ts +589 -0
- package/corpus/toolkit/src/editor.css +510 -0
- package/corpus/toolkit/src/hooks/index.ts +2 -0
- package/corpus/toolkit/src/hooks/use-mobile.tsx +21 -0
- package/corpus/toolkit/src/hooks/use-toast.ts +188 -0
- package/corpus/toolkit/src/index.ts +8 -0
- package/corpus/toolkit/src/onboarding/index.ts +1 -0
- package/corpus/toolkit/src/provider.tsx +47 -0
- package/corpus/toolkit/src/sharing/VisibilityBadge.tsx +37 -0
- package/corpus/toolkit/src/sharing/index.ts +4 -0
- package/corpus/toolkit/src/styles.css +21 -0
- package/corpus/toolkit/src/ui/accordion.tsx +56 -0
- package/corpus/toolkit/src/ui/alert-dialog.tsx +141 -0
- package/corpus/toolkit/src/ui/alert.tsx +59 -0
- package/corpus/toolkit/src/ui/aspect-ratio.tsx +5 -0
- package/corpus/toolkit/src/ui/avatar.tsx +48 -0
- package/corpus/toolkit/src/ui/badge.tsx +37 -0
- package/corpus/toolkit/src/ui/breadcrumb.tsx +115 -0
- package/corpus/toolkit/src/ui/button.tsx +78 -0
- package/corpus/toolkit/src/ui/calendar.tsx +214 -0
- package/corpus/toolkit/src/ui/card.tsx +86 -0
- package/corpus/toolkit/src/ui/carousel.tsx +260 -0
- package/corpus/toolkit/src/ui/chart.tsx +375 -0
- package/corpus/toolkit/src/ui/checkbox.tsx +28 -0
- package/corpus/toolkit/src/ui/collapsible.tsx +9 -0
- package/corpus/toolkit/src/ui/command.tsx +174 -0
- package/corpus/toolkit/src/ui/context-menu.tsx +202 -0
- package/corpus/toolkit/src/ui/date-picker.tsx +64 -0
- package/corpus/toolkit/src/ui/dialog.tsx +146 -0
- package/corpus/toolkit/src/ui/drawer.tsx +126 -0
- package/corpus/toolkit/src/ui/dropdown-menu.tsx +218 -0
- package/corpus/toolkit/src/ui/form.tsx +177 -0
- package/corpus/toolkit/src/ui/hover-card.tsx +27 -0
- package/corpus/toolkit/src/ui/index.ts +52 -0
- package/corpus/toolkit/src/ui/input-otp.tsx +69 -0
- package/corpus/toolkit/src/ui/input.tsx +22 -0
- package/corpus/toolkit/src/ui/label.tsx +24 -0
- package/corpus/toolkit/src/ui/logo.tsx +36 -0
- package/corpus/toolkit/src/ui/menubar.tsx +235 -0
- package/corpus/toolkit/src/ui/navigation-menu.tsx +128 -0
- package/corpus/toolkit/src/ui/pagination.tsx +121 -0
- package/corpus/toolkit/src/ui/popover.tsx +44 -0
- package/corpus/toolkit/src/ui/progress.tsx +26 -0
- package/corpus/toolkit/src/ui/radio-group.tsx +42 -0
- package/corpus/toolkit/src/ui/resizable.tsx +43 -0
- package/corpus/toolkit/src/ui/scroll-area.tsx +46 -0
- package/corpus/toolkit/src/ui/select.tsx +158 -0
- package/corpus/toolkit/src/ui/separator.tsx +29 -0
- package/corpus/toolkit/src/ui/sheet.tsx +160 -0
- package/corpus/toolkit/src/ui/sidebar.tsx +777 -0
- package/corpus/toolkit/src/ui/skeleton.tsx +18 -0
- package/corpus/toolkit/src/ui/slider.tsx +26 -0
- package/corpus/toolkit/src/ui/sonner.tsx +58 -0
- package/corpus/toolkit/src/ui/spinner.tsx +17 -0
- package/corpus/toolkit/src/ui/switch.tsx +27 -0
- package/corpus/toolkit/src/ui/table.tsx +117 -0
- package/corpus/toolkit/src/ui/tabs.tsx +53 -0
- package/corpus/toolkit/src/ui/textarea.tsx +23 -0
- package/corpus/toolkit/src/ui/toast.tsx +127 -0
- package/corpus/toolkit/src/ui/toaster.tsx +33 -0
- package/corpus/toolkit/src/ui/toggle-group.tsx +59 -0
- package/corpus/toolkit/src/ui/toggle.tsx +43 -0
- package/corpus/toolkit/src/ui/tooltip.tsx +53 -0
- package/corpus/toolkit/src/ui/use-toast.ts +3 -0
- package/corpus/toolkit/src/utils.ts +8 -0
- package/corpus/toolkit/tsconfig.json +23 -0
- package/dist/cli/atomic-json-file.d.ts +30 -0
- package/dist/cli/atomic-json-file.d.ts.map +1 -0
- package/dist/cli/atomic-json-file.js +240 -0
- package/dist/cli/atomic-json-file.js.map +1 -0
- package/dist/cli/claude-code-participant.d.ts +77 -0
- package/dist/cli/claude-code-participant.d.ts.map +1 -0
- package/dist/cli/claude-code-participant.js +355 -0
- package/dist/cli/claude-code-participant.js.map +1 -0
- package/dist/cli/code-agent-executor.d.ts +8 -9
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +27 -13
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts +2 -0
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts.map +1 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js +32 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js.map +1 -0
- package/dist/cli/code-agent-runs.d.ts +5 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +51 -33
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/codex-cli-participant.d.ts +77 -0
- package/dist/cli/codex-cli-participant.d.ts.map +1 -0
- package/dist/cli/codex-cli-participant.js +354 -0
- package/dist/cli/codex-cli-participant.js.map +1 -0
- package/dist/cli/multi-frontier-runs.d.ts +246 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -0
- package/dist/cli/multi-frontier-runs.js +1247 -0
- package/dist/cli/multi-frontier-runs.js.map +1 -0
- package/dist/client/chat/ChatHistoryList.d.ts +1 -87
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -1
- package/dist/client/chat/ChatHistoryList.js +1 -82
- package/dist/client/chat/ChatHistoryList.js.map +1 -1
- package/dist/coding-tools/index.d.ts +1 -0
- package/dist/coding-tools/index.d.ts.map +1 -1
- package/dist/coding-tools/index.js +25 -7
- package/dist/coding-tools/index.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/embeddings/index.d.ts +24 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +172 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/index.d.ts +2 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/slack-manifest.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts.map +1 -1
- package/dist/integrations/slack-oauth.js +1 -0
- package/dist/integrations/slack-oauth.js.map +1 -1
- package/dist/integrations/webhook-delivery.d.ts +23 -0
- package/dist/integrations/webhook-delivery.d.ts.map +1 -0
- package/dist/integrations/webhook-delivery.js +32 -0
- package/dist/integrations/webhook-delivery.js.map +1 -0
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +4 -9
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +136 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.js +154 -0
- package/dist/provider-api/actions/custom-provider-registration.js.map +1 -0
- package/dist/provider-api/actions/delete-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.js +3 -34
- package/dist/provider-api/actions/delete-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.d.ts +2 -3
- package/dist/provider-api/actions/list-staged-datasets.d.ts.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.js +3 -40
- package/dist/provider-api/actions/list-staged-datasets.js.map +1 -1
- package/dist/provider-api/actions/provider-api-audit.d.ts +7 -0
- package/dist/provider-api/actions/provider-api-audit.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api-audit.js +74 -0
- package/dist/provider-api/actions/provider-api-audit.js.map +1 -0
- package/dist/provider-api/actions/provider-api.d.ts +370 -0
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api.js +280 -0
- package/dist/provider-api/actions/provider-api.js.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +3 -116
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/staged-datasets.d.ts +190 -0
- package/dist/provider-api/actions/staged-datasets.d.ts.map +1 -0
- package/dist/provider-api/actions/staged-datasets.js +210 -0
- package/dist/provider-api/actions/staged-datasets.js.map +1 -0
- package/dist/provider-api/gong.d.ts +44 -0
- package/dist/provider-api/gong.d.ts.map +1 -0
- package/dist/provider-api/gong.js +56 -0
- package/dist/provider-api/gong.js.map +1 -0
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/docs/source-search.d.ts +2 -1
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +2 -1
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/search/index.d.ts +88 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +267 -0
- package/dist/search/index.js.map +1 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/google-oauth-credentials.d.ts +35 -0
- package/dist/server/google-oauth-credentials.d.ts.map +1 -1
- package/dist/server/google-oauth-credentials.js +48 -2
- package/dist/server/google-oauth-credentials.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/styles/chat-history-list.css +1 -313
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/chat/AGENTS.md +5 -2
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/default/AGENTS.md +25 -18
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/headless/AGENTS.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/dist/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/workspace-core/AGENTS.md +4 -0
- package/dist/templates/workspace-root/AGENTS.md +4 -0
- package/docs/AGENTS.md +7 -0
- package/docs/content/integrations.mdx +63 -2
- package/docs/design/provider-integration-authority.md +117 -0
- package/package.json +9 -2
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/chat/AGENTS.md +5 -2
- package/src/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/default/AGENTS.md +25 -18
- package/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/headless/AGENTS.md +7 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +10 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +6 -0
- package/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +102 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +11 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/workspace-core/AGENTS.md +4 -0
- package/src/templates/workspace-root/AGENTS.md +4 -0
package/corpus/README.md
CHANGED
|
@@ -7,6 +7,7 @@ inside installed apps at `node_modules/@agent-native/core/corpus`.
|
|
|
7
7
|
## Contents
|
|
8
8
|
|
|
9
9
|
- `core/` -- source and package files for `@agent-native/core`.
|
|
10
|
+
- `toolkit/` -- source and package files for `@agent-native/toolkit`.
|
|
10
11
|
- `templates/` -- source-only copies of first-party Agent Native templates.
|
|
11
12
|
|
|
12
13
|
Runtime data, local env files, dependency folders, caches, tests, and build
|
|
@@ -27,5 +28,6 @@ rg -n "defineAction|useActionQuery" node_modules/@agent-native/core/corpus
|
|
|
27
28
|
|
|
28
29
|
## Generated Counts
|
|
29
30
|
|
|
30
|
-
- core files:
|
|
31
|
-
-
|
|
31
|
+
- core files: 1497
|
|
32
|
+
- toolkit files: 136
|
|
33
|
+
- template files: 6048
|
package/corpus/core/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @agent-native/core
|
|
2
2
|
|
|
3
|
+
## 0.113.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e53a34e: Extract reusable Postgres search and embedding primitives into Core while preserving Creative Context imports.
|
|
8
|
+
The pgvector setup error now consistently says "Vector search" instead of the narrower "Visual search" wording.
|
|
9
|
+
- e53a34e: Add reusable Google and Slack OAuth compatibility helpers, including Slack's Basic-auth token exchange, Gong lookup utilities, and SSRF-safe JSON webhook delivery with shared Slack escaping.
|
|
10
|
+
- e53a34e: Add reusable provider API and staged dataset action factories, including opt-in custom provider registration and sanitized provider request audit summaries that narrow recorded audit metadata to safe request context.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- e53a34e: Add a subscription-only Claude Code participant runtime with enforced read-only and driver permissions.
|
|
15
|
+
- e53a34e: Add a ChatGPT-subscription Codex CLI participant runtime with enforced read-only and driver sandboxes.
|
|
16
|
+
- e53a34e: Add durable, fenced local state for compound multi-frontier runs.
|
|
17
|
+
- e53a34e: Move the reusable ChatHistoryList and its stylesheet to the Toolkit chat-history entrypoint while preserving Core compatibility imports. Adopt it across first-party full-page chat sidebars, ship readable Toolkit source, and add generated-app guidance for selective app-owned UI customization.
|
|
18
|
+
- e53a34e: Keep interrupted local Codex runs paused and resumable across every runner command.
|
|
19
|
+
- e53a34e: Harden local Code run persistence and cancellation for the packaged desktop runner.
|
|
20
|
+
- e53a34e: Harden local Code run and transcript persistence with atomic replacements and idempotent events.
|
|
21
|
+
- e53a34e: Persist bounded, redacted Desktop multi-frontier orchestration state for safe recovery.
|
|
22
|
+
- Updated dependencies [e53a34e]
|
|
23
|
+
- @agent-native/toolkit@0.7.0
|
|
24
|
+
|
|
25
|
+
## 0.112.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 6acaad0: Extract reusable Postgres search and embedding primitives into Core while preserving Creative Context imports.
|
|
30
|
+
The pgvector setup error now consistently says "Vector search" instead of the narrower "Visual search" wording.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 6acaad0: Add durable, fenced local state for compound multi-frontier runs.
|
|
35
|
+
- 6acaad0: Harden local Code run persistence and cancellation for the packaged desktop runner.
|
|
36
|
+
|
|
3
37
|
## 0.111.4
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -25,6 +25,7 @@ pnpm action docs-search --slug actions
|
|
|
25
25
|
pnpm action source-search --list
|
|
26
26
|
pnpm action source-search --query "defineAction useActionQuery"
|
|
27
27
|
pnpm action source-search --path templates/plan/AGENTS.md
|
|
28
|
+
pnpm action source-search --path toolkit/src/index.ts
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
The built-in app agent also has read-only `docs-search` and `source-search`
|
|
@@ -42,6 +43,12 @@ For source examples, read matching files under
|
|
|
42
43
|
`node_modules/@agent-native/core/corpus/core/` or
|
|
43
44
|
`node_modules/@agent-native/core/corpus/templates/`.
|
|
44
45
|
|
|
46
|
+
Readable Toolkit TypeScript is available under
|
|
47
|
+
`node_modules/@agent-native/toolkit/src/`. Before adapting it, read the
|
|
48
|
+
generated app's `customizing-agent-native` skill. Treat installed source as a
|
|
49
|
+
read-only reference, copy only the smallest UI piece into app-owned source, and
|
|
50
|
+
preserve public action, state, auth, and agent-chat runtime contracts.
|
|
51
|
+
|
|
45
52
|
## What To Read First
|
|
46
53
|
|
|
47
54
|
| Task | Start with |
|
|
@@ -409,8 +409,69 @@ these built-in providers:
|
|
|
409
409
|
These entries are available to actions through the shared
|
|
410
410
|
`provider-api-catalog`, `provider-api-docs`, and `provider-api-request` pattern.
|
|
411
411
|
They do not imply that the provider also appears in the remote MCP picker.
|
|
412
|
-
|
|
413
|
-
the
|
|
412
|
+
|
|
413
|
+
### Reuse the Core action factories {#provider-api-factories}
|
|
414
|
+
|
|
415
|
+
Provider API actions are reusable Core primitives, not an implementation to
|
|
416
|
+
copy between apps. App builders should keep a thin action file for each stable
|
|
417
|
+
app-facing action id, then delegate its behavior to the shared factory. That
|
|
418
|
+
keeps app-specific provider enums, descriptions, HTTP exposure, and
|
|
419
|
+
`toolCallable` choices intact while Core owns request safety, auditing,
|
|
420
|
+
credential injection, and staging.
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
import { createProviderApiRequestAction } from "@agent-native/core/provider-api/actions/provider-api";
|
|
424
|
+
|
|
425
|
+
import { MY_APP_ID, getMyProviderApiRuntime } from "../server/provider-api";
|
|
426
|
+
|
|
427
|
+
export default createProviderApiRequestAction(getMyProviderApiRuntime(), {
|
|
428
|
+
appId: MY_APP_ID,
|
|
429
|
+
schema: myProviderRequestSchema,
|
|
430
|
+
description: "Call a configured provider API for this app.",
|
|
431
|
+
http: { method: "POST" },
|
|
432
|
+
toolCallable: false,
|
|
433
|
+
});
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Use `createProviderApiCatalogAction` and `createProviderApiDocsAction` for the
|
|
437
|
+
other two actions. Their runtime is the app's provider runtime; the wrapper is
|
|
438
|
+
where an app deliberately narrows provider ids or preserves its own public
|
|
439
|
+
action contract. Do not reimplement the request, catalog, or docs behavior in
|
|
440
|
+
each template.
|
|
441
|
+
|
|
442
|
+
For data too large to keep in a response, pass `stageAs` to the request action
|
|
443
|
+
and expose thin wrappers around `createQueryStagedDatasetAction`,
|
|
444
|
+
`createListStagedDatasetsAction`, and `createDeleteStagedDatasetAction` (or the
|
|
445
|
+
combined `createStagedDatasetActions`). Set the same `appId` on request and
|
|
446
|
+
staged-dataset factories. Core scopes staged data to that app and the current
|
|
447
|
+
credential owner, so one user's scratch data cannot be queried or deleted by a
|
|
448
|
+
different user or app.
|
|
449
|
+
|
|
450
|
+
### Credentials and custom providers {#provider-api-authority}
|
|
451
|
+
|
|
452
|
+
The provider runtime is the credential authority. It resolves a scoped
|
|
453
|
+
workspace connection, OAuth account, or secret and injects authentication into
|
|
454
|
+
an allowed provider request. Action arguments, provider registrations, and
|
|
455
|
+
docs may name credential keys or connection ids, but must never accept, store,
|
|
456
|
+
or log credential values. Use the app's secrets and onboarding surfaces to
|
|
457
|
+
collect credentials; use workspace grants when an account should be shared
|
|
458
|
+
across apps.
|
|
459
|
+
|
|
460
|
+
Apps can add their own provider integrations. Start with a thin wrapper over a
|
|
461
|
+
runtime that recognizes the provider, then use the catalog and docs actions to
|
|
462
|
+
make its safe capabilities discoverable. Custom-provider registration is
|
|
463
|
+
deliberately opt-in:
|
|
464
|
+
|
|
465
|
+
```ts
|
|
466
|
+
createProviderApiActions(runtime, { customProviderRegistration: true });
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
This exposes the registration action only when the app chooses to support it.
|
|
470
|
+
Registration stores endpoint and credential-key
|
|
471
|
+
metadata, never secret values, and organization-scoped mutations require the
|
|
472
|
+
runtime's authorization checks. A custom provider registration is not a remote
|
|
473
|
+
MCP preset or a webhook adapter; add those separate integrations only when the
|
|
474
|
+
product needs them.
|
|
414
475
|
|
|
415
476
|
## Keep the directory honest {#keep-current}
|
|
416
477
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# ADR: Defer `defineIntegration` Until Authority Boundaries Converge
|
|
2
|
+
|
|
3
|
+
Status: Accepted
|
|
4
|
+
|
|
5
|
+
Date: 2026-07-19
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
Several framework surfaces describe a provider or integration: shared workspace
|
|
10
|
+
connections, Dispatch Vault secrets, custom provider APIs, and managed messaging
|
|
11
|
+
adapters. They are related, but they do not have one interchangeable authority
|
|
12
|
+
model. A generic `defineIntegration(...)` API would imply a shared lifecycle for
|
|
13
|
+
credentials, grants, OAuth installation, request dispatch, and user-visible
|
|
14
|
+
setup before that lifecycle exists.
|
|
15
|
+
|
|
16
|
+
The immediate cost would be an attractive abstraction that either bypasses an
|
|
17
|
+
existing access check or becomes a thin facade over incompatible stores. The
|
|
18
|
+
more serious cost is migration risk: live OAuth and Slack installations cannot
|
|
19
|
+
be lost, silently disconnected, or made invisible while an API is normalized.
|
|
20
|
+
|
|
21
|
+
## Decision
|
|
22
|
+
|
|
23
|
+
Do not add `defineIntegration` yet. Keep each existing authority in its current
|
|
24
|
+
owner and use narrow bridges only where the implementation is demonstrably
|
|
25
|
+
shared. A future integration definition must compose existing authority
|
|
26
|
+
contracts; it must not replace them with a new credential or access model.
|
|
27
|
+
|
|
28
|
+
## Authority Boundary Map
|
|
29
|
+
|
|
30
|
+
| Surface | Current authority | What it owns | Boundary for a future abstraction |
|
|
31
|
+
| -------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| Workspace connections and grants | Core workspace-connections | Shared provider connection metadata, app grants, scoped credential resolution, and readiness | An integration may request a connection only through its app grant. It cannot treat a provider label as access to every workspace credential. |
|
|
33
|
+
| Dispatch Vault | Dispatch | Workspace secret lifecycle, requests, approvals, grants, audit, and sync into app credential scopes | Vault is a credential-distribution authority, not a provider transport or OAuth-install store. A generic integration API must not bypass Vault approval or audit paths. |
|
|
34
|
+
| Custom provider registry | Core provider-api | Scoped provider metadata, allowed hosts, auth descriptor, docs links, SSRF validation, and request-time credential resolution | Registry rows describe an allowed outbound API. They do not grant messaging installation, workspace connection, or Vault access by themselves. |
|
|
35
|
+
| Messaging adapters | Core integrations | Signed inbound webhooks, platform identity, managed installations, token health, scopes, queues, and outbound delivery | A messaging adapter is a runtime channel with its own installation and webhook contract, not just another HTTP provider. |
|
|
36
|
+
|
|
37
|
+
These boundaries deliberately permit one product to use more than one surface:
|
|
38
|
+
for example, a workspace-granted connection can supply provider credentials,
|
|
39
|
+
while Dispatch governs a separately shared secret, and a messaging adapter owns
|
|
40
|
+
an inbound channel installation. No generic record may collapse those distinct
|
|
41
|
+
authorities into one unscoped token reference.
|
|
42
|
+
|
|
43
|
+
## Consequences
|
|
44
|
+
|
|
45
|
+
- Core remains the authority for runtime request context, credential resolution,
|
|
46
|
+
SSRF protection, OAuth tokens, workspace-connection grants, and managed
|
|
47
|
+
messaging installations.
|
|
48
|
+
- Dispatch remains the authority for Vault policy, approval, audit, and
|
|
49
|
+
distribution. Provider code must consume its scoped credential result rather
|
|
50
|
+
than read Vault records directly.
|
|
51
|
+
- Toolkit remains presentation-only. It can render readiness and setup supplied
|
|
52
|
+
by Core adapters, but must not import Core runtime contracts or own provider
|
|
53
|
+
credentials.
|
|
54
|
+
- Reusable low-level helpers are still encouraged when they preserve the owner
|
|
55
|
+
of the data and access decision. Examples include OAuth exchange helpers,
|
|
56
|
+
provider response normalization, and a hardened outbound-delivery primitive.
|
|
57
|
+
|
|
58
|
+
## Deferred Work And Required Follow-ups
|
|
59
|
+
|
|
60
|
+
### Provider API registration reads
|
|
61
|
+
|
|
62
|
+
`provider-api-register` has mutation-side authorization for custom-provider
|
|
63
|
+
scope. Before making registration a general integration primitive, add and test
|
|
64
|
+
equivalent request-context scoping for its list and get operations. The
|
|
65
|
+
operations must resolve the caller's user/org context and return only providers
|
|
66
|
+
visible in that scope; callers must not be able to select an arbitrary
|
|
67
|
+
`scopeId` to enumerate or read another tenant's registry entries.
|
|
68
|
+
|
|
69
|
+
### Clips Slack migration
|
|
70
|
+
|
|
71
|
+
Clips currently has a product-specific Slack unfurl installation: its own
|
|
72
|
+
`slack_installations` metadata, app-secret token references, `link_shared`
|
|
73
|
+
webhook routing, and unfurl-only scopes. Core managed messaging installs use a
|
|
74
|
+
different table and encrypted token-bundle format. Do not replace the Clips
|
|
75
|
+
path until all of the following are true:
|
|
76
|
+
|
|
77
|
+
1. The target store preserves the Clips team/app lookup, owner/org access, and
|
|
78
|
+
unfurl-only scopes.
|
|
79
|
+
2. Webhook handling can dual-read the new managed installation and the legacy
|
|
80
|
+
Clips row, with the existing row as a fallback until migration completion.
|
|
81
|
+
3. Existing app-secret references are imported or safely resolved without
|
|
82
|
+
exposing tokens to route responses.
|
|
83
|
+
4. List, status, disconnect, and signed `link_shared` delivery have migration
|
|
84
|
+
coverage using an existing installation.
|
|
85
|
+
5. Production telemetry proves that the new read path handles live events
|
|
86
|
+
before legacy rows or secret references are removed.
|
|
87
|
+
|
|
88
|
+
### Zoom
|
|
89
|
+
|
|
90
|
+
Zoom is not currently a Core provider-api, workspace-connection, or managed
|
|
91
|
+
messaging catalog entry. It is a real OAuth capability in the Calendar template
|
|
92
|
+
backed by the Scheduling package's video-provider API and Core OAuth-token
|
|
93
|
+
storage. Treat Zoom as a later provider-catalog candidate, not evidence that a
|
|
94
|
+
generic integration API already has a common model. Revisit catalog inclusion
|
|
95
|
+
only when there is a defined owner for connection grants, credential setup,
|
|
96
|
+
token refresh, and the Calendar/Scheduling compatibility contract.
|
|
97
|
+
|
|
98
|
+
## Revisit Criteria
|
|
99
|
+
|
|
100
|
+
Reconsider `defineIntegration` only when all of these are satisfied:
|
|
101
|
+
|
|
102
|
+
1. At least two production consumers share the same lifecycle, not merely a
|
|
103
|
+
provider name or an OAuth exchange endpoint.
|
|
104
|
+
2. The API has explicit ports for request context, authorization, credential
|
|
105
|
+
resolution, token storage, outbound-host policy, and audit ownership.
|
|
106
|
+
3. Workspace-connection grants, Dispatch Vault policy, custom-provider scope,
|
|
107
|
+
and messaging-install access are represented as distinct inputs or are
|
|
108
|
+
explicitly inapplicable; none is inferred from a provider id.
|
|
109
|
+
4. Each migrated surface has a documented compatibility path, dual-read or
|
|
110
|
+
backfill plan where durable data exists, rollback behavior, and focused
|
|
111
|
+
tests for existing installations/connections.
|
|
112
|
+
5. The public API can state what it does not own: domain-specific routes,
|
|
113
|
+
provider-specific payloads, app data models, and presentation UI remain with
|
|
114
|
+
the appropriate app or Toolkit adapter.
|
|
115
|
+
|
|
116
|
+
Until then, prefer focused Core exports and app adapters over a universal
|
|
117
|
+
registration API.
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.113.0",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"./integrations": "./dist/integrations/index.js",
|
|
66
66
|
"./ingestion": "./dist/ingestion/index.js",
|
|
67
67
|
"./search-utils": "./dist/search-utils/index.js",
|
|
68
|
+
"./search": "./dist/search/index.js",
|
|
69
|
+
"./embeddings": "./dist/embeddings/index.js",
|
|
68
70
|
"./automation": "./dist/automation/index.js",
|
|
69
71
|
"./brand-kit": "./dist/brand-kit/index.js",
|
|
70
72
|
"./brand-kit/fig": "./dist/brand-kit/fig/index.js",
|
|
@@ -243,6 +245,7 @@
|
|
|
243
245
|
"./usage": "./dist/usage/store.js",
|
|
244
246
|
"./connections": "./dist/connections/index.js",
|
|
245
247
|
"./provider-api": "./dist/provider-api/index.js",
|
|
248
|
+
"./provider-api/gong": "./dist/provider-api/gong.js",
|
|
246
249
|
"./provider-api/corpus-jobs": "./dist/provider-api/corpus-jobs.js",
|
|
247
250
|
"./provider-api/corpus-jobs-store": "./dist/provider-api/corpus-jobs-store.js",
|
|
248
251
|
"./provider-api/staging": "./dist/provider-api/staging.js",
|
|
@@ -251,7 +254,11 @@
|
|
|
251
254
|
"./provider-api/actions/query-staged-dataset": "./dist/provider-api/actions/query-staged-dataset.js",
|
|
252
255
|
"./provider-api/actions/list-staged-datasets": "./dist/provider-api/actions/list-staged-datasets.js",
|
|
253
256
|
"./provider-api/actions/delete-staged-dataset": "./dist/provider-api/actions/delete-staged-dataset.js",
|
|
257
|
+
"./provider-api/actions/staged-datasets": "./dist/provider-api/actions/staged-datasets.js",
|
|
254
258
|
"./provider-api/actions/github-repo-files": "./dist/provider-api/actions/github-repo-files.js",
|
|
259
|
+
"./provider-api/actions/provider-api": "./dist/provider-api/actions/provider-api.js",
|
|
260
|
+
"./provider-api/actions/provider-api-audit": "./dist/provider-api/actions/provider-api-audit.js",
|
|
261
|
+
"./provider-api/actions/custom-provider-registration": "./dist/provider-api/actions/custom-provider-registration.js",
|
|
255
262
|
"./data-programs": {
|
|
256
263
|
"types": "./dist/data-programs/index.d.ts",
|
|
257
264
|
"default": "./dist/data-programs/index.js"
|
|
@@ -281,6 +281,7 @@ function writeCorpusReadme(stats, baseDir) {
|
|
|
281
281
|
"## Contents",
|
|
282
282
|
"",
|
|
283
283
|
"- `core/` -- source and package files for `@agent-native/core`.",
|
|
284
|
+
"- `toolkit/` -- source and package files for `@agent-native/toolkit`.",
|
|
284
285
|
"- `templates/` -- source-only copies of first-party Agent Native templates.",
|
|
285
286
|
"",
|
|
286
287
|
"Runtime data, local env files, dependency folders, caches, tests, and build",
|
|
@@ -302,6 +303,7 @@ function writeCorpusReadme(stats, baseDir) {
|
|
|
302
303
|
"## Generated Counts",
|
|
303
304
|
"",
|
|
304
305
|
`- core files: ${stats.coreFiles}`,
|
|
306
|
+
`- toolkit files: ${stats.toolkitFiles}`,
|
|
305
307
|
`- template files: ${stats.templateFiles}`,
|
|
306
308
|
"",
|
|
307
309
|
];
|
|
@@ -372,10 +374,15 @@ export function materializeSourceCorpus() {
|
|
|
372
374
|
mkdirSync(tempDir, { recursive: true });
|
|
373
375
|
|
|
374
376
|
const coreStats = copySourceFiles("packages/core", "core", tempDir);
|
|
377
|
+
const toolkitStats = copySourceFiles("packages/toolkit", "toolkit", tempDir);
|
|
375
378
|
const templateStats = copySourceFiles("templates", "templates", tempDir);
|
|
376
379
|
|
|
377
380
|
writeCorpusReadme(
|
|
378
|
-
{
|
|
381
|
+
{
|
|
382
|
+
coreFiles: coreStats.files,
|
|
383
|
+
toolkitFiles: toolkitStats.files,
|
|
384
|
+
templateFiles: templateStats.files,
|
|
385
|
+
},
|
|
379
386
|
tempDir,
|
|
380
387
|
);
|
|
381
388
|
|
|
@@ -386,7 +393,7 @@ export function materializeSourceCorpus() {
|
|
|
386
393
|
? ""
|
|
387
394
|
: " (accepted a concurrent run's equivalent corpus)";
|
|
388
395
|
console.log(
|
|
389
|
-
`[agent-native] Materialized source corpus at ${size} (${coreStats.files} core files, ${templateStats.files} template files).${note}`,
|
|
396
|
+
`[agent-native] Materialized source corpus at ${size} (${coreStats.files} core files, ${toolkitStats.files} toolkit files, ${templateStats.files} template files).${note}`,
|
|
390
397
|
);
|
|
391
398
|
}
|
|
392
399
|
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const LOCK_WAIT_MS = 10_000;
|
|
6
|
+
const STALE_LOCK_MS = 30_000;
|
|
7
|
+
const lockWaiter = new Int32Array(new SharedArrayBuffer(4));
|
|
8
|
+
|
|
9
|
+
export interface FileLockOptions {
|
|
10
|
+
lockWaitMs?: number;
|
|
11
|
+
staleLockMs?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Durable writers wait long enough to reclaim a fresh dead owner. Hot paths
|
|
14
|
+
* may opt out and handle a short best-effort timeout themselves.
|
|
15
|
+
*/
|
|
16
|
+
reclaimFreshDeadOwner?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AtomicJsonLineOptions {
|
|
20
|
+
mode?: number;
|
|
21
|
+
lock?: FileLockOptions;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface FileLockMetadata {
|
|
25
|
+
pid: number;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
token: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function withFileLockSync<T>(
|
|
31
|
+
filePath: string,
|
|
32
|
+
action: () => T,
|
|
33
|
+
options: FileLockOptions = {},
|
|
34
|
+
): T {
|
|
35
|
+
const lockPath = `${filePath}.lock`;
|
|
36
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
37
|
+
const owner = acquireFileLockSync(lockPath, options);
|
|
38
|
+
try {
|
|
39
|
+
return action();
|
|
40
|
+
} finally {
|
|
41
|
+
releaseFileLockSync(lockPath, owner);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function writeJsonFileAtomically(
|
|
46
|
+
filePath: string,
|
|
47
|
+
value: unknown,
|
|
48
|
+
options?: { mode?: number },
|
|
49
|
+
): void {
|
|
50
|
+
writeTextFileAtomically(
|
|
51
|
+
filePath,
|
|
52
|
+
`${JSON.stringify(value, null, 2)}\n`,
|
|
53
|
+
options,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function writeTextFileAtomically(
|
|
58
|
+
filePath: string,
|
|
59
|
+
content: string,
|
|
60
|
+
options?: { mode?: number },
|
|
61
|
+
): void {
|
|
62
|
+
const directory = path.dirname(filePath);
|
|
63
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
64
|
+
const temporaryPath = path.join(
|
|
65
|
+
directory,
|
|
66
|
+
`.${path.basename(filePath)}.tmp-${process.pid}-${crypto.randomUUID()}`,
|
|
67
|
+
);
|
|
68
|
+
let mode = options?.mode;
|
|
69
|
+
if (mode === undefined) {
|
|
70
|
+
try {
|
|
71
|
+
mode = fs.statSync(filePath).mode & 0o777;
|
|
72
|
+
} catch {
|
|
73
|
+
// New files use the process umask.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
fs.writeFileSync(temporaryPath, content, {
|
|
79
|
+
encoding: "utf-8",
|
|
80
|
+
flag: "wx",
|
|
81
|
+
...(mode === undefined ? {} : { mode }),
|
|
82
|
+
});
|
|
83
|
+
fs.renameSync(temporaryPath, filePath);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
fs.rmSync(temporaryPath, { force: true });
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function updateJsonFileAtomically<T>(
|
|
91
|
+
filePath: string,
|
|
92
|
+
parse: (value: unknown) => T | null,
|
|
93
|
+
update: (current: T | null) => T | null,
|
|
94
|
+
options?: { lock?: FileLockOptions },
|
|
95
|
+
): T | null {
|
|
96
|
+
return withFileLockSync(
|
|
97
|
+
filePath,
|
|
98
|
+
() => {
|
|
99
|
+
const current = readJsonFile(filePath, parse);
|
|
100
|
+
const next = update(current);
|
|
101
|
+
if (next !== null) writeJsonFileAtomically(filePath, next);
|
|
102
|
+
return next;
|
|
103
|
+
},
|
|
104
|
+
options?.lock,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function appendUniqueJsonLineAtomically<T extends { id: string }>(
|
|
109
|
+
filePath: string,
|
|
110
|
+
value: T,
|
|
111
|
+
parse: (value: unknown) => T | null,
|
|
112
|
+
options?: AtomicJsonLineOptions,
|
|
113
|
+
): { value: T; appended: boolean } {
|
|
114
|
+
return withFileLockSync(
|
|
115
|
+
filePath,
|
|
116
|
+
() => {
|
|
117
|
+
if (fs.existsSync(filePath)) {
|
|
118
|
+
for (const line of fs.readFileSync(filePath, "utf-8").split(/\r?\n/)) {
|
|
119
|
+
if (!line) continue;
|
|
120
|
+
try {
|
|
121
|
+
const existing = parse(JSON.parse(line) as unknown);
|
|
122
|
+
if (existing?.id === value.id) {
|
|
123
|
+
return { value: existing, appended: false };
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
// Ignore malformed legacy lines; valid events remain append-only.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
fs.appendFileSync(filePath, `${JSON.stringify(value)}\n`, {
|
|
131
|
+
encoding: "utf-8",
|
|
132
|
+
...(options?.mode === undefined ? {} : { mode: options.mode }),
|
|
133
|
+
});
|
|
134
|
+
return { value, appended: true };
|
|
135
|
+
},
|
|
136
|
+
options?.lock,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function readJsonFile<T>(
|
|
141
|
+
filePath: string,
|
|
142
|
+
parse: (value: unknown) => T | null,
|
|
143
|
+
): T | null {
|
|
144
|
+
try {
|
|
145
|
+
return parse(JSON.parse(fs.readFileSync(filePath, "utf-8")) as unknown);
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function acquireFileLockSync(
|
|
152
|
+
lockPath: string,
|
|
153
|
+
options: FileLockOptions,
|
|
154
|
+
): FileLockMetadata {
|
|
155
|
+
const startedAt = Date.now();
|
|
156
|
+
while (true) {
|
|
157
|
+
if (hasActiveReaper(lockPath, options)) {
|
|
158
|
+
waitForFileLock(lockPath, startedAt, options);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const metadata: FileLockMetadata = {
|
|
162
|
+
pid: process.pid,
|
|
163
|
+
createdAt: Date.now(),
|
|
164
|
+
token: crypto.randomUUID(),
|
|
165
|
+
};
|
|
166
|
+
let fd: number | undefined;
|
|
167
|
+
try {
|
|
168
|
+
fd = fs.openSync(lockPath, "wx", 0o600);
|
|
169
|
+
fs.writeFileSync(fd, JSON.stringify(metadata), "utf-8");
|
|
170
|
+
return metadata;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
173
|
+
recoverStaleFileLock(lockPath, options);
|
|
174
|
+
if (!fs.existsSync(lockPath)) continue;
|
|
175
|
+
waitForFileLock(lockPath, startedAt, options);
|
|
176
|
+
} finally {
|
|
177
|
+
if (fd !== undefined) fs.closeSync(fd);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function recoverStaleFileLock(
|
|
183
|
+
lockPath: string,
|
|
184
|
+
options: FileLockOptions,
|
|
185
|
+
): void {
|
|
186
|
+
const reaperPath = `${lockPath}.reaper`;
|
|
187
|
+
const reaper = tryAcquireFileLock(reaperPath);
|
|
188
|
+
if (!reaper) return;
|
|
189
|
+
try {
|
|
190
|
+
const stale = readFileLockMetadata(lockPath);
|
|
191
|
+
if (!isStaleDeadOwner(stale, options)) return;
|
|
192
|
+
const confirmed = readFileLockMetadata(lockPath);
|
|
193
|
+
if (!sameFileLock(stale, confirmed)) return;
|
|
194
|
+
releaseFileLockSync(lockPath, stale);
|
|
195
|
+
} finally {
|
|
196
|
+
releaseFileLockSync(reaperPath, reaper);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function hasActiveReaper(lockPath: string, options: FileLockOptions): boolean {
|
|
201
|
+
const reaperPath = `${lockPath}.reaper`;
|
|
202
|
+
const reaper = readFileLockMetadata(reaperPath);
|
|
203
|
+
if (!reaper) return false;
|
|
204
|
+
if (!isStaleDeadOwner(reaper, options)) return true;
|
|
205
|
+
releaseFileLockSync(reaperPath, reaper);
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function tryAcquireFileLock(lockPath: string): FileLockMetadata | null {
|
|
210
|
+
const metadata: FileLockMetadata = {
|
|
211
|
+
pid: process.pid,
|
|
212
|
+
createdAt: Date.now(),
|
|
213
|
+
token: crypto.randomUUID(),
|
|
214
|
+
};
|
|
215
|
+
let fd: number | undefined;
|
|
216
|
+
try {
|
|
217
|
+
fd = fs.openSync(lockPath, "wx", 0o600);
|
|
218
|
+
fs.writeFileSync(fd, JSON.stringify(metadata), "utf-8");
|
|
219
|
+
return metadata;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if ((error as NodeJS.ErrnoException).code === "EEXIST") return null;
|
|
222
|
+
throw error;
|
|
223
|
+
} finally {
|
|
224
|
+
if (fd !== undefined) fs.closeSync(fd);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function releaseFileLockSync(lockPath: string, owner: FileLockMetadata): void {
|
|
229
|
+
if (!sameFileLock(owner, readFileLockMetadata(lockPath))) return;
|
|
230
|
+
try {
|
|
231
|
+
fs.rmSync(lockPath);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function readFileLockMetadata(lockPath: string): FileLockMetadata | null {
|
|
238
|
+
try {
|
|
239
|
+
const parsed = JSON.parse(fs.readFileSync(lockPath, "utf-8")) as unknown;
|
|
240
|
+
if (
|
|
241
|
+
parsed &&
|
|
242
|
+
typeof parsed === "object" &&
|
|
243
|
+
typeof (parsed as FileLockMetadata).pid === "number" &&
|
|
244
|
+
typeof (parsed as FileLockMetadata).createdAt === "number" &&
|
|
245
|
+
typeof (parsed as FileLockMetadata).token === "string"
|
|
246
|
+
) {
|
|
247
|
+
return parsed as FileLockMetadata;
|
|
248
|
+
}
|
|
249
|
+
} catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function sameFileLock(
|
|
256
|
+
left: FileLockMetadata | null,
|
|
257
|
+
right: FileLockMetadata | null,
|
|
258
|
+
): boolean {
|
|
259
|
+
return Boolean(
|
|
260
|
+
left &&
|
|
261
|
+
right &&
|
|
262
|
+
left.pid === right.pid &&
|
|
263
|
+
left.createdAt === right.createdAt &&
|
|
264
|
+
left.token === right.token,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function isStaleDeadOwner(
|
|
269
|
+
metadata: FileLockMetadata | null,
|
|
270
|
+
options: FileLockOptions,
|
|
271
|
+
): metadata is FileLockMetadata {
|
|
272
|
+
return (
|
|
273
|
+
metadata !== null &&
|
|
274
|
+
Date.now() - metadata.createdAt >= staleLockMs(options) &&
|
|
275
|
+
!isProcessAlive(metadata.pid)
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function waitForFileLock(
|
|
280
|
+
lockPath: string,
|
|
281
|
+
startedAt: number,
|
|
282
|
+
options: FileLockOptions,
|
|
283
|
+
): void {
|
|
284
|
+
if (
|
|
285
|
+
Date.now() - startedAt >=
|
|
286
|
+
lockWaitBudgetMs(lockPath, startedAt, options)
|
|
287
|
+
) {
|
|
288
|
+
throw new Error(`Timed out waiting for local store lock: ${lockPath}`);
|
|
289
|
+
}
|
|
290
|
+
Atomics.wait(lockWaiter, 0, 0, 8 + Math.floor(Math.random() * 8));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function lockWaitBudgetMs(
|
|
294
|
+
lockPath: string,
|
|
295
|
+
startedAt: number,
|
|
296
|
+
options: FileLockOptions,
|
|
297
|
+
): number {
|
|
298
|
+
const configured = options.lockWaitMs ?? LOCK_WAIT_MS;
|
|
299
|
+
if (options.reclaimFreshDeadOwner === false) return configured;
|
|
300
|
+
const owner = readFileLockMetadata(lockPath);
|
|
301
|
+
if (!owner || isProcessAlive(owner.pid)) return configured;
|
|
302
|
+
const remainingUntilStale = Math.max(
|
|
303
|
+
0,
|
|
304
|
+
staleLockMs(options) - (Date.now() - owner.createdAt),
|
|
305
|
+
);
|
|
306
|
+
return Math.max(
|
|
307
|
+
configured,
|
|
308
|
+
Date.now() - startedAt + remainingUntilStale + 32,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function staleLockMs(options: FileLockOptions): number {
|
|
313
|
+
return options.staleLockMs ?? STALE_LOCK_MS;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function isProcessAlive(pid: number): boolean {
|
|
317
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
318
|
+
try {
|
|
319
|
+
process.kill(pid, 0);
|
|
320
|
+
return true;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
return (error as NodeJS.ErrnoException).code === "EPERM";
|
|
323
|
+
}
|
|
324
|
+
}
|