Files
ben 630cedcff6 feat(workbot): track content-free adoption in Den (#6156)
* feat(workbot): track content-free adoption in Den

Record member-scoped admission and completion from trusted services rather than browser relay events. Reuse the telemetry tables and existing service credential, preserve first sightings atomically, and distinguish provider-reported model identity from configured fallback. Add a bounded read-only platform-admin funnel and content/privacy/authentication integration coverage.

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* fix(workbot): preserve sign-in time across readiness probes

Record the authenticated sign-in instant before its asynchronous connection snapshot so a fast greeting cannot fall outside its adoption cohort. Exercise runner telemetry and Workbot sign-in tests in the existing CI lanes.

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* test(workbot): keep fast greetings in delayed sign-in cohorts

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* fix(workbot): correlate OAuth telemetry by public nonce

Never pass signed OAuth state through telemetry identity derivation. Reuse the transaction's public UUID directly for deduplication, keep signed state and credentials outside the sink, and preserve first lifecycle identifiers.

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* fix(workbot): keep telemetry outcomes content-free

Use a shared closed error-code vocabulary at producer and sink rather than accepting arbitrary provider-defined slugs. Derive contextual-turn counts from trusted policy instead of message text. Cover both privacy boundaries and build the shared runner protocol in its existing CI lane.

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* fix(workbot): reject credential-like model telemetry

Do not treat reflected model keys, turn tokens or provider prose as model identifiers. Protect both admission and terminal delivery, omit unsafe identities at the sink and retain unknown attribution without dropping the outcome.

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>

* fix(workbot): bind telemetry to an explicit trusted Den origin

* fix(workbot): preserve Responses attribution and prove key redaction

---------

Signed-off-by: Benjamin Shafii <benjamin.shafii@gmail.com>
2026-10-18 17:20:37 -07:00

87 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Workbot on this machine: Den (where people sign in), the headless runner, and the Workbot app, wired together
# and reloading on save.
#
# pnpm dev:den:mysql # once, starts MySQL and Redis in Docker
# pnpm dev:workbot # then open http://localhost:3020 and sign in with a Den account
#
# Workbot needs its capability on for your organization: Den's /admin panel, or the den_set_org_capability admin
# tool. The runner talks to Anthropic directly. It uses HEADLESS_MODEL_API_KEY when set, otherwise
# ANTHROPIC_API_KEY, otherwise the team's dev key from Infisical. Override the model with HEADLESS_MODEL.
# Files are kept on disk in .data/workbot-files; set HEADLESS_FILES=off to turn them off.
# Each conversation gets a Linux computer (a Freestyle VM) when FREESTYLE_API_KEY is set or Infisical has it
# (dev, /openwork-ops); HEADLESS_COMPUTER=off turns it off.
#
# Ports: DEN_WEB_PORT (3005), DEN_API_PORT (8788), HEADLESS_PORT (8795), WORKBOT_PORT (3020). DATABASE_URL picks
# Den's database, as for pnpm dev:den.
set -euo pipefail
cd "$(dirname "$0")/.."
RUNNER_PORT="${HEADLESS_PORT:-8795}"
API_PORT="${DEN_API_PORT:-8788}"
WEB_PORT="${DEN_WEB_PORT:-3005}"
WORKBOT_PORT="${WORKBOT_PORT:-3020}"
DATA_DIR="${WORKBOT_DATA_DIR:-$PWD/.data}"
# Local-only secrets between Workbot, the runner and Den; not secrets anywhere else.
RUNNER_TOKEN="local-workbot-runner-token-not-a-secret-0000"
SESSION_SECRET="local-workbot-session-secret-not-a-secret-00"
key="${HEADLESS_MODEL_API_KEY:-${ANTHROPIC_API_KEY:-}}"
if [ -z "$key" ] && command -v infisical >/dev/null; then
key="$(infisical secrets get ANTHROPIC_API_KEY --env dev --plain --silent 2>/dev/null || true)"
[ "$key" = "*not found*" ] && key=""
fi
if [ -z "$key" ]; then
echo "dev-workbot: set ANTHROPIC_API_KEY (or log in to Infisical) so the runner can reach a model." >&2
exit 1
fi
computer="${HEADLESS_COMPUTER:-}"
freestyle="${FREESTYLE_API_KEY:-}"
if [ "$computer" != "off" ] && [ -z "$freestyle" ] && command -v infisical >/dev/null; then
freestyle="$(infisical secrets get FREESTYLE_API_KEY --env dev --path /openwork-ops --plain --silent 2>/dev/null || true)"
[ "$freestyle" = "*not found*" ] && freestyle=""
fi
if [ -z "$computer" ]; then
if [ -n "$freestyle" ]; then computer=freestyle; else computer=off; fi
fi
if [ "$computer" = "freestyle" ]; then
# A no-op unless the computer image changed; then it builds the new snapshot (about three minutes).
FREESTYLE_API_KEY="$freestyle" pnpm --filter @openwork-ee/headless-computer snapshot:build
fi
mkdir -p "$DATA_DIR"
pids=()
trap 'kill "${pids[@]}" 2>/dev/null || true' EXIT INT TERM
HEADLESS_COMPUTER="$computer" \
FREESTYLE_API_KEY="$freestyle" \
HEADLESS_API_TOKEN="$RUNNER_TOKEN" \
HEADLESS_PORT="$RUNNER_PORT" \
HEADLESS_DB_PATH="${HEADLESS_DB_PATH:-$DATA_DIR/workbot-runner.sqlite}" \
HEADLESS_MODEL_PROTOCOL="${HEADLESS_MODEL_PROTOCOL:-anthropic}" \
HEADLESS_MODEL_BASE_URL="${HEADLESS_MODEL_BASE_URL:-https://api.anthropic.com/v1}" \
HEADLESS_MODEL="${HEADLESS_MODEL:-claude-sonnet-5-5}" \
HEADLESS_MODEL_API_KEY="$key" \
HEADLESS_MCP_URL="http://127.0.0.1:${API_PORT}/mcp/agent" \
HEADLESS_WORKBOT_DEN_API_URL="http://127.0.0.1:${API_PORT}" \
HEADLESS_FILES="${HEADLESS_FILES:-disk}" \
HEADLESS_FILES_DIR="${HEADLESS_FILES_DIR:-$DATA_DIR/workbot-files}" \
pnpm --filter @openwork-ee/headless-runner dev &
pids+=($!)
WORKBOT_PUBLIC_URL="http://localhost:${WORKBOT_PORT}" \
WORKBOT_PORT="$WORKBOT_PORT" \
WORKBOT_DEN_API_URL="http://localhost:${API_PORT}" \
WORKBOT_DEN_WEB_URL="http://localhost:${WEB_PORT}" \
WORKBOT_RUNNER_URL="http://127.0.0.1:${RUNNER_PORT}" \
WORKBOT_RUNNER_TOKEN="$RUNNER_TOKEN" \
WORKBOT_SESSION_SECRET="$SESSION_SECRET" \
pnpm --filter @openwork-ee/workbot dev &
pids+=($!)
DEN_WORKBOT_URL="http://localhost:${WORKBOT_PORT}" \
DEN_HEADLESS_RUNNER_URL="http://127.0.0.1:${RUNNER_PORT}" \
DEN_HEADLESS_RUNNER_TOKEN="$RUNNER_TOKEN" \
pnpm dev:den