Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,13 @@ let
cf = pkgs.callPackage ../pkgs/cf { };
wrangler = pkgs.callPackage ../pkgs/wrangler { };
};
# Issue #5767, external-Worker slice: the hatch-personal Workers'
# deploy apps (pinned rev staged at deploy time).
agentInboxDeploy = pkgs.callPackage ../pkgs/external-workers/agent-inbox-deploy.nix { };
webhookGatewayDeploy = pkgs.callPackage ../pkgs/external-workers/webhook-gateway-deploy.nix { };
webhookGatewaySinkDeploy =
pkgs.callPackage ../pkgs/external-workers/webhook-gateway-sink-deploy.nix
{ };
in
{
packages = {
Expand All @@ -870,6 +877,9 @@ let
queueTransportAlertDeploy
messageBridge
messageBridgeDeploy
agentInboxDeploy
webhookGatewayDeploy
webhookGatewaySinkDeploy
;
mcpx-docs = mcpxDocs;
fleet-docs = fleetDocs;
Expand Down Expand Up @@ -958,6 +968,9 @@ let
cf-container-hello-deploy = mkApp cfContainerHelloDeploy "Deploy the cf-container-hello Worker from its flake package (needs Bitwarden and sops access)";
queue-transport-alert-deploy = mkApp queueTransportAlertDeploy "Deploy the queue-transport-alert Worker (broker outage alert, code#6369) from its flake package via the cf versions flow (needs Bitwarden and sops access)";
message-bridge-deploy = mkApp messageBridgeDeploy "Deploy the message-bridge Worker (Claude custom connector that sends and receives messages, plus history page) through the cf versions flow (tagged version, then deployment) and set its access token; --code-only uploads code with Cloudflare env vars (CI), --deploy-version <id> rolls back, --print-urls prints the connector URL (needs Bitwarden and sops access)";
agent-inbox-deploy = mkApp agentInboxDeploy "Deploy the agent-inbox Worker from the pinned dezren39/hatch-personal source (needs hatch-personal read access plus Bitwarden and sops access)";
webhook-gateway-deploy = mkApp webhookGatewayDeploy "Deploy the webhook-gateway Worker from the pinned dezren39/hatch-personal source — deploy the sink first on a fresh account (needs hatch-personal read access plus Bitwarden and sops access)";
webhook-gateway-sink-deploy = mkApp webhookGatewaySinkDeploy "Deploy the webhook-gateway-sink Worker from the pinned dezren39/hatch-personal source (needs hatch-personal read access plus Bitwarden and sops access)";
mcpx = {
type = "app";
program = "${mcpx}/bin/mcpx";
Expand Down Expand Up @@ -1699,6 +1712,9 @@ let
grep -q "cf-container-hello" list.txt
grep -q "queue-transport-alert" list.txt
grep -q "message-bridge" list.txt
grep -q "agent-inbox" list.txt
grep -q "webhook-gateway" list.txt
grep -q "webhook-gateway-sink" list.txt
grep -q "secrets-broker" list.txt
grep -q "pm-aggregator" list.txt
grep -q "pm-projector" list.txt
Expand Down
9 changes: 9 additions & 0 deletions pkgs/deploy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ let
# Issue #12909: ready-for-agent, packaged from its pinned npm
# tarballs — the last of the four #12768 services to register.
readyForAgent = callPackage ../ready-for-agent/package.nix { };
# Issue #5767, external-Worker slice: agent-inbox, webhook-gateway,
# and webhook-gateway-sink live in dezren39/hatch-personal (source
# verdict comment 6974159268), not this repo. Each deploy app
# carries the pinned hatch-personal rev and stages the worker dir
# at deploy time (sparse checkout — no full clone, no build, no
# deploy-time npm install; both workers are dependency-free).
agentInboxDeploy = callPackage ../external-workers/agent-inbox-deploy.nix { };
webhookGatewayDeploy = callPackage ../external-workers/webhook-gateway-deploy.nix { };
webhookGatewaySinkDeploy = callPackage ../external-workers/webhook-gateway-sink-deploy.nix { };
};
# The registry names each target's store path without depending on it
# (code#12738): string context would make building the CLI realize every
Expand Down
68 changes: 68 additions & 0 deletions pkgs/deploy/services.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
cfContainerHelloDeploy,
queueTransportAlertDeploy,
messageBridgeDeploy,
agentInboxDeploy,
webhookGatewayDeploy,
webhookGatewaySinkDeploy,
pmAggregator,
pmProjector,
pmTunnel,
Expand Down Expand Up @@ -323,6 +326,71 @@
class = "cloudflare";
};

# Issue #5767, external-Worker slice: agent-inbox, webhook-gateway,
# and webhook-gateway-sink live in dezren39/hatch-personal (source
# verdict comment 6974159268), not this repo. Each deploy app stages
# its worker dir from the pinned hatch-personal rev at deploy time
# (sparse checkout) and runs wrangler deploy there; both workers are
# dependency-free, so there is no build and no deploy-time npm
# install. Credentials are gathered impurely at deploy time, so the
# definitions name no secrets (the phase-1 shape). The pinned rev is
# repeated in `environment` so `deploy list` shows the source pin
# next to the target. Deploy the sink before the gateway on a fresh
# account (the gateway binds to the SINK service).
agent-inbox = {
package = agentInboxDeploy;
entryPoint = "bin/agent-inbox-deploy";
args = [ ];
environment = {
HATCH_PERSONAL_REPO = "dezren39/hatch-personal";
HATCH_PERSONAL_REV = "ae79c332a78a7ba39b6dacd0f30228384d58dfdc";
HATCH_WORKER_PATH = "workspace/agent-inbox/worker";
};
secrets = [ ]; # resolved by the deploy app itself at deploy time
user = "user";
ports = [ ];
restart = "no";
healthCheck = null;
targets = [ "cloudflare" ];
class = "cloudflare";
};

webhook-gateway = {
package = webhookGatewayDeploy;
entryPoint = "bin/webhook-gateway-deploy";
args = [ ];
environment = {
HATCH_PERSONAL_REPO = "dezren39/hatch-personal";
HATCH_PERSONAL_REV = "ae79c332a78a7ba39b6dacd0f30228384d58dfdc";
HATCH_WORKER_PATH = "workspace/webhook-gateway";
};
secrets = [ ]; # resolved by the deploy app itself at deploy time
user = "user";
ports = [ ];
restart = "no";
healthCheck = null;
targets = [ "cloudflare" ];
class = "cloudflare";
};

webhook-gateway-sink = {
package = webhookGatewaySinkDeploy;
entryPoint = "bin/webhook-gateway-sink-deploy";
args = [ ];
environment = {
HATCH_PERSONAL_REPO = "dezren39/hatch-personal";
HATCH_PERSONAL_REV = "ae79c332a78a7ba39b6dacd0f30228384d58dfdc";
HATCH_WORKER_PATH = "workspace/webhook-gateway/sink";
};
secrets = [ ]; # resolved by the deploy app itself at deploy time
user = "user";
ports = [ ];
restart = "no";
healthCheck = null;
targets = [ "cloudflare" ];
class = "cloudflare";
};

# Route proxy - issue #5768, migration M1 of the deployment
# architecture (design doc/2026-11-04_deployment-architecture-services-layer.md, §7): the
# hand-written opencode-route-proxy.service unit is already gone
Expand Down
36 changes: 36 additions & 0 deletions pkgs/external-workers/agent-inbox-deploy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Deploy app for the agent-inbox Worker — issue #5767, external-Worker
# registration slice. The Worker's source lives in dezren39/hatch-personal
# (not this repo), so this app carries the pinned source coordinates and
# stages them at deploy time (sparse checkout of the worker dir at the
# pinned rev — trees only, no full clone). The worker is
# dependency-free, so there is no build and no deploy-time npm install.
# Cloudflare credentials are gathered impurely at deploy time (sops
# account id, wrangler token), so the registry definition names no
# secrets of its own — the phase-1 shape.
{
writeShellApplication,
bws,
git,
jq,
nodejs,
sops,
wrangler,
}:
writeShellApplication {
name = "agent-inbox-deploy";
runtimeInputs = [
bws
git
jq
nodejs
sops
wrangler
];
text = ''
export HATCH_PERSONAL_REPO="dezren39/hatch-personal"
export HATCH_PERSONAL_REV="ae79c332a78a7ba39b6dacd0f30228384d58dfdc"
export HATCH_WORKER_PATH="workspace/agent-inbox/worker"
repo_root=$(git rev-parse --show-toplevel)
exec bash "$repo_root/pkgs/external-workers/agent-inbox-deploy.sh" "$@"
'';
}
67 changes: 67 additions & 0 deletions pkgs/external-workers/agent-inbox-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Deploys the agent-inbox Worker whose source lives in
# dezren39/hatch-personal (issue #5767, external-Worker registration
# slice). The worker is dependency-free (no package.json — wrangler
# uploads src/ + wrangler.toml directly), so the deploy needs no build
# and no deploy-time npm install: it stages the pinned source tree and
# runs `wrangler deploy`.
#
# Usage:
# agent-inbox-deploy.sh [--dry-run] [--rev <sha>]
#
# --dry-run stages the source and runs `wrangler deploy --dry-run`
# (validates wrangler.toml, uploads nothing, needs no credentials).
# A full deploy needs CLOUDFLARE_ACCOUNT_ID (decrypted from sops here,
# like the other cloudflare deploy apps) and a Cloudflare token
# wrangler can use (CLOUDFLARE_API_TOKEN env or wrangler login).
# Worker secrets (TURSO_TOKEN, ADMIN_TOKEN) are managed out of band
# with `wrangler secret put` and are never carried here.
#
# Source overrides (default: the pinned rev in the deploy.nix that
# wraps this script):
# HATCH_PERSONAL_REPO owner/repo (default dezren39/hatch-personal)
# HATCH_PERSONAL_REV full commit SHA to deploy
# HATCH_WORKER_PATH worker dir inside that repo
set -euo pipefail

REPO="${HATCH_PERSONAL_REPO:?HATCH_PERSONAL_REPO must be set by the deploy app}"
PINNED_REV="${HATCH_PERSONAL_REV:?HATCH_PERSONAL_REV must be set by the deploy app}"
SUBPATH="${HATCH_WORKER_PATH:?HATCH_WORKER_PATH must be set by the deploy app}"
WORKER="agent-inbox"

DRY_RUN=0
REV="$PINNED_REV"
while [ $# -gt 0 ]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--rev)
REV="${2:?--rev needs a value}"; shift 2 ;;
--rev=*) REV="${1#--rev=}"; shift ;;
-h|--help)
echo "Usage: $0 [--dry-run] [--rev <sha>]"; exit 0 ;;
*) echo "error: unknown argument $1 (usage: $0 [--dry-run] [--rev <sha>])" >&2; exit 2 ;;
esac
done

if [ "$REV" != "$PINNED_REV" ]; then
echo "warning: deploying $WORKER at $REV, not the pinned $PINNED_REV" >&2
fi

STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
echo "staging $REPO $SUBPATH at $REV ..." >&2
git clone --quiet --filter=blob:none --no-checkout "https://github.com/${REPO}.git" "$STAGE/checkout"
git -C "$STAGE/checkout" sparse-checkout set "$SUBPATH"
git -C "$STAGE/checkout" checkout --quiet "$REV"
WORKDIR="$STAGE/checkout/$SUBPATH"
[ -f "$WORKDIR/wrangler.toml" ] || { echo "error: $SUBPATH has no wrangler.toml at $REV" >&2; exit 1; }

if [ "$DRY_RUN" = 1 ]; then
( cd "$WORKDIR" && wrangler deploy --dry-run )
exit 0
fi

repo_root="$(git rev-parse --show-toplevel)"
CLOUDFLARE_ACCOUNT_ID="$(sops decrypt --extract '["cloudflare_account_id"]' "${repo_root}/secrets/sops/common/cloudflare.yaml")"
export CLOUDFLARE_ACCOUNT_ID
( cd "$WORKDIR" && wrangler deploy )
36 changes: 36 additions & 0 deletions pkgs/external-workers/webhook-gateway-deploy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Deploy app for the webhook-gateway Worker — issue #5767,
# external-Worker registration slice. The Worker's source lives in
# dezren39/hatch-personal (not this repo), so this app carries the
# pinned source coordinates and stages them at deploy time (sparse
# checkout of the worker dir at the pinned rev — trees only, no full
# clone). The worker is dependency-free, so there is no build and no
# deploy-time npm install. Cloudflare credentials are gathered
# impurely at deploy time (sops account id, wrangler token), so the
# registry definition names no secrets of its own — the phase-1 shape.
{
writeShellApplication,
bws,
git,
jq,
nodejs,
sops,
wrangler,
}:
writeShellApplication {
name = "webhook-gateway-deploy";
runtimeInputs = [
bws
git
jq
nodejs
sops
wrangler
];
text = ''
export HATCH_PERSONAL_REPO="dezren39/hatch-personal"
export HATCH_PERSONAL_REV="ae79c332a78a7ba39b6dacd0f30228384d58dfdc"
export HATCH_WORKER_PATH="workspace/webhook-gateway"
repo_root=$(git rev-parse --show-toplevel)
exec bash "$repo_root/pkgs/external-workers/webhook-gateway-deploy.sh" "$@"
'';
}
73 changes: 73 additions & 0 deletions pkgs/external-workers/webhook-gateway-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Deploys the webhook-gateway Worker whose source lives in
# dezren39/hatch-personal (issue #5767, external-Worker registration
# slice). The worker is dependency-free (no package.json — wrangler
# uploads src/ + wrangler.toml directly), so the deploy needs no build
# and no deploy-time npm install: it stages the pinned source tree and
# runs `wrangler deploy`.
#
# Ordering note: the gateway binds to two internal services declared in
# its wrangler.toml — SINK (webhook-gateway-sink) and LEDGER
# (ledger-svc, same repo). Deploy the sink (and ledger-svc) before the
# gateway on a fresh account, or the gateway deploy fails binding
# resolution.
#
# Usage:
# webhook-gateway-deploy.sh [--dry-run] [--rev <sha>]
#
# --dry-run stages the source and runs `wrangler deploy --dry-run`
# (validates wrangler.toml, uploads nothing, needs no credentials).
# A full deploy needs CLOUDFLARE_ACCOUNT_ID (decrypted from sops here,
# like the other cloudflare deploy apps) and a Cloudflare token
# wrangler can use (CLOUDFLARE_API_TOKEN env or wrangler login).
# Gateway bindings (D1 webhook-gateway, R2 payloads, delivery queue,
# cron) are provisioned out of band and never carried here.
#
# Source overrides (default: the pinned rev in the deploy.nix that
# wraps this script):
# HATCH_PERSONAL_REPO owner/repo (default dezren39/hatch-personal)
# HATCH_PERSONAL_REV full commit SHA to deploy
# HATCH_WORKER_PATH worker dir inside that repo
set -euo pipefail

REPO="${HATCH_PERSONAL_REPO:?HATCH_PERSONAL_REPO must be set by the deploy app}"
PINNED_REV="${HATCH_PERSONAL_REV:?HATCH_PERSONAL_REV must be set by the deploy app}"
SUBPATH="${HATCH_WORKER_PATH:?HATCH_WORKER_PATH must be set by the deploy app}"
WORKER="webhook-gateway"

DRY_RUN=0
REV="$PINNED_REV"
while [ $# -gt 0 ]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--rev)
REV="${2:?--rev needs a value}"; shift 2 ;;
--rev=*) REV="${1#--rev=}"; shift ;;
-h|--help)
echo "Usage: $0 [--dry-run] [--rev <sha>]"; exit 0 ;;
*) echo "error: unknown argument $1 (usage: $0 [--dry-run] [--rev <sha>])" >&2; exit 2 ;;
esac
done

if [ "$REV" != "$PINNED_REV" ]; then
echo "warning: deploying $WORKER at $REV, not the pinned $PINNED_REV" >&2
fi

STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
echo "staging $REPO $SUBPATH at $REV ..." >&2
git clone --quiet --filter=blob:none --no-checkout "https://github.com/${REPO}.git" "$STAGE/checkout"
git -C "$STAGE/checkout" sparse-checkout set "$SUBPATH"
git -C "$STAGE/checkout" checkout --quiet "$REV"
WORKDIR="$STAGE/checkout/$SUBPATH"
[ -f "$WORKDIR/wrangler.toml" ] || { echo "error: $SUBPATH has no wrangler.toml at $REV" >&2; exit 1; }

if [ "$DRY_RUN" = 1 ]; then
( cd "$WORKDIR" && wrangler deploy --dry-run )
exit 0
fi

repo_root="$(git rev-parse --show-toplevel)"
CLOUDFLARE_ACCOUNT_ID="$(sops decrypt --extract '["cloudflare_account_id"]' "${repo_root}/secrets/sops/common/cloudflare.yaml")"
export CLOUDFLARE_ACCOUNT_ID
( cd "$WORKDIR" && wrangler deploy )
37 changes: 37 additions & 0 deletions pkgs/external-workers/webhook-gateway-sink-deploy.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Deploy app for the webhook-gateway-sink Worker — issue #5767,
# external-Worker registration slice. The Worker's source lives in
# dezren39/hatch-personal under workspace/webhook-gateway/sink (not
# this repo), so this app carries the pinned source coordinates and
# stages them at deploy time (sparse checkout of the worker dir at the
# pinned rev — trees only, no full clone). The worker is
# dependency-free, so there is no build and no deploy-time npm install.
# Cloudflare credentials are gathered impurely at deploy time (sops
# account id, wrangler token), so the registry definition names no
# secrets of its own — the phase-1 shape.
{
writeShellApplication,
bws,
git,
jq,
nodejs,
sops,
wrangler,
}:
writeShellApplication {
name = "webhook-gateway-sink-deploy";
runtimeInputs = [
bws
git
jq
nodejs
sops
wrangler
];
text = ''
export HATCH_PERSONAL_REPO="dezren39/hatch-personal"
export HATCH_PERSONAL_REV="ae79c332a78a7ba39b6dacd0f30228384d58dfdc"
export HATCH_WORKER_PATH="workspace/webhook-gateway/sink"
repo_root=$(git rev-parse --show-toplevel)
exec bash "$repo_root/pkgs/external-workers/webhook-gateway-sink-deploy.sh" "$@"
'';
}
Loading