@egbe-ai/opencode 0.0.0-stage → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +124 -2
- package/index.js +5 -0
- package/package.json +55 -4
- package/plugin.js +230 -0
- package/session-log.js +315 -0
- package/skills/.egbe-catalog/manifest.json +1 -0
- package/skills/egbe-os-analytics/SKILL.md +499 -0
- package/skills/egbe-os-analytics/canonical-events.v1.json +256 -0
- package/skills/egbe-os-analytics/references/session-funnel.md +130 -0
- package/skills/egbe-os-analytics/references/workflows/activation-tracking.md +147 -0
- package/skills/egbe-os-analytics/references/workflows/landing-click-tracking.md +209 -0
- package/skills/egbe-os-analytics/references/workflows/payment-lifecycle-tracking.md +122 -0
- package/skills/egbe-os-analytics/references/workflows/product-funnel-tracking.md +77 -0
- package/skills/egbe-os-analytics/references/workflows/signup-lifecycle-tracking.md +208 -0
- package/skills/egbe-os-analytics/scripts/umami_funnel.py +927 -0
- package/skills/egbe-os-apollo-lead-finder/SKILL.md +135 -0
- package/skills/egbe-os-apollo-lead-finder/references/operations.md +240 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/apollo-client.js +343 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/helpers.js +127 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/places-filters.js +217 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/sourcing.js +153 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.js +653 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.sh +4 -0
- package/skills/egbe-os-campaign-landing-page/SKILL.md +95 -0
- package/skills/egbe-os-campaign-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-campaign-landing-page/references/leads-calendar-and-tracking.md +66 -0
- package/skills/egbe-os-campaign-landing-page/references/os-wiring.md +58 -0
- package/skills/egbe-os-campaign-landing-page/references/qa.md +40 -0
- package/skills/egbe-os-campaign-landing-page/references/routing.md +32 -0
- package/skills/egbe-os-db/SKILL.md +174 -0
- package/skills/egbe-os-deploy/SKILL.md +412 -0
- package/skills/egbe-os-design/SKILL.md +182 -0
- package/skills/egbe-os-design-landing-page/SKILL.md +117 -0
- package/skills/egbe-os-design-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/.dockerignore +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/AGENTS.md +31 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/Dockerfile +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/eslint.config.mjs +18 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/next.config.ts +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/package.json +36 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/postcss.config.mjs +7 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/public/.gitkeep +1 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.edge.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.server.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/global-error.tsx +19 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/globals.css +22 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/layout.tsx +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/page.tsx +3 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/privacy/page.tsx +28 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/components/egbe-analytics.tsx +39 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation-client.ts +15 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/egbe-observability.generated.ts +20 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/utils.ts +6 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/tsconfig.json +34 -0
- package/skills/egbe-os-design-landing-page/references/application-preparation.md +44 -0
- package/skills/egbe-os-design-landing-page/references/page-inputs.md +22 -0
- package/skills/egbe-os-destination-readiness/SKILL.md +132 -0
- package/skills/egbe-os-destination-readiness/references/checks.md +130 -0
- package/skills/egbe-os-destination-readiness/references/network-requirements.md +34 -0
- package/skills/egbe-os-destination-readiness/references/report.md +116 -0
- package/skills/egbe-os-domains/SKILL.md +189 -0
- package/skills/egbe-os-errors/SKILL.md +259 -0
- package/skills/egbe-os-git/SKILL.md +275 -0
- package/skills/egbe-os-git/references/issues.md +33 -0
- package/skills/egbe-os-google-ads/SKILL.md +163 -0
- package/skills/egbe-os-google-ads/references/artifacts.md +133 -0
- package/skills/egbe-os-google-ads/references/campaigns.md +157 -0
- package/skills/egbe-os-google-ads/references/conversions.md +153 -0
- package/skills/egbe-os-google-ads/references/delivery.md +128 -0
- package/skills/egbe-os-google-ads/references/keyword-ideas.md +40 -0
- package/skills/egbe-os-google-ads/references/reporting.md +105 -0
- package/skills/egbe-os-google-ads/references/search-assets.md +219 -0
- package/skills/egbe-os-google-ads/references/server-conversions.md +119 -0
- package/skills/egbe-os-google-auth/SKILL.md +285 -0
- package/skills/egbe-os-google-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-gtm-knowledge/SKILL.md +151 -0
- package/skills/egbe-os-images/SKILL.md +163 -0
- package/skills/egbe-os-images/references/stock-images.md +21 -0
- package/skills/egbe-os-instantly-campaign-launcher/SKILL.md +127 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/instantly-ops.md +260 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/observation-and-scheduling.md +188 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/reply-handling.md +116 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-spec-template.json +65 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-state.md +145 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/conclude-campaign.js +158 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/install-crons.js +956 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/launch-campaign.js +2008 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/campaign-metrics.js +124 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/confirmed-opt-outs.js +208 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/create-once.js +23 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/gtm-identity.js +125 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/helpers.js +545 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/html-body.js +266 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/instantly-client.js +328 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/outreach-db.js +370 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/recipient-exclusion/index.js +86 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/replenish-test-harness.js +53 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/reply-queue.js +67 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/run-config.js +103 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/sender-selection.js +105 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/monitor-campaign.js +607 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/outreach-report.js +147 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/replenish-leads.js +619 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/reply-worker.js +258 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/run-cron-job.js +32 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/send-reply.js +260 -0
- package/skills/egbe-os-linkedin-ads/SKILL.md +114 -0
- package/skills/egbe-os-linkedin-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/api-reference.md +154 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/artifacts.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/build-paused.md +44 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/conversions.md +88 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/launch-and-pause.md +49 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/monitoring.md +35 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/readiness.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/targeting-and-creative.md +52 -0
- package/skills/egbe-os-llm/SKILL.md +160 -0
- package/skills/egbe-os-mail/SKILL.md +180 -0
- package/skills/egbe-os-me/SKILL.md +119 -0
- package/skills/egbe-os-meta-ads/SKILL.md +114 -0
- package/skills/egbe-os-meta-ads/references/creative/creative-specs.md +15 -0
- package/skills/egbe-os-meta-ads/references/creative/talking-head.md +35 -0
- package/skills/egbe-os-meta-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-meta-ads/references/runtime/api-reference.md +436 -0
- package/skills/egbe-os-meta-ads/references/runtime/artifacts.md +51 -0
- package/skills/egbe-os-meta-ads/references/runtime/insights-reference.md +187 -0
- package/skills/egbe-os-meta-ads/references/runtime/pixel-install.md +196 -0
- package/skills/egbe-os-meta-ads/references/runtime/shared-analytics-attribution.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/build-paused.md +36 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch-ready.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch.md +23 -0
- package/skills/egbe-os-meta-ads/references/workflows/monitoring.md +72 -0
- package/skills/egbe-os-meta-ads/references/workflows/pause.md +17 -0
- package/skills/egbe-os-meta-ads/references/workflows/recovery.md +23 -0
- package/skills/egbe-os-meta-ads/scripts/check-pixel.py +229 -0
- package/skills/egbe-os-meta-ads/scripts/validate-meta-artifacts.py +187 -0
- package/skills/egbe-os-notifications/SKILL.md +78 -0
- package/skills/egbe-os-openai-ads/SKILL.md +149 -0
- package/skills/egbe-os-openai-ads/references/creative/chat-card.md +51 -0
- package/skills/egbe-os-openai-ads/references/destination-requirements.md +29 -0
- package/skills/egbe-os-openai-ads/references/runtime/api-reference.md +219 -0
- package/skills/egbe-os-openai-ads/references/runtime/artifacts.md +169 -0
- package/skills/egbe-os-openai-ads/references/workflows/build-paused.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/conversions.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/creative-assembly.md +24 -0
- package/skills/egbe-os-openai-ads/references/workflows/launch.md +27 -0
- package/skills/egbe-os-openai-ads/references/workflows/monitoring.md +54 -0
- package/skills/egbe-os-openai-ads/references/workflows/pause.md +22 -0
- package/skills/egbe-os-openai-ads/references/workflows/readiness.md +37 -0
- package/skills/egbe-os-openai-ads/references/workflows/tracking.md +32 -0
- package/skills/egbe-os-openai-ads/scripts/validate-openai-artifacts.py +271 -0
- package/skills/egbe-os-organic-trend-watch/SKILL.md +139 -0
- package/skills/egbe-os-organic-trend-watch/agents/openai.yaml +4 -0
- package/skills/egbe-os-organic-trend-watch/references/analysis-and-adaptation.md +54 -0
- package/skills/egbe-os-organic-trend-watch/references/collection-and-analysis.md +117 -0
- package/skills/egbe-os-organic-trend-watch/references/output-contract.md +133 -0
- package/skills/egbe-os-organic-trend-watch/references/provider-contract.md +169 -0
- package/skills/egbe-os-organic-trend-watch/references/runtime-contract.md +204 -0
- package/skills/egbe-os-organic-trend-watch/references/visual-analysis-prompt.md +17 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_analysis.py +612 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_contract.py +1133 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_provider_inputs.py +165 -0
- package/skills/egbe-os-organic-trend-watch/scripts/analyze-visual-evidence.py +315 -0
- package/skills/egbe-os-organic-trend-watch/scripts/build-provider-inputs.py +88 -0
- package/skills/egbe-os-organic-trend-watch/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-organic-trend-watch/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-organic-trend-watch/scripts/finalize-receipt.py +106 -0
- package/skills/egbe-os-organic-trend-watch/scripts/normalize-videos.py +647 -0
- package/skills/egbe-os-organic-trend-watch/scripts/prepare-visual-evidence.py +324 -0
- package/skills/egbe-os-organic-trend-watch/scripts/render-result.py +30 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-apify.py +723 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-state.py +192 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-context.py +27 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-runtime.py +137 -0
- package/skills/egbe-os-payments/SKILL.md +215 -0
- package/skills/egbe-os-payments/agents/openai.yaml +4 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/.egbe/scaffolds/billing-nextjs-subscription.v1.json +5 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/AGENTS.append.md +13 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/db/migrations/1000_egbe_billing.sql +66 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/package.fragment.json +12 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/scripts/billing-sync.mjs +162 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/error.tsx +11 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/loading.tsx +8 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/page.tsx +121 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/checkout/route.ts +102 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/portal/route.ts +54 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/status/route.ts +22 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/payments/webhook/route.ts +65 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/components/egbe-billing/plan-badge.tsx +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/billing-sync.test.mjs +58 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/catalog.ts +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/checkout-payload.ts +47 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/foundation-contract.test.mjs +59 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.d.ts +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.mjs +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.test.mjs +94 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/os-client.ts +96 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/plans.json +17 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/repository.ts +325 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.d.ts +6 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.mjs +22 -0
- package/skills/egbe-os-payments/references/contracts/plan-catalog.md +46 -0
- package/skills/egbe-os-payments/references/security/durable-verification.md +64 -0
- package/skills/egbe-os-payments/references/security/server-integration.md +26 -0
- package/skills/egbe-os-payments/references/security/webhook-and-entitlements.md +152 -0
- package/skills/egbe-os-payments/references/ux/billing-experience.md +47 -0
- package/skills/egbe-os-payments/references/workflows/account-billing.md +64 -0
- package/skills/egbe-os-payments/references/workflows/discounts-and-promotion-codes.md +265 -0
- package/skills/egbe-os-payments/references/workflows/one-time-purchase.md +75 -0
- package/skills/egbe-os-payments/references/workflows/product-checkout.md +355 -0
- package/skills/egbe-os-payments/references/workflows/subscription-lifecycle.md +55 -0
- package/skills/egbe-os-playbook/SKILL.md +79 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/email-outreach.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/google-search.md +40 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/linkedin.md +24 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/meta.md +23 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/openai.md +15 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/reddit.md +56 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/choose-test.md +73 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/evaluate.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/market.md +96 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/run-test.md +111 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition.md +56 -0
- package/skills/egbe-os-playbook/playbooks/product/business-loop.md +141 -0
- package/skills/egbe-os-playbook/playbooks/product/collaboration.md +26 -0
- package/skills/egbe-os-playbook/playbooks/product/deliver.md +75 -0
- package/skills/egbe-os-playbook/playbooks/product/diagnose.md +80 -0
- package/skills/egbe-os-playbook/playbooks/product/evaluate.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/experience.md +132 -0
- package/skills/egbe-os-playbook/playbooks/product/loop-examples.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/offer.md +65 -0
- package/skills/egbe-os-playbook/playbooks/product/value.md +91 -0
- package/skills/egbe-os-playbook/playbooks/product.md +67 -0
- package/skills/egbe-os-playbook/references/catalog.md +127 -0
- package/skills/egbe-os-playbook/references/changes.md +167 -0
- package/skills/egbe-os-playbook/scripts/playbook-changes.py +6 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/__init__.py +1 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/cli.py +57 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/operations.py +137 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/protocol.py +132 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/storage.py +180 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/transport.py +113 -0
- package/skills/egbe-os-product-auth/SKILL.md +151 -0
- package/skills/egbe-os-product-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-auth/assets/db/README.md +102 -0
- package/skills/egbe-os-product-auth/assets/db/create-validation-session.mjs +223 -0
- package/skills/egbe-os-product-auth/assets/db/migrate.mjs +64 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0001_auth.sql +33 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0002_auth_identities.sql +16 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/AGENTS.append.md +17 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/package.fragment.json +10 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/AGENTS.append.md +9 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/package.fragment.json +13 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/db.ts +31 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/identity.ts +94 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/index.ts +3 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/session.ts +91 -0
- package/skills/egbe-os-product-auth/references/contracts/live-auth-interface.md +108 -0
- package/skills/egbe-os-product-auth/references/frameworks/nextjs.md +34 -0
- package/skills/egbe-os-product-auth/references/security/session-and-credentials.md +73 -0
- package/skills/egbe-os-product-auth/references/ux/auth-experience.md +58 -0
- package/skills/egbe-os-product-auth/references/workflows/account-recovery.md +22 -0
- package/skills/egbe-os-product-auth/references/workflows/build-auth.md +212 -0
- package/skills/egbe-os-product-auth/references/workflows/google.md +34 -0
- package/skills/egbe-os-product-auth/references/workflows/passwordless-email.md +65 -0
- package/skills/egbe-os-product-build/SKILL.md +111 -0
- package/skills/egbe-os-product-build/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-build/references/capabilities.md +25 -0
- package/skills/egbe-os-product-build/references/engineering.md +72 -0
- package/skills/egbe-os-product-build/references/execution.md +55 -0
- package/skills/egbe-os-product-build/references/foundations.md +93 -0
- package/skills/egbe-os-product-build/references/interface-quality.md +32 -0
- package/skills/egbe-os-product-build/references/workflows/private-review-handoff.md +86 -0
- package/skills/egbe-os-product-build/scripts/scaffold.py +296 -0
- package/skills/egbe-os-product-demo-video/SKILL.md +118 -0
- package/skills/egbe-os-product-demo-video/references/recording.md +32 -0
- package/skills/egbe-os-product-market-research/SKILL.md +159 -0
- package/skills/egbe-os-product-market-research/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-market-research/references/catalog.v1.json +177 -0
- package/skills/egbe-os-product-market-research/references/config/channel-footprint-sources.v1.json +99 -0
- package/skills/egbe-os-product-market-research/references/config/creative-taxonomy.v1.json +367 -0
- package/skills/egbe-os-product-market-research/references/contracts/creative-video.md +75 -0
- package/skills/egbe-os-product-market-research/references/contracts/funnel-teardown.md +235 -0
- package/skills/egbe-os-product-market-research/references/contracts/geography-comparison.md +71 -0
- package/skills/egbe-os-product-market-research/references/contracts/lifecycle-capture.md +119 -0
- package/skills/egbe-os-product-market-research/references/contracts/research-artifacts.md +520 -0
- package/skills/egbe-os-product-market-research/references/contracts/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.md +137 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.md +118 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.md +154 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.md +100 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.md +126 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.md +98 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.md +217 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.md +113 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/workflows/acquisition-channels.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/channel-footprint.md +163 -0
- package/skills/egbe-os-product-market-research/references/workflows/community-demand.md +100 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitive-landscape.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-ads.md +82 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-set.md +300 -0
- package/skills/egbe-os-product-market-research/references/workflows/creative-patterns.md +228 -0
- package/skills/egbe-os-product-market-research/references/workflows/demand-validation.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/fleet-prior.md +80 -0
- package/skills/egbe-os-product-market-research/references/workflows/funnel-teardown.md +184 -0
- package/skills/egbe-os-product-market-research/references/workflows/geography-comparison.md +84 -0
- package/skills/egbe-os-product-market-research/references/workflows/keyword-economics.md +122 -0
- package/skills/egbe-os-product-market-research/references/workflows/lifecycle-capture.md +218 -0
- package/skills/egbe-os-product-market-research/references/workflows/local-research.md +55 -0
- package/skills/egbe-os-product-market-research/references/workflows/market-size-and-dynamics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/preview.md +175 -0
- package/skills/egbe-os-product-market-research/references/workflows/pricing-and-monetization.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/recommendations.md +35 -0
- package/skills/egbe-os-product-market-research/references/workflows/review-mining.md +76 -0
- package/skills/egbe-os-product-market-research/references/workflows/target-audience.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/tiktok-reels-market-trends.md +46 -0
- package/skills/egbe-os-product-market-research/references/workflows/unit-economics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/value-proposition.md +27 -0
- package/skills/egbe-os-product-market-research/scripts/build-organic-trend-context.py +167 -0
- package/skills/egbe-os-product-market-research/scripts/build-preview-context.py +91 -0
- package/skills/egbe-os-product-market-research/scripts/build-research-query.py +225 -0
- package/skills/egbe-os-product-market-research/scripts/channel-footprint-model.py +294 -0
- package/skills/egbe-os-product-market-research/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-product-market-research/scripts/creative-model.py +364 -0
- package/skills/egbe-os-product-market-research/scripts/creative-selection.py +113 -0
- package/skills/egbe-os-product-market-research/scripts/creative-semantics.py +365 -0
- package/skills/egbe-os-product-market-research/scripts/creative-video.py +542 -0
- package/skills/egbe-os-product-market-research/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-product-market-research/scripts/finalize-organic-trend-watch.py +304 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-email-review.py +97 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-model.py +966 -0
- package/skills/egbe-os-product-market-research/scripts/funnel_features.py +50 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison-contract.py +172 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison.py +169 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-forecast.py +61 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-locale-publication.py +136 -0
- package/skills/egbe-os-product-market-research/scripts/lifecycle-start.py +190 -0
- package/skills/egbe-os-product-market-research/scripts/persist-research-report.py +63 -0
- package/skills/egbe-os-product-market-research/scripts/research-artifact-io.py +281 -0
- package/skills/egbe-os-product-market-research/scripts/research-evidence.py +496 -0
- package/skills/egbe-os-product-market-research/scripts/research-policy.py +33 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-runtime.py +343 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-workflow.py +288 -0
- package/skills/egbe-os-product-market-research/scripts/research_integrity.py +122 -0
- package/skills/egbe-os-product-market-research/scripts/review-research-completion.py +306 -0
- package/skills/egbe-os-product-market-research/scripts/run-acquisition-channels.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-channel-footprint.py +2258 -0
- package/skills/egbe-os-product-market-research/scripts/run-community-demand.py +1603 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitive-landscape.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-ads.py +1156 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-set.py +2514 -0
- package/skills/egbe-os-product-market-research/scripts/run-creative-patterns.py +2042 -0
- package/skills/egbe-os-product-market-research/scripts/run-demand-validation.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-fleet-prior.py +652 -0
- package/skills/egbe-os-product-market-research/scripts/run-funnel-teardown.py +493 -0
- package/skills/egbe-os-product-market-research/scripts/run-keyword-economics.py +1443 -0
- package/skills/egbe-os-product-market-research/scripts/run-lifecycle-capture.py +1543 -0
- package/skills/egbe-os-product-market-research/scripts/run-market-size-and-dynamics.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-os-research.py +311 -0
- package/skills/egbe-os-product-market-research/scripts/run-pricing-and-monetization.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-review-mining.py +1051 -0
- package/skills/egbe-os-product-market-research/scripts/run-target-audience.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-unit-economics.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-value-proposition.py +67 -0
- package/skills/egbe-os-product-market-research/scripts/upsert-markdown-section.py +156 -0
- package/skills/egbe-os-product-market-research/scripts/walk-funnels.py +249 -0
- package/skills/egbe-os-product-market-research/scripts/write-preview.py +710 -0
- package/skills/egbe-os-product-market-research/scripts/write-recommendations.py +272 -0
- package/skills/egbe-os-product-report/SKILL.md +150 -0
- package/skills/egbe-os-product-report/references/artifacts.md +84 -0
- package/skills/egbe-os-product-report/references/brief.md +34 -0
- package/skills/egbe-os-product-report/references/daily.md +76 -0
- package/skills/egbe-os-product-report/references/sources.md +68 -0
- package/skills/egbe-os-product-routines/SKILL.md +166 -0
- package/skills/egbe-os-product-routines/references/catalog.md +22 -0
- package/skills/egbe-os-product-routines/references/continuation-check.md +41 -0
- package/skills/egbe-os-product-routines/references/product-reporting.md +163 -0
- package/skills/egbe-os-product-routines/references/run-preset.md +32 -0
- package/skills/egbe-os-quickstart/scripts/egbe-curl.py +357 -0
- package/skills/egbe-os-quiz-funnel/SKILL.md +152 -0
- package/skills/egbe-os-quiz-funnel/agents/openai.yaml +4 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.d.mts +224 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.mjs +652 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.test.mjs +764 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.d.mts +31 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.mjs +87 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.test.mjs +265 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-reference.test.mjs +254 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/QUIZ.md +195 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.json +421 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.public.json +369 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/validation.json +21 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/index.html +26 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-bootstrap.js +31 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-early-actions.mjs +11 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-first-screen.mjs +32 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-page.mjs +480 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz.css +264 -0
- package/skills/egbe-os-quiz-funnel/references/competitor-teardown.md +159 -0
- package/skills/egbe-os-quiz-funnel/references/conversion-handoff.md +156 -0
- package/skills/egbe-os-quiz-funnel/references/implementation.md +207 -0
- package/skills/egbe-os-quiz-funnel/references/inputs.md +37 -0
- package/skills/egbe-os-quiz-funnel/references/measurement.md +122 -0
- package/skills/egbe-os-quiz-funnel/references/spec-contract.md +335 -0
- package/skills/egbe-os-quiz-funnel/references/verification.md +101 -0
- package/skills/egbe-os-quiz-funnel/references/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-quiz-funnel/scripts/compile-quiz-spec.py +1869 -0
- package/skills/egbe-os-quiz-funnel/scripts/prepare-research-identity.py +66 -0
- package/skills/egbe-os-reddit-ads/SKILL.md +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/schema.json +41 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/template.html +106 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/schema.json +61 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/template.html +151 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/schema.json +91 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/template.html +185 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/schema.json +51 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/template.html +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/schema.json +87 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/template.html +212 -0
- package/skills/egbe-os-reddit-ads/references/creative/html-to-png-pipeline.md +123 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-qa.md +12 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-system.md +16 -0
- package/skills/egbe-os-reddit-ads/references/destination-requirements.md +36 -0
- package/skills/egbe-os-reddit-ads/references/runtime/api-reference.md +435 -0
- package/skills/egbe-os-reddit-ads/references/runtime/artifacts.md +57 -0
- package/skills/egbe-os-reddit-ads/references/runtime/monitoring.md +64 -0
- package/skills/egbe-os-reddit-ads/references/runtime/pixel-and-tracking.md +49 -0
- package/skills/egbe-os-reddit-ads/references/runtime/policies.md +19 -0
- package/skills/egbe-os-reddit-ads/references/runtime/shared-analytics-attribution.md +14 -0
- package/skills/egbe-os-reddit-ads/references/workflows/build-paused.md +35 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch-ready.md +19 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch.md +32 -0
- package/skills/egbe-os-reddit-ads/references/workflows/readiness.md +9 -0
- package/skills/egbe-os-reddit-ads/scripts/capture-ad.sh +178 -0
- package/skills/egbe-os-reddit-ads/scripts/validate-reddit-artifacts.py +187 -0
- package/skills/egbe-os-report-ui/SKILL.md +133 -0
- package/skills/egbe-os-report-ui/assets/egbe-wordmark.svg +9 -0
- package/skills/egbe-os-report-ui/assets/examples/components.html +417 -0
- package/skills/egbe-os-report-ui/assets/examples/editorial.html +209 -0
- package/skills/egbe-os-report-ui/assets/scaffold.html +179 -0
- package/skills/egbe-os-report-ui/references/components.md +209 -0
- package/skills/egbe-os-research/SKILL.md +125 -0
- package/skills/egbe-os-saas-unit-economics/SKILL.md +188 -0
- package/skills/egbe-os-scrape/SKILL.md +160 -0
- package/skills/egbe-os-search/SKILL.md +182 -0
- package/skills/egbe-os-search/references/google-places.md +81 -0
- package/skills/egbe-os-support/SKILL.md +149 -0
- package/skills/egbe-os-telemetry/SKILL.md +344 -0
- package/skills/egbe-os-telemetry/references/harnesses/claude-code.md +97 -0
- package/skills/egbe-os-telemetry/references/harnesses/codex.md +22 -0
- package/skills/egbe-os-telemetry/references/harnesses/hermes.md +39 -0
- package/skills/egbe-os-telemetry/references/harnesses/openclaw.md +139 -0
- package/skills/egbe-os-telemetry/references/harnesses/opencode.md +28 -0
- package/skills/egbe-os-tools/SKILL.md +180 -0
- package/skills/egbe-os-tools/references/theona.md +26 -0
- package/skills/egbe-os-wallet/SKILL.md +181 -0
- package/skills/egbe-setup/EGBE.md +484 -0
- package/skills/egbe-setup/SKILL.md +116 -0
- package/skills/egbe-setup/references/project.md +80 -0
- package/state.js +37 -0
- package/update.js +361 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { InstantlyClient } = require("./lib/instantly-client");
|
|
4
|
+
const {
|
|
5
|
+
readJson,
|
|
6
|
+
writeJson,
|
|
7
|
+
parseArgs,
|
|
8
|
+
isoNow,
|
|
9
|
+
loadRunEnv,
|
|
10
|
+
getOsConfig,
|
|
11
|
+
assertCampaignNotForeign,
|
|
12
|
+
} = require("./lib/helpers");
|
|
13
|
+
const {
|
|
14
|
+
initDb,
|
|
15
|
+
upsertLead,
|
|
16
|
+
upsertRunLead,
|
|
17
|
+
insertLeadEvent,
|
|
18
|
+
upsertReplyQueueItem,
|
|
19
|
+
queryAll,
|
|
20
|
+
} = require("./lib/outreach-db");
|
|
21
|
+
const { resolveCampaignRecipient, readOptOutHistory } = require("./lib/confirmed-opt-outs");
|
|
22
|
+
const { updateQueue } = require("./lib/reply-queue");
|
|
23
|
+
|
|
24
|
+
// A hint for the agent, not a decision: the agent reads every queued reply and
|
|
25
|
+
// decides by references/reply-handling.md. Refusals and opt-outs are checked
|
|
26
|
+
// before interest so "not interested" never reads as positive.
|
|
27
|
+
function classify(email) {
|
|
28
|
+
const text = String(email?.body?.text || "").toLowerCase();
|
|
29
|
+
if (/\bunsubscribe\b|\bremove me\b|\bopt[- ]?out\b|\b(?:do not|don'?t|never) (?:call|contact|email|e-mail|write to|message) (?:me|us)\b|^\s*stop\s*[.!]?\s*$/m.test(text))
|
|
30
|
+
return "unsubscribe";
|
|
31
|
+
if (/\bnot (?:interested|relevant|a fit)\b|\bno,? thanks?\b|\bwrong person\b|\bnot the right person\b/.test(text))
|
|
32
|
+
return "negative";
|
|
33
|
+
if (/\bprice\b|\bpricing\b|\bcost\b|\bhow much\b/.test(text)) return "pricing";
|
|
34
|
+
if (/\binterested\b|\blet'?s talk\b|\bavailable\b|\bbook\b|\bcall\b|\bdemo\b/.test(text))
|
|
35
|
+
return "positive";
|
|
36
|
+
return "ambiguous";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function unreadReplies(client, campaignId) {
|
|
40
|
+
const items = [];
|
|
41
|
+
const cursors = new Set();
|
|
42
|
+
let cursor;
|
|
43
|
+
// Bound malformed provider pagination and stay within its 20 email reads/min.
|
|
44
|
+
// Collect every page before advancing the local queue/processed checkpoint.
|
|
45
|
+
for (let page = 0; page < 100; page++) {
|
|
46
|
+
const res = await client.listEmails({
|
|
47
|
+
campaign_id: campaignId,
|
|
48
|
+
email_type: "received",
|
|
49
|
+
is_unread: true,
|
|
50
|
+
limit: 100,
|
|
51
|
+
...(cursor === undefined ? {} : { starting_after: cursor }),
|
|
52
|
+
});
|
|
53
|
+
if (!(res.status >= 200 && res.status < 300))
|
|
54
|
+
throw new Error(`Email list failed: ${res.status}`);
|
|
55
|
+
if (!Array.isArray(res.body?.items))
|
|
56
|
+
throw new Error("Email list returned invalid items; collection incomplete");
|
|
57
|
+
if (!res.body.items.length) return items;
|
|
58
|
+
items.push(...res.body.items);
|
|
59
|
+
const next = res.body.next_starting_after;
|
|
60
|
+
if (next === undefined || next === null) return items;
|
|
61
|
+
if (typeof next !== "string" || !next.trim() || cursors.has(next))
|
|
62
|
+
throw new Error("Email list returned an invalid or repeated cursor; collection incomplete");
|
|
63
|
+
cursors.add(next);
|
|
64
|
+
cursor = next;
|
|
65
|
+
if (page < 99) await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
66
|
+
}
|
|
67
|
+
throw new Error("Email list page limit reached; collection incomplete");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function main() {
|
|
71
|
+
const args = parseArgs(process.argv);
|
|
72
|
+
const runDir = args["run-dir"] ? path.resolve(args["run-dir"]) : null;
|
|
73
|
+
if (!runDir) throw new Error("Missing --run-dir");
|
|
74
|
+
const connectionEnvFile = loadRunEnv(runDir, args["env-file"]);
|
|
75
|
+
const manifest = readJson(path.join(runDir, "manifest.json"));
|
|
76
|
+
let spec = readJson(path.join(runDir, "run-spec.json"));
|
|
77
|
+
// launch-campaign.js no longer bakes derived values (sender identity,
|
|
78
|
+
// chosen mailboxes) into the operator's run-spec; they live in
|
|
79
|
+
// state/resolved-run-spec.json. Overlay only the derived fields so any
|
|
80
|
+
// operator edit to run-spec.json still wins.
|
|
81
|
+
const resolvedSpec = readJson(
|
|
82
|
+
path.join(runDir, "state", "resolved-run-spec.json"),
|
|
83
|
+
null,
|
|
84
|
+
);
|
|
85
|
+
if (!spec && resolvedSpec) {
|
|
86
|
+
// Operator input missing (moved/renamed) — the resolved spec is a full
|
|
87
|
+
// superset from launch time; better than crashing every 10-minute tick.
|
|
88
|
+
spec = resolvedSpec;
|
|
89
|
+
}
|
|
90
|
+
if (!spec) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
"run-spec.json not found in the run dir (and no state/resolved-run-spec.json to fall back to)",
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
if (spec && resolvedSpec && spec !== resolvedSpec) {
|
|
96
|
+
spec.reply_policy = spec.reply_policy || {};
|
|
97
|
+
if (!spec.reply_policy.sender_name) {
|
|
98
|
+
spec.reply_policy.sender_name = resolvedSpec.reply_policy?.sender_name;
|
|
99
|
+
}
|
|
100
|
+
if (!spec.reply_policy.reply_from_email) {
|
|
101
|
+
spec.reply_policy.reply_from_email =
|
|
102
|
+
resolvedSpec.reply_policy?.reply_from_email;
|
|
103
|
+
}
|
|
104
|
+
spec.campaign = spec.campaign || {};
|
|
105
|
+
if (
|
|
106
|
+
!Array.isArray(spec.campaign.email_list) ||
|
|
107
|
+
!spec.campaign.email_list.length
|
|
108
|
+
) {
|
|
109
|
+
spec.campaign.email_list = resolvedSpec.campaign?.email_list;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const ownership = readJson(
|
|
113
|
+
path.join(runDir, "state", "ownership.json"),
|
|
114
|
+
manifest?.ownership || {},
|
|
115
|
+
);
|
|
116
|
+
if (!manifest?.campaign?.id)
|
|
117
|
+
throw new Error("Run manifest missing campaign ID");
|
|
118
|
+
const history = readOptOutHistory(runDir);
|
|
119
|
+
if (!history.runs.some((run) => run.run_key === manifest.run_key && run.campaign_id === manifest.campaign.id))
|
|
120
|
+
throw new Error("Reply collection requires this run's existing outreach.db history; restore it before collecting replies");
|
|
121
|
+
const os = getOsConfig();
|
|
122
|
+
if (os.missing.length)
|
|
123
|
+
throw new Error(`Missing ${os.missing.join(" and ")}`);
|
|
124
|
+
const client = new InstantlyClient({
|
|
125
|
+
connectionEnvFile,
|
|
126
|
+
osApiKey: os.osApiKey,
|
|
127
|
+
osUrl: os.osUrl,
|
|
128
|
+
verbose: !!args.verbose,
|
|
129
|
+
});
|
|
130
|
+
const campaign = await client.getCampaign(manifest.campaign.id);
|
|
131
|
+
if (!(campaign.status >= 200 && campaign.status < 300)) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Campaign lookup failed: ${campaign.status} ${JSON.stringify(campaign.body)}`,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
assertCampaignNotForeign(
|
|
137
|
+
campaign.body,
|
|
138
|
+
ownership,
|
|
139
|
+
`campaign ${manifest.campaign.id}`,
|
|
140
|
+
);
|
|
141
|
+
const dbPath = initDb(runDir);
|
|
142
|
+
const knownRecipients = new Set(queryAll(dbPath,
|
|
143
|
+
`SELECT email FROM run_leads WHERE run_key = ? AND
|
|
144
|
+
(imported_at IS NOT NULL OR last_contacted_at IS NOT NULL)`, [manifest.run_key])
|
|
145
|
+
.map((lead) => lead.email));
|
|
146
|
+
|
|
147
|
+
const stateDir = path.join(runDir, "state");
|
|
148
|
+
const processedPath = path.join(stateDir, "processed-replies.json");
|
|
149
|
+
const processed = new Set(readJson(processedPath, []));
|
|
150
|
+
const added = [];
|
|
151
|
+
|
|
152
|
+
const items = await unreadReplies(client, manifest.campaign.id);
|
|
153
|
+
|
|
154
|
+
const actions = [];
|
|
155
|
+
if (spec.reply_policy?.auto_reply_enabled) {
|
|
156
|
+
console.error(
|
|
157
|
+
"reply_policy.auto_reply_enabled is ignored: the agent answers queued replies with send-reply.js",
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
for (const email of items) {
|
|
161
|
+
if (!email?.id || processed.has(email.id)) continue;
|
|
162
|
+
const fromEmail =
|
|
163
|
+
email.from_address_email || email.email_from || email.from || null;
|
|
164
|
+
// Provider association, when exposed as an address, wins over the author
|
|
165
|
+
// of a forwarded message. Unresolved identity stays explicit in the queue.
|
|
166
|
+
const leadEmail = email.lead_email || (typeof email.lead === "string" && email.lead.includes("@") ? email.lead : null);
|
|
167
|
+
let recipientEmail = null;
|
|
168
|
+
try {
|
|
169
|
+
recipientEmail = resolveCampaignRecipient({ from_email: fromEmail, lead_email: leadEmail }, knownRecipients);
|
|
170
|
+
} catch (_) { /* The agent must inspect the original thread before acting. */ }
|
|
171
|
+
upsertLead(dbPath, {
|
|
172
|
+
email: fromEmail,
|
|
173
|
+
first_name: email.from_address_name || null,
|
|
174
|
+
source: "instantly-reply",
|
|
175
|
+
});
|
|
176
|
+
const intent = classify(email);
|
|
177
|
+
const actionAt = isoNow();
|
|
178
|
+
|
|
179
|
+
if (fromEmail) {
|
|
180
|
+
if (recipientEmail) upsertRunLead(dbPath, {
|
|
181
|
+
run_key: manifest.run_key,
|
|
182
|
+
email: recipientEmail,
|
|
183
|
+
campaign_id: manifest.campaign.id,
|
|
184
|
+
last_known_status: "replied",
|
|
185
|
+
last_replied_at: actionAt,
|
|
186
|
+
reply_intent: intent,
|
|
187
|
+
ownership_tag: ownership.run_tag_label,
|
|
188
|
+
});
|
|
189
|
+
insertLeadEvent(dbPath, {
|
|
190
|
+
run_key: manifest.run_key,
|
|
191
|
+
email: fromEmail,
|
|
192
|
+
event_type: "reply_received",
|
|
193
|
+
event_at: actionAt,
|
|
194
|
+
payload_json: {
|
|
195
|
+
email_id: email.id,
|
|
196
|
+
intent,
|
|
197
|
+
subject: email.subject || null,
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
upsertReplyQueueItem(dbPath, {
|
|
201
|
+
run_key: manifest.run_key,
|
|
202
|
+
email: fromEmail,
|
|
203
|
+
message_id: email.id,
|
|
204
|
+
intent,
|
|
205
|
+
status: "pending",
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// Everything the agent needs to answer in the same thread with the same
|
|
209
|
+
// mailbox; send-reply.js reads it back from here.
|
|
210
|
+
added.push({
|
|
211
|
+
email_id: email.id,
|
|
212
|
+
campaign_id: manifest.campaign.id,
|
|
213
|
+
from_email: fromEmail,
|
|
214
|
+
recipient_email: recipientEmail,
|
|
215
|
+
lead_email: leadEmail,
|
|
216
|
+
from_name: email.from_address_name || null,
|
|
217
|
+
eaccount:
|
|
218
|
+
typeof email.eaccount === "string" && email.eaccount.trim()
|
|
219
|
+
? email.eaccount.trim()
|
|
220
|
+
: null,
|
|
221
|
+
subject: email.subject || null,
|
|
222
|
+
text: String(email?.body?.text || "").slice(0, 4000),
|
|
223
|
+
intent_hint: intent,
|
|
224
|
+
status: "pending",
|
|
225
|
+
at: actionAt,
|
|
226
|
+
});
|
|
227
|
+
actions.push({ email_id: email.id, intent_hint: intent, action: "queued", at: actionAt });
|
|
228
|
+
processed.add(email.id);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Append under the queue lock: send-reply.js may be changing statuses in
|
|
232
|
+
// the same file, and a whole-file rewrite from here would undo them.
|
|
233
|
+
const pending = updateQueue(runDir, (queue) => {
|
|
234
|
+
const known = new Set(queue.map((q) => q.email_id));
|
|
235
|
+
for (const item of added) if (!known.has(item.email_id)) queue.push(item);
|
|
236
|
+
return queue.filter((q) => q.status === "pending").length;
|
|
237
|
+
});
|
|
238
|
+
// A failed queue write must leave these replies collectable on the next tick.
|
|
239
|
+
writeJson(processedPath, Array.from(processed));
|
|
240
|
+
console.log(
|
|
241
|
+
JSON.stringify(
|
|
242
|
+
{
|
|
243
|
+
run_key: manifest.run_key,
|
|
244
|
+
campaign_id: manifest.campaign.id,
|
|
245
|
+
inspected: items.length,
|
|
246
|
+
actions,
|
|
247
|
+
pending,
|
|
248
|
+
},
|
|
249
|
+
null,
|
|
250
|
+
2,
|
|
251
|
+
),
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
main().catch((err) => {
|
|
256
|
+
console.error(err.stack || err.message);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Bound each direct scheduler tick and fail closed on concurrent/stale locks.
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { spawnSync } = require("child_process");
|
|
6
|
+
const { parseArgs } = require("./lib/helpers");
|
|
7
|
+
const scripts = {reply:"reply-worker.js", monitor:"monitor-campaign.js",
|
|
8
|
+
replenish:"replenish-leads.js", conclude:"conclude-campaign.js"};
|
|
9
|
+
|
|
10
|
+
function main() {
|
|
11
|
+
const args = parseArgs(process.argv);
|
|
12
|
+
const script = scripts[args.job];
|
|
13
|
+
const timeout = Number(args["timeout-seconds"]);
|
|
14
|
+
if (!script || !args["run-dir"] || !args["env-file"] || !Number.isInteger(timeout)
|
|
15
|
+
|| timeout < 1 || timeout > 1800) throw new Error("Invalid cron job arguments");
|
|
16
|
+
const runDir = path.resolve(args["run-dir"]);
|
|
17
|
+
const lock = path.join(runDir, `.cron-${args.job}.lock`);
|
|
18
|
+
try { fs.mkdirSync(lock, {mode:0o700}); }
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err.code !== "EEXIST") throw err;
|
|
21
|
+
throw new Error(`Concurrent or stale job lock: ${lock}. Verify no tick is running before removing it.`);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
fs.writeFileSync(path.join(lock, "owner.json"), JSON.stringify({pid:process.pid, started_at:new Date().toISOString()}));
|
|
25
|
+
const result = spawnSync(process.execPath, [path.join(__dirname, script),
|
|
26
|
+
"--run-dir", runDir, "--env-file", path.resolve(args["env-file"])],
|
|
27
|
+
{stdio:"inherit", timeout:timeout * 1000, killSignal:"SIGKILL"});
|
|
28
|
+
if (result.error) throw result.error;
|
|
29
|
+
process.exitCode = result.status === null ? 1 : result.status;
|
|
30
|
+
} finally { fs.rmSync(lock, {recursive:true, force:true}); }
|
|
31
|
+
}
|
|
32
|
+
try { main(); } catch (err) { console.error(err.message); process.exitCode = 1; }
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The agent's way to act on one queued reply (reply-queue.json, written by
|
|
3
|
+
// reply-worker.js): send the reply it wrote, in the same thread from the
|
|
4
|
+
// mailbox that received the message, or close the item without sending.
|
|
5
|
+
//
|
|
6
|
+
// node send-reply.js --run-dir <run> --email-id <id> --text-file reply.txt
|
|
7
|
+
// node send-reply.js --run-dir <run> --email-id <id> --mark owner_review|no_reply|opt_out
|
|
8
|
+
// --mark opt_out confirms the agent read the reply; --recipient-email is needed
|
|
9
|
+
// when a forwarded reply cannot be associated with the original recipient.
|
|
10
|
+
//
|
|
11
|
+
// Run it for one message at a time; the queue lock serialises writes, but two
|
|
12
|
+
// sends for different messages in parallel gain nothing.
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const { InstantlyClient } = require("./lib/instantly-client");
|
|
16
|
+
const {
|
|
17
|
+
readJson,
|
|
18
|
+
parseArgs,
|
|
19
|
+
isoNow,
|
|
20
|
+
loadRunEnv,
|
|
21
|
+
getOsConfig,
|
|
22
|
+
assertCampaignNotForeign,
|
|
23
|
+
} = require("./lib/helpers");
|
|
24
|
+
const {
|
|
25
|
+
initDb,
|
|
26
|
+
insertLeadEvent,
|
|
27
|
+
setReplyQueueStatus,
|
|
28
|
+
queryAll,
|
|
29
|
+
upsertLead,
|
|
30
|
+
confirmOptOut,
|
|
31
|
+
} = require("./lib/outreach-db");
|
|
32
|
+
const { updateQueue } = require("./lib/reply-queue");
|
|
33
|
+
const {
|
|
34
|
+
plainToHtmlBody,
|
|
35
|
+
markdownLinksToText,
|
|
36
|
+
linkHosts,
|
|
37
|
+
} = require("./lib/html-body");
|
|
38
|
+
const { readOptOutHistory, assertRecipientNotOptedOut, resolveCampaignRecipient,
|
|
39
|
+
stopConfirmedRecipient } = require("./lib/confirmed-opt-outs");
|
|
40
|
+
|
|
41
|
+
// owner_review / no_reply close a queued item. sent / pending resolve an item
|
|
42
|
+
// left in "sending" by a process that died mid-send: check the thread in
|
|
43
|
+
// Instantly first, then record what actually happened.
|
|
44
|
+
const MARKS = ["owner_review", "no_reply", "opt_out"];
|
|
45
|
+
const RESOLVE_SENDING = ["sent", "pending"];
|
|
46
|
+
const OPEN = ["pending", "owner_review"];
|
|
47
|
+
|
|
48
|
+
function claim(runDir, emailId, campaignId, check) {
|
|
49
|
+
return updateQueue(runDir, (queue) => {
|
|
50
|
+
const item = queue.find((q) => q.email_id === emailId);
|
|
51
|
+
if (!item) throw new Error(`Message ${emailId} is not in this run's reply queue`);
|
|
52
|
+
if (item.campaign_id !== campaignId)
|
|
53
|
+
throw new Error(`Message ${emailId} belongs to another campaign`);
|
|
54
|
+
return check(item);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function setStatus(runDir, emailId, status, extra = {}) {
|
|
59
|
+
updateQueue(runDir, (queue) => {
|
|
60
|
+
Object.assign(queue.find((q) => q.email_id === emailId), { status, ...extra });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function main() {
|
|
65
|
+
const args = parseArgs(process.argv);
|
|
66
|
+
const runDir = args["run-dir"] ? path.resolve(args["run-dir"]) : null;
|
|
67
|
+
const emailId = args["email-id"];
|
|
68
|
+
if (!runDir || !emailId) throw new Error("Missing --run-dir or --email-id");
|
|
69
|
+
const mark = args.mark;
|
|
70
|
+
if (mark && !MARKS.includes(mark) && !RESOLVE_SENDING.includes(mark))
|
|
71
|
+
throw new Error(`--mark must be one of: ${[...MARKS, ...RESOLVE_SENDING].join(", ")}`);
|
|
72
|
+
const text = args["text-file"]
|
|
73
|
+
? fs.readFileSync(path.resolve(args["text-file"]), "utf8").trim()
|
|
74
|
+
: "";
|
|
75
|
+
if (!mark && !text) throw new Error("Give --text-file with the reply, or --mark");
|
|
76
|
+
|
|
77
|
+
const connectionEnvFile = loadRunEnv(runDir, args["env-file"]);
|
|
78
|
+
const manifest = readJson(path.join(runDir, "manifest.json"));
|
|
79
|
+
if (!manifest?.campaign?.id) throw new Error("Run manifest missing campaign ID");
|
|
80
|
+
const campaignId = manifest.campaign.id;
|
|
81
|
+
if (!mark || mark === "opt_out") readOptOutHistory(runDir);
|
|
82
|
+
// Validate reply attribution input before any queue write. Opt-outs and
|
|
83
|
+
// recovery marks must remain available even when the run spec is damaged.
|
|
84
|
+
const spec = !mark ? (
|
|
85
|
+
readJson(path.join(runDir, "run-spec.json")) ||
|
|
86
|
+
readJson(path.join(runDir, "state", "resolved-run-spec.json"), {})
|
|
87
|
+
) : null;
|
|
88
|
+
const dbPath = initDb(runDir);
|
|
89
|
+
const at = isoNow();
|
|
90
|
+
const record = (status) =>
|
|
91
|
+
setReplyQueueStatus(dbPath, { run_key: manifest.run_key, message_id: emailId, status });
|
|
92
|
+
|
|
93
|
+
if (mark && mark !== "opt_out") {
|
|
94
|
+
claim(runDir, emailId, campaignId, (item) => {
|
|
95
|
+
const from = item.status || "pending";
|
|
96
|
+
if (RESOLVE_SENDING.includes(mark) ? from !== "sending" : !OPEN.includes(from))
|
|
97
|
+
throw new Error(`Message ${emailId} is ${from}; --mark ${mark} does not apply`);
|
|
98
|
+
Object.assign(item, { status: mark, handled_at: at });
|
|
99
|
+
});
|
|
100
|
+
record(mark);
|
|
101
|
+
console.log(JSON.stringify({ email_id: emailId, action: mark, at }));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Keep the durable refusal even if provider access is temporarily unavailable.
|
|
106
|
+
// The queue records any unresolved scoped pause for the next agent to handle.
|
|
107
|
+
const queued = claim(runDir, emailId, campaignId, (item) => {
|
|
108
|
+
const from = item.status || "pending";
|
|
109
|
+
if (from === "sending")
|
|
110
|
+
throw new Error(`Message ${emailId} is "sending": check the thread in Instantly, then --mark sent or --mark pending`);
|
|
111
|
+
if (!OPEN.includes(from) && !(mark === "opt_out" && from === "no_reply"))
|
|
112
|
+
throw new Error(`Message ${emailId} is already handled (${from})`);
|
|
113
|
+
return { ...item };
|
|
114
|
+
});
|
|
115
|
+
const localRecipients = new Set(queryAll(dbPath,
|
|
116
|
+
`SELECT email FROM run_leads WHERE run_key = ? AND
|
|
117
|
+
(imported_at IS NOT NULL OR last_contacted_at IS NOT NULL)`, [manifest.run_key])
|
|
118
|
+
.map((lead) => lead.email));
|
|
119
|
+
let client;
|
|
120
|
+
const getClient = () => {
|
|
121
|
+
if (client) return client;
|
|
122
|
+
const os = getOsConfig();
|
|
123
|
+
if (os.missing.length) throw new Error(`Missing ${os.missing.join(" and ")}`);
|
|
124
|
+
client = new InstantlyClient({ connectionEnvFile, osApiKey: os.osApiKey, osUrl: os.osUrl });
|
|
125
|
+
return client;
|
|
126
|
+
};
|
|
127
|
+
let recipient;
|
|
128
|
+
try {
|
|
129
|
+
recipient = resolveCampaignRecipient(queued, localRecipients, args["recipient-email"]);
|
|
130
|
+
} catch (_) {
|
|
131
|
+
const members = await getClient().listLeadEmails(campaignId);
|
|
132
|
+
if (!members.ok) throw new Error("Campaign recipient lookup incomplete; inspect the original thread before acting");
|
|
133
|
+
recipient = resolveCampaignRecipient(queued, members.emails, args["recipient-email"]);
|
|
134
|
+
}
|
|
135
|
+
if (mark === "opt_out") {
|
|
136
|
+
claim(runDir, emailId, campaignId, (item) => {
|
|
137
|
+
if (![...OPEN, "no_reply"].includes(item.status || "pending"))
|
|
138
|
+
throw new Error(`Message ${emailId} changed status; inspect before confirming opt-out`);
|
|
139
|
+
if (item.opt_out_confirmed && item.recipient_email !== recipient)
|
|
140
|
+
throw new Error("This message already confirmed a different recipient; inspect the original thread");
|
|
141
|
+
if (!queryAll(dbPath, "SELECT email FROM leads WHERE email = ?", [recipient]).length)
|
|
142
|
+
upsertLead(dbPath, { email: recipient, source: "instantly-reply" });
|
|
143
|
+
// Commit first: failed persistence must never close the JSON queue.
|
|
144
|
+
confirmOptOut(dbPath, { run_key: manifest.run_key, email: recipient,
|
|
145
|
+
campaign_id: campaignId, message_id: emailId, event_at: at });
|
|
146
|
+
Object.assign(item, { status: "no_reply", handled_at: at, recipient_email: recipient,
|
|
147
|
+
opt_out_confirmed: true, opt_out_provider: { ok: false, pending: true } });
|
|
148
|
+
});
|
|
149
|
+
record("no_reply");
|
|
150
|
+
let provider;
|
|
151
|
+
try {
|
|
152
|
+
provider = await stopConfirmedRecipient(getClient(), runDir, recipient);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
provider = { ok: false, error: error.message };
|
|
155
|
+
}
|
|
156
|
+
setStatus(runDir, emailId, "no_reply", { opt_out_provider: provider });
|
|
157
|
+
console.log(JSON.stringify({ email_id: emailId, recipient_email: recipient,
|
|
158
|
+
action: "opt_out_confirmed", provider, at }));
|
|
159
|
+
if (!provider.ok) process.exitCode = 1;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
assertRecipientNotOptedOut(runDir, recipient);
|
|
163
|
+
// A reply can go to a forwarder rather than the original lead. Check both.
|
|
164
|
+
if (queued.from_email) assertRecipientNotOptedOut(runDir, queued.from_email);
|
|
165
|
+
getClient();
|
|
166
|
+
const campaign = await client.getCampaign(campaignId);
|
|
167
|
+
if (!(campaign.status >= 200 && campaign.status < 300))
|
|
168
|
+
throw new Error(`Campaign lookup failed: ${campaign.status}`);
|
|
169
|
+
assertCampaignNotForeign(
|
|
170
|
+
campaign.body,
|
|
171
|
+
readJson(path.join(runDir, "state", "ownership.json"), manifest.ownership || {}),
|
|
172
|
+
`campaign ${campaignId}`,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// HTML as for the campaign steps: without it clients that show the HTML
|
|
176
|
+
// part run the reply into one paragraph, and its links carry no UTMs.
|
|
177
|
+
// - The reply is plain text even if it has a tag like <b>: escaped, one
|
|
178
|
+
// <div> per line.
|
|
179
|
+
// - The run's UTMs go only on the product's links, i.e. the hosts the
|
|
180
|
+
// campaign steps link to; a Calendly or LinkedIn link stays as written.
|
|
181
|
+
// - Steps without links leave the product unknown: then no link is
|
|
182
|
+
// tagged (an extra query parameter can break a signed or third-party URL).
|
|
183
|
+
// Built before the claim, so a broken run-spec.json fails here instead of
|
|
184
|
+
// leaving the item "sending".
|
|
185
|
+
const productHosts = linkHosts(
|
|
186
|
+
(spec.sequence?.steps || []).map((step) => step.body || "").join("\n"),
|
|
187
|
+
);
|
|
188
|
+
const body = {
|
|
189
|
+
text: markdownLinksToText(text),
|
|
190
|
+
html: plainToHtmlBody(text, manifest.run_key, { plain: true, utmHosts: productHosts }),
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Claim the item before calling the API. If this process dies after the
|
|
194
|
+
// send, the item stays "sending" and no later run sends it again.
|
|
195
|
+
const item = claim(runDir, emailId, campaignId, (it) => {
|
|
196
|
+
const from = it.status || "pending";
|
|
197
|
+
if (from === "sending")
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Message ${emailId} is "sending": a previous send may have gone out. Check the thread in Instantly, then --mark sent or --mark pending`,
|
|
200
|
+
);
|
|
201
|
+
if (!OPEN.includes(from)) throw new Error(`Message ${emailId} is already handled (${from})`);
|
|
202
|
+
if (!it.eaccount)
|
|
203
|
+
throw new Error("Receiving mailbox unknown for this message; answer it in Instantly by hand");
|
|
204
|
+
assertRecipientNotOptedOut(runDir, recipient);
|
|
205
|
+
if (it.from_email) assertRecipientNotOptedOut(runDir, it.from_email);
|
|
206
|
+
Object.assign(it, { status: "sending", sending_at: at });
|
|
207
|
+
return { ...it };
|
|
208
|
+
});
|
|
209
|
+
record("sending");
|
|
210
|
+
|
|
211
|
+
const subject = item.subject
|
|
212
|
+
? /^re:/i.test(item.subject) ? item.subject : `Re: ${item.subject}`
|
|
213
|
+
: "Re:";
|
|
214
|
+
const res = await client.replyToEmail({
|
|
215
|
+
reply_to_uuid: emailId,
|
|
216
|
+
eaccount: item.eaccount,
|
|
217
|
+
subject,
|
|
218
|
+
body,
|
|
219
|
+
});
|
|
220
|
+
if (res.status >= 400 && res.status < 500) {
|
|
221
|
+
// Rejected by the API, so nothing was sent: back to the open queue.
|
|
222
|
+
setStatus(runDir, emailId, "pending");
|
|
223
|
+
record("pending");
|
|
224
|
+
console.log(JSON.stringify({ email_id: emailId, action: "reply_failed", status: res.status, at }));
|
|
225
|
+
process.exitCode = 1;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (!(res.status >= 200 && res.status < 300)) {
|
|
229
|
+
// A 5xx can come after Instantly sent the email: leave the item "sending"
|
|
230
|
+
// so it is checked in the thread instead of being sent again.
|
|
231
|
+
console.log(
|
|
232
|
+
JSON.stringify({
|
|
233
|
+
email_id: emailId,
|
|
234
|
+
action: "reply_unknown",
|
|
235
|
+
status: res.status,
|
|
236
|
+
next: "check the thread in Instantly, then --mark sent or --mark pending",
|
|
237
|
+
at,
|
|
238
|
+
}),
|
|
239
|
+
);
|
|
240
|
+
process.exitCode = 1;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
setStatus(runDir, emailId, "sent", { handled_at: at, reply_text: text });
|
|
244
|
+
record("sent");
|
|
245
|
+
if (recipient) {
|
|
246
|
+
insertLeadEvent(dbPath, {
|
|
247
|
+
run_key: manifest.run_key,
|
|
248
|
+
email: recipient,
|
|
249
|
+
event_type: "reply_sent",
|
|
250
|
+
event_at: at,
|
|
251
|
+
payload_json: { email_id: emailId, status: res.status },
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
console.log(JSON.stringify({ email_id: emailId, action: "replied", status: res.status, at }));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
main().catch((err) => {
|
|
258
|
+
console.error(err.stack || err.message);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: egbe-os-linkedin-ads
|
|
3
|
+
description: Build, operate and measure LinkedIn Single Image and Text Ad campaigns.
|
|
4
|
+
metadata:
|
|
5
|
+
egbe-when: "Offer for audiences defined by roles or companies; use for existing LinkedIn campaigns."
|
|
6
|
+
egbe-visible: "true"
|
|
7
|
+
egbe-title: "LinkedIn Ads"
|
|
8
|
+
egbe-description: "Run ads through Egbe. Reach professional audiences with image and text ads, manage campaigns and measure results."
|
|
9
|
+
egbe-category: "Marketing & growth"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<!-- egbe-mcp-connection:v1 -->
|
|
13
|
+
This skill comes with the Egbe plugin. If this project has its own installed copy
|
|
14
|
+
of the skill, use that copy instead. Otherwise make every Egbe API call it
|
|
15
|
+
describes with the Egbe connector: `egbe_read` for GET and `egbe_write` for POST,
|
|
16
|
+
PUT, PATCH and DELETE (with `method`). Pass the API path (for example
|
|
17
|
+
`/me/limits`), query parameters in `query` and the JSON body in `body`. Leave out `OS_URL`, the Authorization header, `.env.local`,
|
|
18
|
+
`egbe-curl.py` and catalog update checks; the connection authenticates and
|
|
19
|
+
identifies the request. Also pass the `business` that `egbe_setup` returned.
|
|
20
|
+
Where this skill sends an `Idempotency-Key` header, pass the same value as
|
|
21
|
+
`idempotency_key` and reuse it when retrying. A result with a `continuation`
|
|
22
|
+
holds one part of a long body; read the next part with `egbe_read`, the same
|
|
23
|
+
`path` and `business`, and that `continuation`.
|
|
24
|
+
Read bundled files beside this `SKILL.md`. For published skill resources on
|
|
25
|
+
Egbe OS, use `egbe_skill`. Follow "Files downloaded on demand" for listed downloads.
|
|
26
|
+
|
|
27
|
+
Publishing works through the connector: commit the app's files with the JSON
|
|
28
|
+
commit requests in `egbe-os-git` ("Without a terminal") and deploy the returned
|
|
29
|
+
commit SHA; no git push or workspace setup is needed. A step that needs a local
|
|
30
|
+
project key or a bundled script, such as a local `npx convex deploy`, needs a
|
|
31
|
+
set-up project workspace. In a persistent
|
|
32
|
+
project workspace that is not set up yet, set it up as the `egbe-setup` skill's
|
|
33
|
+
project setup describes.
|
|
34
|
+
Without such a workspace, or if it refuses, tell the founder that this step needs
|
|
35
|
+
an agent with a set-up project folder, and continue with the rest of the work.
|
|
36
|
+
|
|
37
|
+
If the connector's tools (`egbe_read` and the other `egbe_*` tools) are not
|
|
38
|
+
available, the plugin's connector is not signed in for this agent. Tell
|
|
39
|
+
the founder how to connect it, as the `egbe-setup` skill describes, rather than
|
|
40
|
+
saying Egbe is unavailable.
|
|
41
|
+
|
|
42
|
+
The connector's tools work even where this environment's shell cannot reach
|
|
43
|
+
Egbe: their calls travel through this agent's connection, not through the
|
|
44
|
+
shell's network. A step that runs in the shell, such as a bundled script, a `git
|
|
45
|
+
push` to Egbe's Git endpoint or a deploy upload, needs the shell to reach the
|
|
46
|
+
Egbe host (`os.hz.egbe.dev`). If a proxy or allowlist refuses that request
|
|
47
|
+
before Egbe answers, for example HTTP 403 on CONNECT or curl status `000`, tell
|
|
48
|
+
the founder: they allow that host in this agent's network settings or continue
|
|
49
|
+
with an agent on their own computer. Code can also be published without the
|
|
50
|
+
shell by committing through the connector (`egbe-os-git`, "Without a terminal").
|
|
51
|
+
Until the shell step or that commit and its deploy succeed, do not report the
|
|
52
|
+
work as published: a preview in this agent or on this computer is not an Egbe
|
|
53
|
+
deployment.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# LinkedIn Ads
|
|
57
|
+
|
|
58
|
+
Use from any product repository with `OS_URL` and `OS_API_KEY` (scope `ads`).
|
|
59
|
+
No scaffold, instance layout or egbe-os-product-build stage is required. Provider
|
|
60
|
+
credentials stay inside Egbe OS; never request them for product code.
|
|
61
|
+
|
|
62
|
+
`GET /ads/linkedin/skill` returns this entrypoint. Read only the references needed
|
|
63
|
+
for the task from the installed bundle. External agents may download
|
|
64
|
+
`GET /skills/linkedin-ads` (ZIP), or
|
|
65
|
+
`GET /skills/linkedin-ads/resources/<relative-path>`.
|
|
66
|
+
Exact schemas are at `$OS_URL/openapi.json`.
|
|
67
|
+
|
|
68
|
+
| Task | Reference |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Inspect destination-specific requirements only | [Destination requirements](references/destination-requirements.md) |
|
|
71
|
+
| Continue any campaign work | [Artifacts](references/runtime/artifacts.md) |
|
|
72
|
+
| Check access, account, Page or Egbe team prerequisites | [Readiness](references/workflows/readiness.md) |
|
|
73
|
+
| Resolve planned targeting and assemble creatives | [Targeting and creative assembly](references/workflows/targeting-and-creative.md) |
|
|
74
|
+
| Build non-serving objects, upload images or recover a partial build | [Build without delivery](references/workflows/build-paused.md) |
|
|
75
|
+
| Authorize delivery or stop it | [Launch and pause](references/workflows/launch-and-pause.md) |
|
|
76
|
+
| Read delivery/results or change campaign settings | [Reporting and changes](references/workflows/monitoring.md) |
|
|
77
|
+
| Add optional browser/server conversions and inspect attribution | [Conversions](references/workflows/conversions.md) |
|
|
78
|
+
| Request bodies, units, controls and errors | [API reference](references/runtime/api-reference.md) |
|
|
79
|
+
|
|
80
|
+
## Operating boundaries
|
|
81
|
+
|
|
82
|
+
- Resolve existing campaign IDs before writing. OS creates groups, campaigns
|
|
83
|
+
and creatives DRAFT (non-serving). Activate only with
|
|
84
|
+
founder authorization or an applicable product marketing policy. An audit or
|
|
85
|
+
a request to edit text does not authorize launch, a larger budget or a new campaign.
|
|
86
|
+
- Use the configured account and its linked organization Page. Do not substitute
|
|
87
|
+
the Page associated with a developer app or publish an organic post as a fallback.
|
|
88
|
+
- Single Image uses Direct Sponsored Content (not the organic feed). Text Ads use
|
|
89
|
+
their separate creative format. These require separate native campaigns.
|
|
90
|
+
- Preserve the approved destination, offer, targeting, budget and exact UTM URL.
|
|
91
|
+
Provider minimums are discovered through pricing/creation; do not increase an
|
|
92
|
+
approved budget automatically to meet them.
|
|
93
|
+
- Persist operation keys before mutations. An ambiguous result is not a failed
|
|
94
|
+
create: reuse the same request/key and read back. Never use a new key to bypass
|
|
95
|
+
an uncertain operation or exhausted quota.
|
|
96
|
+
- Separate configuration, moderation, delivery, product outcomes and attribution.
|
|
97
|
+
ACTIVE does not prove impressions; account access does not prove Page posting
|
|
98
|
+
permission; an empty report does not prove zero spend.
|
|
99
|
+
- These API operations do not install recurring jobs. Read access alone does not
|
|
100
|
+
authorize campaign changes.
|
|
101
|
+
|
|
102
|
+
Return the campaign folder/IDs, actual changes, observed state/time, unresolved
|
|
103
|
+
operations and recovery instructions. Do not commit/push artifacts solely because the skill ran.
|
|
104
|
+
|
|
105
|
+
## Scope
|
|
106
|
+
|
|
107
|
+
First release: USD daily budgets, manual CPC, website visits, Single Image and
|
|
108
|
+
Text Ads, native targeting, campaign controls, reporting and actual-spend sync.
|
|
109
|
+
Optional Insight Tag/CAPI rules, explicit campaign associations, runtime events
|
|
110
|
+
and per-rule reports use the conversions workflow. They do not change manual
|
|
111
|
+
CPC, budgets or delivery status and are not prerequisites for an authorized
|
|
112
|
+
traffic campaign. Runtime event delivery/readback accepts scope `analytics`;
|
|
113
|
+
management requires `ads`. No raw passthrough, audience uploads, organic
|
|
114
|
+
publishing, automatic conversions or conversion bidding.
|