@tnunamak/dalan 0.0.0-stage → 0.5.2

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.
Files changed (182) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/CONTRIBUTING.md +26 -0
  3. package/LICENSE +204 -0
  4. package/PROTOCOL.md +339 -0
  5. package/README.md +348 -2
  6. package/SECURITY.md +30 -0
  7. package/bin/dalan.mjs +38 -0
  8. package/bin/dot-acp-agent.mjs +377 -0
  9. package/bin/dot-alert.mjs +9 -0
  10. package/bin/dot-deadman.mjs +82 -0
  11. package/bin/dot-heartbeat.mjs +29 -0
  12. package/bin/dot-pr-reviewer.mjs +32 -0
  13. package/bin/dot-worker.mjs +755 -0
  14. package/docs/chatgpt-worker-onboarding.md +112 -0
  15. package/docs/claude-worker-onboarding.md +113 -0
  16. package/docs/connect-chatgpt.md +78 -0
  17. package/docs/connection-longevity.md +37 -0
  18. package/docs/dalan-upgrade.md +242 -0
  19. package/docs/deadman.md +59 -0
  20. package/docs/dot-pr-reviewer.config.example.json +9 -0
  21. package/docs/durability-audit.md +27 -0
  22. package/docs/keycloak-client-chatgpt-dot-bridge.json +59 -0
  23. package/docs/keycloak-oauth-setup.md +30 -0
  24. package/docs/local-agent-mcp.md +39 -0
  25. package/docs/manual-setup.md +135 -0
  26. package/docs/mirror-fetch.md +98 -0
  27. package/docs/operations.md +751 -0
  28. package/docs/operator-duties.md +68 -0
  29. package/docs/owner-integrator.md +27 -0
  30. package/docs/portable-auth-profile.md +109 -0
  31. package/docs/pr-head-reviewer.md +54 -0
  32. package/docs/pr-preflight.md +26 -0
  33. package/docs/pull-workers.md +97 -0
  34. package/docs/redaction.md +27 -0
  35. package/docs/service-setup.md +166 -0
  36. package/docs/setup-reference.md +80 -0
  37. package/docs/t3-connector-icon.png +0 -0
  38. package/docs/t3-integration.md +49 -0
  39. package/docs/t3-result-retry-delivery.md +41 -0
  40. package/docs/t3-reverse-control.md +107 -0
  41. package/docs/usage.md +439 -0
  42. package/docs/worker-clients.md +285 -0
  43. package/integrations/t3/acp-kit/src/capability.mjs +25 -0
  44. package/integrations/t3/acp-kit/src/errors.mjs +13 -0
  45. package/integrations/t3/acp-kit/src/index.mjs +5 -0
  46. package/integrations/t3/acp-kit/src/lock.mjs +155 -0
  47. package/integrations/t3/acp-kit/src/session-store.mjs +36 -0
  48. package/integrations/t3/acp-kit/src/t3-envelope.mjs +62 -0
  49. package/package.json +65 -4
  50. package/packages/job-core/README.md +18 -0
  51. package/packages/job-core/index.mjs +2 -0
  52. package/packages/job-core/package.json +8 -0
  53. package/packages/job-core/protocol/canonical.mjs +11 -0
  54. package/packages/job-core/protocol/v0/command.schema.json +1154 -0
  55. package/packages/job-core/protocol/v0/event.schema.json +77 -0
  56. package/packages/job-core/protocol/v0/reply.schema.json +59 -0
  57. package/packages/job-core/transitions.mjs +25 -0
  58. package/scripts/daily-selfcheck.mjs +135 -0
  59. package/scripts/lib/expose-tailscale.mjs +408 -0
  60. package/scripts/live-trial/common.mjs +272 -0
  61. package/scripts/monitor-targets.mjs +44 -0
  62. package/scripts/upgrade-drain.mjs +39 -0
  63. package/scripts/worker-bridge-setup.mjs +925 -0
  64. package/src/ack-ledger.mjs +37 -0
  65. package/src/acp-bridge.mjs +412 -0
  66. package/src/acp-context.mjs +138 -0
  67. package/src/admin-socket.mjs +14 -0
  68. package/src/alerts.mjs +147 -0
  69. package/src/artifact-journal.mjs +75 -0
  70. package/src/as-files.mjs +347 -0
  71. package/src/as-store.mjs +456 -0
  72. package/src/as.mjs +497 -0
  73. package/src/auth.mjs +166 -0
  74. package/src/builtin-http.mjs +22 -0
  75. package/src/check-coverage.mjs +38 -0
  76. package/src/check-lint.mjs +88 -0
  77. package/src/check-readiness.mjs +112 -0
  78. package/src/check-response.mjs +19 -0
  79. package/src/claim-command-ledger.mjs +51 -0
  80. package/src/cli-help.mjs +172 -0
  81. package/src/cli-name.mjs +16 -0
  82. package/src/connect-cli.mjs +126 -0
  83. package/src/consumers.mjs +61 -0
  84. package/src/deadman.mjs +329 -0
  85. package/src/delivery.mjs +19 -0
  86. package/src/demo-worker.mjs +150 -0
  87. package/src/destinations/index.mjs +23 -0
  88. package/src/destinations/none.mjs +15 -0
  89. package/src/destinations/t3.mjs +109 -0
  90. package/src/diagnostic.mjs +78 -0
  91. package/src/docs-url.mjs +9 -0
  92. package/src/drain-runner.mjs +9 -0
  93. package/src/drained-slot.mjs +53 -0
  94. package/src/drained.mjs +40 -0
  95. package/src/durable-waiters.mjs +236 -0
  96. package/src/env.mjs +19 -0
  97. package/src/execution.mjs +112 -0
  98. package/src/failure-type.mjs +28 -0
  99. package/src/get-summary.mjs +32 -0
  100. package/src/git-env.mjs +15 -0
  101. package/src/host-budget-receipts.mjs +154 -0
  102. package/src/host-budget-seccomp.py +33 -0
  103. package/src/host-budget-service.mjs +54 -0
  104. package/src/host-budget-stop.mjs +26 -0
  105. package/src/host-budget-storage.py +259 -0
  106. package/src/host-budget.mjs +149 -0
  107. package/src/host-cgroup.mjs +23 -0
  108. package/src/host-check-allowlist.mjs +42 -0
  109. package/src/host-execution-policy.mjs +38 -0
  110. package/src/host-health.mjs +34 -0
  111. package/src/host-stop-reverify.mjs +44 -0
  112. package/src/inbox.mjs +55 -0
  113. package/src/integrator.mjs +322 -0
  114. package/src/job-retention.mjs +69 -0
  115. package/src/legacy-names.mjs +8 -0
  116. package/src/lifecycle.mjs +291 -0
  117. package/src/limits.mjs +31 -0
  118. package/src/loopback.mjs +9 -0
  119. package/src/mcp-outcome.mjs +70 -0
  120. package/src/mcp-stdio.mjs +191 -0
  121. package/src/mirror-fetch-lock.py +164 -0
  122. package/src/mirror-fetch.mjs +174 -0
  123. package/src/notify-ledger.mjs +82 -0
  124. package/src/objectives.mjs +129 -0
  125. package/src/owner-report-artifact.mjs +66 -0
  126. package/src/patch-apply.mjs +84 -0
  127. package/src/path-syntax.mjs +16 -0
  128. package/src/paths.mjs +67 -0
  129. package/src/pr-head-reviewer.mjs +596 -0
  130. package/src/pr-preflight.mjs +51 -0
  131. package/src/prepared-node-modules.mjs +129 -0
  132. package/src/projects.mjs +480 -0
  133. package/src/protocol-artifact-commands.mjs +52 -0
  134. package/src/protocol-delivery-driver.mjs +167 -0
  135. package/src/protocol-finish.mjs +100 -0
  136. package/src/protocol-owner-command.mjs +35 -0
  137. package/src/protocol-owner-mutations.mjs +22 -0
  138. package/src/protocol-owner-waiters.mjs +67 -0
  139. package/src/protocol-retention.mjs +52 -0
  140. package/src/protocol-services.mjs +61 -0
  141. package/src/protocol-stop-observer.mjs +131 -0
  142. package/src/publish-plan.mjs +245 -0
  143. package/src/redaction.mjs +763 -0
  144. package/src/rejections.mjs +18 -0
  145. package/src/request-log.mjs +102 -0
  146. package/src/restore-check.mjs +90 -0
  147. package/src/result-binding.mjs +65 -0
  148. package/src/runtime-check.mjs +13 -0
  149. package/src/sandbox-supervisor.mjs +105 -0
  150. package/src/schema-subset.mjs +186 -0
  151. package/src/scopes.mjs +15 -0
  152. package/src/server.mjs +1340 -0
  153. package/src/shutdown-signal.mjs +12 -0
  154. package/src/signal-sandbox-processes.py +56 -0
  155. package/src/signal.mjs +119 -0
  156. package/src/status-evidence.mjs +47 -0
  157. package/src/status-summary.mjs +54 -0
  158. package/src/store.mjs +3057 -0
  159. package/src/submission-policy.mjs +623 -0
  160. package/src/subscription-storage.mjs +64 -0
  161. package/src/t3-audit.mjs +120 -0
  162. package/src/t3-control.mjs +102 -0
  163. package/src/t3-transport.mjs +158 -0
  164. package/src/t3.mjs +209 -0
  165. package/src/terminal-safe.mjs +19 -0
  166. package/src/tool-registry.mjs +451 -0
  167. package/src/try-command.mjs +11 -0
  168. package/src/try.mjs +589 -0
  169. package/src/webhooks.mjs +86 -0
  170. package/src/work-order.mjs +265 -0
  171. package/src/worker-instructions.mjs +26 -0
  172. package/src/worker-prompt.mjs +4 -0
  173. package/src/workers.mjs +622 -0
  174. package/src/workspace.mjs +1058 -0
  175. package/systemd/dot-bridge-heartbeat.service +18 -0
  176. package/systemd/dot-bridge-heartbeat.timer +10 -0
  177. package/systemd/dot-bridge-selfcheck.service +12 -0
  178. package/systemd/dot-bridge-selfcheck.timer +11 -0
  179. package/systemd/dot-bridge.service +17 -0
  180. package/systemd/dot-deadman.service +30 -0
  181. package/systemd/dot-pr-reviewer.service +11 -0
  182. package/systemd/dot-pr-reviewer.timer +10 -0
@@ -0,0 +1,112 @@
1
+ # ChatGPT cloud worker: manual first connection
2
+
3
+ This recipe is for a ChatGPT-hosted worker using a remote MCP connector with the bridge's built-in authorization server. It is not a Codex CLI requester setup, an API integration, or a claim that every paid account can run an unattended worker. The first acceptance test is **one repository-free text assignment, execution none, triggered manually**. No schedule or signal hook is part of onboarding.
4
+
5
+ The owner completes the setup and first-job checks below on the intended account and computer. The commands below are for a separately authorized operator.
6
+
7
+ ## 1. Check features and the existing bridge
8
+
9
+ - Confirm that the intended account/workspace can add a custom remote MCP server, authorize it with OAuth, and invoke its tools in the intended cloud conversation. OpenAI says account/workspace policies govern custom MCP access; stop if the controls are absent rather than changing a subscription or policy. [Connection guide](https://developers.openai.com/plugins/deploy/connect-chatgpt#add-the-mcp-server)
10
+ - Background runs, schedules, push wake and continuous execution are separate capabilities and not prerequisites for this manual smoke; ordinary chat access does not prove any of them.
11
+ - Have the owner complete the [public-service owner setup](service-setup.md#owner-setup) and make `dalan` available on your PATH with `DALAN_HOME` set to that setup's bridge home. Retain the same generated HOME, worker profile and `<bridge-home>/resource-url` throughout this recipe. Use an existing dedicated worker profile with no T3 capability and no allowed repositories. `NAME` below means that exact profile name, not the account display name. Do not change the profile to make a failed test pass.
12
+ - Use the existing public **HTTPS resource URL**, including its secret path and `/mcp`, from `<bridge-home>/resource-url` (mode 0600); never substitute the host root or an authorization endpoint. Prefer standard public port 443 for the trial. This is a conservative deployment choice, not a claim that OpenAI forbids other ports. OpenAI documents public HTTPS and authentication discovery for this path. [Endpoint requirements](https://developers.openai.com/plugins/deploy/connect-chatgpt#prepare-the-endpoint)
13
+ - Before account linking, have the owner verify the public surface from outside the private network: path-suffixed resource/authorization discovery returns 200; tokenless MCP returns 401; unsuffixed discovery, root and `/admin` return 404. The existing [live-trial public check](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md#3-verify-from-outside-the-tailnet) reads the resource URL from a private file. Reuse its check, but not its job: that job is not this smoke.
14
+
15
+ ## 2. Resolve the exact callback before registration
16
+
17
+ **Do not paste a callback template.** OpenAI directs operators to copy the exact production redirect URI from the MCP server's management page. Current documentation distinguishes callback-ID-specific `https://chatgpt.com/connector/oauth/{callback_id}` from stable `https://chatgpt.com/connector_platform_oauth_redirect`; stable selection depends on issuer-identification support, with an older-server exception. This recipe does not assume which mode the pinned bridge will select. [Redirect rules](https://developers.openai.com/plugins/build/auth#redirect-url)
18
+
19
+ The same source documents protected-resource discovery, DCR through `registration_endpoint`, and CIMD as a different client-identity path. DCR registers a client; CIMD does not. A predefined/static OAuth client instead requires an already registered ID and matching client-authentication method. A static client secret is not a bearer token. [OAuth/client registration](https://developers.openai.com/plugins/build/auth#oauth-flow)
20
+
21
+ For this built-in recipe, use DCR only if offered and compatible. This recipe covers Dynamic Client Registration; other registration methods need separate instructions from the owner. Do not invent credentials, switch issuers, add headers, or modify discovery/auth policy. If only another method is available, stop and ask the owner for that separately validated path.
22
+
23
+ Owner sequence:
24
+
25
+ 1. Inspect the current MCP connection management UI and copy its **complete exact callback** through the vendor-supported flow. Record the source and observed callback privately. If this screen is unavailable before the first registration, stop at this step: ask the owner to capture the current UI/official instructions that expose it. Do not allow a wildcard or begin a guessing loop.
26
+ 2. Verify HTTPS, exact vendor host and full path, including any connection-specific suffix. The bridge refuses callback queries, fragments and credentials. The `as_registration_refused` log records no callback details; it is not a callback source. [Bridge callback handling](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md#4-pair-fixture-a-and-allow-its-callback)
27
+ 3. On the bridge host, allow that value **before DCR**, then open the short pairing window:
28
+
29
+ ```sh
30
+ printf 'Exact verified ChatGPT callback: '
31
+ IFS= read -r CALLBACK_URL
32
+ dalan connect allow-callback "$CALLBACK_URL"
33
+ unset CALLBACK_URL
34
+ dalan connect start --worker NAME
35
+ ```
36
+
37
+ If the callback differs from the source or the bridge rejects it, stop; do not broaden the allowlist or change auth mode. Record the callback that ChatGPT showed so you can check the allowlist against it later.
38
+
39
+ ## 3. Add, pair and inspect the connector
40
+
41
+ The current documented entry is **ChatGPT Plugins → plus → Add custom MCP server**. Supply a descriptive name and the bridge's exact resource URL, configure OAuth, review the risk warning, and create the personal plugin. Do not copy the quickstart's unauthenticated example. Inspect the discovered tools and install only for the intended account. [Connection guide](https://developers.openai.com/plugins/deploy/connect-chatgpt#add-the-mcp-server), [personal-plugin quickstart](https://developers.openai.com/plugins/quickstart)
42
+
43
+ If the UI instead shows **Settings → Apps → Advanced → Developer mode** and **Plugins → Create**, follow [ChatGPT user setup](connect-chatgpt.md#chatgpt-user-setup); the pairing and code-match checks are the same. For other UI differences, use current official guidance for the screen actually present.
44
+
45
+ During the owner-initiated browser flow:
46
+
47
+ ```sh
48
+ dalan connect pending
49
+ ```
50
+
51
+ Compare the browser pairing code **exactly** with the local pending code. Check the expected worker, client ID, full callback, resource and scopes; a familiar client name or vendor callback does not establish which account initiated the flow. Approve only the matching code, within the 10-minute window:
52
+
53
+ ```sh
54
+ dalan connect approve CODE --worker NAME
55
+ ```
56
+
57
+ These are bridge pairing requirements, not vendor UI claims. A missing/mismatched code, unexpected scopes or expired window is a stop, not permission to approve an entry without code comparison over a trusted channel. [Bridge pairing flow](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md#4-pair-fixture-a-and-allow-its-callback)
58
+
59
+ Before a job, inspect the actual connected catalog. The text smoke needs `list_pending`, `get`, `claim`, `progress` and `finish`; `ack_message` is useful only for messages. A generic no-T3 profile must not expose `t3_thread_*` or `notify_owner`. Repository tools, if enabled on the existing host, are not needed and must not be called by this execution-none job. Missing tools or unexpected privilege are blockers, not reasons to expand the profile.
60
+
61
+ For stale schemas, OpenAI documents refreshing the connection and retesting in a new conversation. [Metadata refresh](https://developers.openai.com/plugins/deploy/connect-chatgpt#refresh-metadata) Verify that the refreshed tool catalog exposes optional `acquisition_id`. Do not infer that every client needs, or never needs, a new conversation. Inspect the live `claim` schema and record what actually refreshed; any new Work/Codex task needs its own required authorization.
62
+
63
+ ## 4. One owner-submitted text smoke
64
+
65
+ Only after the owner authorizes a real trial, create the assignment locally. This generates a unique request ID and harmless nonce; it does not submit anything:
66
+
67
+ ```sh
68
+ node --input-type=module > first-job.json <<'NODE'
69
+ import { randomUUID } from 'node:crypto';
70
+ const nonce = randomUUID();
71
+ console.log(JSON.stringify({
72
+ schema_version: 1,
73
+ request_id: `req_${randomUUID()}`,
74
+ brief: `Text-only bridge smoke. Return exactly SMOKE ${nonce}. Do not access repositories, run checks, start other jobs, or change any state outside this assignment's claim/progress/finish lifecycle.`,
75
+ inputs: [],
76
+ scope_paths: [],
77
+ execution_scope: 'read-only',
78
+ expected_output: `A completed text report containing exactly SMOKE ${nonce}.`
79
+ }, null, 2));
80
+ NODE
81
+ ```
82
+
83
+ The distinction matters: **`execution_scope` is `read-only`; executor selection is separately `--execution none`**, not `execution_scope: "none"`. No repository input or repository grant is required. The owner submits to the existing selected profile with quiet delivery (the default):
84
+
85
+ ```sh
86
+ dalan submit --worker NAME --execution none --file first-job.json
87
+ dalan get REQUEST_ID --json
88
+ ```
89
+
90
+ Use the `request_id` from the submit response for `REQUEST_ID`. Save the JSON and that ID; if the response is lost, retry the identical file/ID, not a new job. Confirm `execution` is `none` and the intended target worker before continuing. These submission fields were confirmed by the owner for the pinned base; no submission was made while writing this page.
91
+
92
+ Manually ask the already authorized cloud conversation to do exactly this (replace `REQUEST_ID` with the confirmed ID and explicitly select the connected bridge):
93
+
94
+ > Check the bridge once for REQUEST_ID only. Read it with get and stop if cancelled, revoked, mismatched or outside this text-only scope. Use list_pending to locate it. Before claiming, generate and privately save one random acquisition_id for this run. Never print this claim nonce (acquisition_id), even in diagnostics, examples or reports. Keep it in private saved run state and reuse it only for this acquisition. Use your stable claimant and that same acquisition_id on every claim retry. Save only the claim_id directly returned by your claim; do not borrow a grant from get. Read owner notes, send progress, echo the assigned nonce through a completed text finish using the current tool schema, then stop. Do not claim another job, call repository/check tools, create a Work/Codex task, invoke a model API, or add a schedule.
95
+
96
+ For ChatGPT's documented direct plugin invocation, select the plugin using `@` in the intended authorized conversation; this is not permission to start a new Work task. [Official quickstart](https://developers.openai.com/plugins/quickstart) No push delivery or scheduled wake is assumed. A blocker must go through `progress` to the submitting owner, not to an unrelated person.
97
+
98
+ After the worker finishes, the owner reads the bridge record, not just the chat reply:
99
+
100
+ ```sh
101
+ dalan get REQUEST_ID --json
102
+ ```
103
+
104
+ Check terminal completed status, the intended target and claim/report attribution, execution none, and the exact nonce from `first-job.json`. Keep a redacted receipt. A conversational answer without the matching bridge `finish` record is a failure. `get` marks the result read; record a disposition only after reviewing it. See [requester commands](../README.md#commands-that-matter). Stop after this one job; repository work and recurring triggers require separate acceptance.
105
+
106
+ ## 5. Limits and owner acceptance record
107
+
108
+ Keep a redacted ledger with date, account/workspace feature availability, bridge commit, worker profile, public-surface results, exact callback **source**, chosen registration method, matching-code result, displayed tool names/schema, request ID, manual trigger time, claim/finish result and owner `get` result. Keep resource URLs, private URLs, codes, claim/acquisition IDs, tokens and client secrets out of shared evidence.
109
+
110
+ Do not mark the journey accepted until the owner completes every required check on the intended account and computer. This recipe covers manual jobs with Dynamic Client Registration on ChatGPT web. Other registration methods, mobile or older UI variants, long-lived refresh and unattended wake need separate setup instructions.
111
+
112
+ If a gate fails, report the exact step, sanitized error and next observation to the submitting owner. Leave schedules off, do not create another job to hide the failure, and use the owner's existing teardown plan for any authorized trial exposure. This page authorizes no login, settings, subscription, permission or host-network change.
@@ -0,0 +1,113 @@
1
+ # Claude cloud worker: manual first connection
2
+
3
+ This recipe connects a Claude-hosted conversation to the bridge's built-in authorization server through a remote MCP custom connector. It is not Claude Code's local MCP/requester flow or a Messages API integration. Start with **one repository-free text assignment, execution none, triggered manually**. Do not enable a schedule, hosted background feature or signal hook for the first smoke.
4
+
5
+ For a new hosted-worker installation, begin with [Run Dalan as a service](service-setup.md#owner-setup), using a public HTTPS origin and your selected worker `NAME`. A provider-hosted connector cannot reach the README's loopback trial. Install the checkout using [owner and requester setup](manual-setup.md#owner-and-requester-setup), then follow the service guide rather than starting the loopback server. Keep the service's bridge home and worker identity throughout pairing, submission and result retrieval.
6
+
7
+ The owner completes the setup and first-job checks below on the intended account and computer. All commands below are for a separately authorized operator.
8
+
9
+ ## 1. Check features and the existing bridge
10
+
11
+ - Confirm that this account/workspace can add or use a custom remote MCP connector, perform OAuth, enable it in a conversation, and call the required tools. On managed plans, organization role and connector access matter; the official help page describes owner setup before member connection. A plan label alone is not an access test. [Custom connector setup](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)
12
+ - Unattended execution and background-worker availability are separate observations. An interactive manual smoke proves neither. If a required connector control is absent, stop and have the owner verify access; do not upgrade, change roles, or add a subscription.
13
+ - Have the owner complete [service setup](service-setup.md#owner-setup) and define the `dalan` helper for the service's `DALAN_HOME`. Use an existing dedicated profile with no T3 capability and no repository allowlist. `NAME` below is that exact worker name. No policy changes are part of this recipe.
14
+ - Supply the public **HTTPS resource URL** from the private `<bridge-home>/resource-url` file, including its secret path and `/mcp`. Do not use the origin, an OAuth endpoint or localhost. Claude's remote connector traffic originates from Anthropic infrastructure, even when the UI is on a local device. [Network requirements](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp#network-requirements)
15
+ - Prefer public HTTPS port 443 as a simple trial default, not an asserted Claude port restriction. Have the owner verify path-suffixed resource/authorization discovery (200), tokenless MCP (401), and unsuffixed discovery/root/`/admin` (404) from outside the private network. The [public-surface checker](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md#3-verify-from-outside-the-tailnet) consumes a private resource-file value; do not reuse an unrelated example job.
16
+
17
+ ## 2. Allow the sourced callback, then choose registration
18
+
19
+ Anthropic documents this exact callback for hosted Claude surfaces:
20
+
21
+ ```text
22
+ https://claude.ai/api/mcp/auth_callback
23
+ ```
24
+
25
+ Claude Code uses a different loopback flow; do not weaken the bridge's HTTPS callback policy to accommodate it in this cloud-worker recipe. [Official callback URLs](https://claude.com/docs/connectors/building/authentication#callback-urls)
26
+
27
+ On the bridge host, **before registration**:
28
+
29
+ ```sh
30
+ dalan connect allow-callback 'https://claude.ai/api/mcp/auth_callback'
31
+ dalan connect start --worker NAME
32
+ ```
33
+
34
+ The current custom-connector UI distinguishes automatic registration, published identity (CIMD), and a supplied OAuth client. Choose **Register automatically** for this DCR recipe, not the published-identity default simply because it is recommended in the UI. [Connector setup](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)
35
+
36
+ DCR discovers `registration_endpoint` and creates the client. A static OAuth client requires the owner to register the exact redirect first and supply the matching client ID/authentication credentials; it is not a static request-header token. CIMD is another identity method, not DCR. [Claude authentication](https://claude.com/docs/connectors/building/authentication#register-claude-as-an-oauth-client)
37
+
38
+ This recipe covers automatic client registration; other registration methods need separate instructions from the owner. If automatic registration is absent or fails, stop and ask for an owner-validated variant; do not invent client credentials, switch to no-auth, add bearer headers, change issuers or broaden callback patterns. Verify a differing callback against current official hosted-surface documentation before making any allowlist change.
39
+
40
+ ## 3. Add, pair and inspect the connector
41
+
42
+ For the documented individual-account path, open **Customize → Connectors**, use **+ Add**, then **Add custom connector**. Enter the name and exact resource URL, review detected authentication, and choose OAuth sign-in plus automatic registration. Managed workspaces follow the owner/member steps in the same source rather than this individual's path. [Official setup](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp)
43
+
44
+ If the screen differs, record the current labels and the role and access outcome before you proceed.
45
+
46
+ In the browser flow you initiated, wait for the bridge's pairing code. On the owner host:
47
+
48
+ ```sh
49
+ dalan connect pending
50
+ ```
51
+
52
+ Compare the browser and local codes exactly. Check the requested worker, full callback, resource, scopes and client ID. The client name and `claude.ai` hostname alone cannot identify the initiating account. Approve only the matching code within the 10-minute pairing window:
53
+
54
+ ```sh
55
+ dalan connect approve CODE --worker NAME
56
+ ```
57
+
58
+ These are bridge requirements. A code mismatch, expired window or unexpected callback/scope means stop, not auto-approve. The `as_registration_refused` DCR-refusal log records no callback details; never reconstruct an allowlist entry from it. [Bridge pairing requirements](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md#4-pair-fixture-a-and-allow-its-callback)
59
+
60
+ Anthropic's test guide says to verify connected state, review **Tool permissions**, then enable the connector from **+ → Connectors** in a chat and confirm an actual tool call. [Test guide](https://claude.com/docs/connectors/building/testing#test-in-claude-as-a-custom-connector)
61
+
62
+ For this smoke, require `list_pending`, `get`, `claim`, `progress` and `finish`; `ack_message` is only for messages. The generic no-T3 profile must expose neither `t3_thread_*` nor `notify_owner`. Repository tools may depend on existing host configuration, but are unnecessary and must not be called for the execution-none job. Verify the actual `claim` schema, including optional `acquisition_id`, instead of importing ChatGPT's refresh behavior. Missing tools or excess privileges are owner blockers; do not expand policy.
63
+
64
+ ## 4. One owner-submitted text smoke
65
+
66
+ Only after the owner authorizes a real trial, create the assignment locally. This generates a unique request ID and harmless nonce; it does not submit anything:
67
+
68
+ ```sh
69
+ node --input-type=module > first-job.json <<'NODE'
70
+ import { randomUUID } from 'node:crypto';
71
+ const nonce = randomUUID();
72
+ console.log(JSON.stringify({
73
+ schema_version: 1,
74
+ request_id: `req_${randomUUID()}`,
75
+ brief: `Text-only bridge smoke. Return exactly SMOKE ${nonce}. Do not access repositories, run checks, start other jobs, or change any state outside this assignment's claim/progress/finish lifecycle.`,
76
+ inputs: [],
77
+ scope_paths: [],
78
+ execution_scope: 'read-only',
79
+ expected_output: `A completed text report containing exactly SMOKE ${nonce}.`
80
+ }, null, 2));
81
+ NODE
82
+ ```
83
+
84
+ The distinction matters: **`execution_scope` is `read-only`; executor selection is separately `--execution none`**, not `execution_scope: "none"`. No repository input or repository grant is required. The owner submits to the existing selected profile with quiet delivery (the default):
85
+
86
+ ```sh
87
+ dalan submit --worker NAME --execution none --file first-job.json
88
+ dalan get REQUEST_ID --json
89
+ ```
90
+
91
+ Use the `request_id` from the submit response for `REQUEST_ID`. Save the JSON and that ID; if the response is lost, retry the identical file/ID, not a new job. Confirm `execution` is `none` and the intended target worker before continuing. These submission fields were confirmed by the owner for the pinned base; no submission was made while writing this page.
92
+
93
+ Manually ask the already authorized cloud conversation to do exactly this (replace `REQUEST_ID` with the confirmed ID and explicitly select the connected bridge):
94
+
95
+ > Check the bridge once for REQUEST_ID only. Read it with get and stop if cancelled, revoked, mismatched or outside this text-only scope. Use list_pending to locate it. Before claiming, generate and privately save one random acquisition_id for this run. Never print this claim nonce (acquisition_id), even in diagnostics, examples or reports. Keep it in private saved run state and reuse it only for this acquisition. Use your stable claimant and that same acquisition_id on every claim retry. Save only the claim_id directly returned by your claim; do not borrow a grant from get. Read owner notes, send progress, echo the assigned nonce through a completed text finish using the current tool schema, then stop. Do not claim another job, call repository/check tools, create a Work/Codex task, invoke a model API, or add a schedule.
96
+
97
+ Use the connector you enabled in the intended Claude chat. Push delivery and scheduled wake are not assumed. A blocker must go through `progress` to the submitting owner, not to an unrelated person.
98
+
99
+ After the worker finishes, the owner reads the bridge record, not just the chat reply:
100
+
101
+ ```sh
102
+ dalan get REQUEST_ID --json
103
+ ```
104
+
105
+ Check terminal completed status, the intended target and claim/report attribution, execution none, and the exact nonce from `first-job.json`. Keep a redacted receipt. A conversational answer without the matching bridge `finish` record is a failure. `get` marks the result read; record a disposition only after reviewing it. See [Operate and recover](../README.md#operate-and-recover). Stop after this one job; repository work and recurring triggers require separate acceptance.
106
+
107
+ ## 5. Limits and owner acceptance record
108
+
109
+ Record a redacted date/account-feature/bridge-commit ledger: worker profile, public-surface outcomes, official callback source and actual match, DCR selection, exact pairing-code comparison outcome, displayed catalog/schema, request ID, manual trigger, claim/finish result and owner `get`. Keep resource URLs (they contain the secret path), codes, credentials and claim/acquisition IDs out of shared evidence.
110
+
111
+ Acceptance requires the intended account and computer to pass every check. This recipe covers manual jobs with automatic registration. Other registration methods, long-lived token refresh, hosted background execution, automatic wake and schedules need separate setup instructions.
112
+
113
+ If a gate fails, send the exact failed step, sanitized error and required next observation to the submitting owner. Do not start a replacement job or change the profile to hide the failure. Keep recurring triggers disabled and use the owner's teardown plan for any authorized trial exposure. This recipe grants no authority for account, permission, subscription or host-network changes.
@@ -0,0 +1,78 @@
1
+ # Connect ChatGPT as a Dalan worker
2
+
3
+ This guide takes you from a built-in OAuth connection to one completed job. Use ChatGPT on the web with custom MCP connections enabled for your account or workspace; UI labels can vary. The owner runs Dalan and approves the connection; the ChatGPT user connects the worker and starts its run. One person can perform both roles.
4
+
5
+ ## Owner setup
6
+
7
+ 1. Follow the [service setup](service-setup.md) with a publicly reachable HTTPS origin. Set `DALAN_HOME` to that service's private home and make `dalan` available on your PATH with the [manual setup](manual-setup.md#owner-and-requester-setup) steps. Use the service's worker name wherever this guide says `NAME`.
8
+
9
+ ```sh
10
+ dalan status --json
11
+ ```
12
+
13
+ Status shows the running bridge. Read the complete MCP URL from the private `$DALAN_HOME/resource-url` file. It has the form `https://HOST/<secret>/mcp`; enter the actual URL only in connector setup. A localhost URL cannot reach the bridge from ChatGPT's servers.
14
+
15
+ 2. Open a pairing window for that worker.
16
+
17
+ ```sh
18
+ dalan connect start --worker NAME
19
+ ```
20
+
21
+ The response shows an open window for `NAME`; the default is ten minutes. Fresh init already allows `https://chatgpt.com/connector_platform_oauth_redirect` and the callback-ID form `https://chatgpt.com/connector/oauth/*`. An existing installation retains its saved allowlist. If its attempt uses the exact callback observed below and that callback is absent, add it before retrying.
22
+
23
+ ```sh
24
+ dalan connect allow-callback 'https://chatgpt.com/connector_platform_oauth_redirect'
25
+ ```
26
+
27
+ The command reports the allowed callback. Do not broaden the list to accommodate an unknown redirect.
28
+
29
+ ## ChatGPT user setup
30
+
31
+ 1. In ChatGPT web, enable custom connector creation. Open **Settings → Apps → Advanced → Developer mode**. Then open **Plugins → Create**, enter a connection name and the owner's complete MCP URL, and select **OAuth** authentication. If the UI instead shows **Plugins → plus → Add custom MCP server**, follow [worker onboarding section 3](chatgpt-worker-onboarding.md#3-add-pair-and-inspect-the-connector); the pairing and code-match checks are the same.
32
+
33
+ Let ChatGPT discover the OAuth settings and select its offered Dynamic Client Registration, which registers this client with Dalan. Review the risk acknowledgement and choose **Create**. Do not enter static client credentials. A browser page should show a pairing code; keep it open.
34
+
35
+ 2. Ask the owner to inspect the exact pending attempt on the bridge computer.
36
+
37
+ ```sh
38
+ dalan connect pending
39
+ ```
40
+
41
+ Match the code on the browser page, worker `NAME`, resource, client ID, callback and requested scopes. ChatGPT names itself `ChatGPT` and uses the callback `https://chatgpt.com/connector_platform_oauth_redirect`; the name is untrusted client text. If attempts are ambiguous or a value differs unexpectedly, resolve that before approval.
42
+
43
+ ```sh
44
+ dalan connect approve CODE --worker NAME
45
+ ```
46
+
47
+ The owner replaces `CODE` with the matched code. Approval should let the waiting browser return to ChatGPT. A saved connector is not yet proof of a working job.
48
+
49
+ 3. As requester, save the [first-job JSON](manual-setup.md#submit-finish-and-read-the-result) from the manual setup with a new request ID, then submit it to this worker.
50
+
51
+ ```sh
52
+ dalan submit --worker NAME --execution none --deliver none --file first-job.json --json
53
+ ```
54
+
55
+ The response contains that request ID. In a new ChatGPT conversation, use **+** to attach the connector. Send the manual setup's worker prompt with this request ID. Submission alone does not start ChatGPT.
56
+
57
+ After you start the worker, run wait and get in the requester shell.
58
+
59
+ ```sh
60
+ dalan wait REQUEST_ID
61
+ dalan get REQUEST_ID
62
+ ```
63
+
64
+ Success is a finished report containing `bridge first report`. Read the report. If you accept it, record that decision.
65
+
66
+ ```sh
67
+ dalan decide REQUEST_ID accepted
68
+ ```
69
+
70
+ ## When connection fails
71
+
72
+ If ChatGPT says “Couldn't discover OAuth settings” or “Some app settings were rejected,” inspect discovery, registration, tunnel and TLS stages rather than assuming a single cause. OpenAI does not document a universal port requirement for public custom MCP endpoints. See its [connection guide](https://developers.openai.com/plugins/deploy/connect-chatgpt) and [OAuth guide](https://developers.openai.com/plugins/build/auth).
73
+
74
+ HTTP 421 means the incoming Host does not match the configured public origin, including any non-default port. Preserve Host through the proxy; forwarding a different `X-Forwarded-Host` does not fix it. See [network setup](service-setup.md).
75
+
76
+ If the pairing window expired, open it again with `dalan connect start --worker NAME`, restart connection in ChatGPT and compare the new code with pending attempts. If registration reports an unallowed callback, compare its exact scheme, host and path with the expected ChatGPT redirect before adding it. Public discovery probes do not prove browser approval, token exchange or authenticated MCP calls work.
77
+
78
+ This guide covers ChatGPT on the web; set up a mobile browser separately. Repeat the first job after you reconnect or change endpoint settings, and configure [wake hooks or schedules](pull-workers.md) only after manual jobs work.
@@ -0,0 +1,37 @@
1
+ # Worker connection longevity
2
+
3
+ A worker’s OAuth token, refresh token and event subscription have separate lifetimes. Dalan does not hold or refresh the worker client’s token. The client must refresh its credentials and renew a finite Events subscription before its advertised `refreshBefore` deadline.
4
+
5
+ For an external issuer, inspect its access-token lifetime, parent session limits, refresh-token reuse policy and offline-session limits. A client-session timeout cannot necessarily extend the parent session. If you enable offline access, verify the issuer’s idle and maximum lifetimes and the client’s refresh behavior. Do not copy another deployment’s scope mappings, and do not treat a working subscription as proof that token refresh works.
6
+
7
+ The bridge defaults Events subscriptions to seven days and returns an expiration in `refreshBefore`. Its monitoring reports missing or expiring subscriptions. A manual or scheduled pull worker can operate without an Events subscription; assess health against the worker mode you configured. See [pull workers](pull-workers.md).
8
+
9
+ The legacy `dot-bridge-selfcheck.timer` example and `scripts/daily-selfcheck.mjs` are deployment-specific, so review their repository and subscription assumptions before you use them. Set `DALAN_GITHUB_REPOSITORY` and `DALAN_SELFCHECK_REPOSITORY_ID` (the numeric GitHub repository ID pinned to this installation) in the service environment, for example with a systemd drop-in, before enabling it. The check reads the public resource and the issuer from the bridge's own OAuth file (`oauth.env`, which must be mode 0600 or it is treated as unavailable), and the TLS host defaults to the resource hostname, so no endpoint environment variables are needed (the repository settings above stay required). `DALAN_SELFCHECK_RESOURCE` and `DALAN_SELFCHECK_ISSUER` override the file; an explicit `DALAN_SELFCHECK_TLS_HOST` must equal the resource hostname or the check fails. An alert is sent once per distinct set of failures: a repeated identical failure still exits 1 but sends no new alert until the set changes.
10
+
11
+ ## MCP failure diagnostics
12
+
13
+ After deployment, `~/.local/state/dalan/requests.jsonl` records `mcp_received` before authentication and one `mcp_outcome` when each HTTP response finishes or closes early. A generated `call_id` joins those records to `mcp_inbound`, which still means authentication and request parsing succeeded. A received call with no outcome can indicate a process exit. These MCP records omit URLs, tokens, subjects, client-provided names, RPC IDs, arguments, file paths, contents and exception messages; the one exception is `tool_error_message` on a failed tool call, the bridge's error text redacted like alert notes and cut to 300 characters. Declared methods and tools are retained; undeclared names are logged as `unknown`. Old records are not rewritten. A refused sign-in has an `mcp_outcome` with `http_status` 401 and an `auth_reason`: `missing_bearer`, `invalid_token`, `unsupported_signature`, `invalid_signature`, `jwks_unavailable`, `signing_key_unavailable`, `wrong_issuer`, `wrong_audience`, `malformed_claims`, `expired`, `not_yet_valid`, `unknown_subject`, `invalid_scope`, or for built-in sign-in `connection_inactive`. A request to a path that is not the MCP path logs `mcp_inbound` with `status` 404, `route` `other`, `http_method`, `path_shape` and `auth_header_present`. `path_shape` keeps only the names of public routes (`mcp`, `.well-known`, `oauth-protected-resource`, and similar) and replaces every other segment, including the secret path and any token in a wrong URL, with its length. A client with no `mcp_received` line at all never reached the MCP path.
14
+
15
+ Outcome fields include tool, HTTP status, JSON-RPC error code, tool `isError`, duration, response bytes, completion (`finished` or `closed`), request phase, and fixed authentication/JWKS reasons, timing and fetch status. `pending` auth/JWKS outcomes with null timing mean the connection closed while verification was still running. `http_status: null` means no headers were sent; it must not be treated as HTTP 200. `response_bytes` is the serialized JSON body size prepared by the bridge, excluding HTTP headers. A closed response may not have delivered all those bytes. `finished` means Node handed the response to its transport; it does not prove ChatGPT accepted it. A pre-auth or incomplete-body failure has no tool name. Authentication is logged separately from tool scope rejection, which remains an HTTP 200 MCP tool error with the authentication challenge in `_meta`.
16
+
17
+ For an intermittent failure, correlate progress timestamps with `mcp_outcome` and reverse-proxy access entries. Check authentication failures first, then closed responses and their phase, then JSON-RPC or tool errors and response sizes.
18
+
19
+ ## Liveness classes and alerts
20
+
21
+ The bridge reports observations and labels, not diagnoses. `dalan status --json` adds `claimed_outer_count`, `max_claimed_outer_assignments`, `oldest_claim_age_ms`, `oldest_claim_progress_age_ms`, `last_worker_call_at`, `last_list_pending_at`, `oldest_unclaimed_event_2xx_age_ms`, `queue_classes` and `stale_claims`. Queued work after its first event 2xx is labelled:
22
+
23
+ | Class | Meaning | Default threshold (limits.json key) |
24
+ | --- | --- | --- |
25
+ | `pause_suspected` | no worker tool call and silence at least the threshold; cause unconfirmed | 20 min (`pause_suspected_silence_ms`) |
26
+ | `at_capacity_healthy` | every active worker subscriber has no free lane after counting shared worker claims and its principal's historical subject claims for that worker, and the newest activity on at least one claim is within that claim’s stored lease; waiting is expected | 60 min by default (`claim_lease_ms` sets the maximum) |
27
+ | `stale_claims` | claim past its persisted lease deadline, the deadline the sweep uses (`lease_expires_at`); `get` does not extend it | per grant (60 min by default) |
28
+ | `alive_not_claiming` | the worker called tools recently, slots free, item still queued after 2x the interval | interval 10 min (`assignment_reannounce_interval_ms`) |
29
+ | `transport_failing` | no event for the item ever got a 2xx; separate path, no re-announce | 20 min (`pause_suspected_silence_ms`) |
30
+
31
+ The bridge's automatic claim abandonment requires lease expiry (actor `system`, reason `lease_expired`, checked by the independent maintenance timer, same path as `dalan abandon`): the item is requeued and its lane is free. A usage break does not hold the sweep and does not move `lease_expires_at`: a claim with no claimant activity for one lease period is released during a break too. After a bridge start, a claim whose last activity came before the start is not swept before the start plus that claim's own lease (`lease_ms`, one hour by default), the full lease a restart would have given it, so a deadline that ran out while the bridge was down or draining does not requeue work the worker may still be running; a claim the worker touched since the start has no grace. After that window, the first maintenance tick sweeps it. Native protocol fixed-deadline leases renew only through explicit `renew_claim`. Claim-bearing calls still require an unexpired grant under the applicable lease model; acquire a new epoch when permitted. Preparation expiry and default-worker only skip expiry still run during a break and while delivery is paused (see **Preparation expiry** and **Skip expiry** in [Operations](operations.md#usage-breaks-and-usage-estimates)). Merged or closed PRs are cancelled by the PR-head reviewer (`cancelled_reason` `pr_closed`); see docs/pr-head-reviewer.md. An expired lease permits takeover only after verified host stop and delivery/admission gates; abandonment never shortens the old deadline. `dalan claims` lists active claims and `dalan abandon ID` requeues one (operator key); see the operations section [Claims and leases](operations.md#claims-and-leases). Attention alert names include `pause_suspected`, `stale_claims` and `transport_failing` (the old `queued_no_claim` is gone). Text names the class and ages, for example `pause_suspected: no worker tool call for 47 min while 3 assignments are queued (2 of 6 slots claimed). Pause cause unconfirmed.` These attention alerts require 30 continuous observed minutes before publication, with a recovery notice only after an attention alert was sent. `denial_mentioned` remains log-only, quoting at most 80 redacted characters, and has no recovery. See the current delay and publication rules in [Operations](operations.md#lifecycle-events-and-metrics). Queue re-wake sends at most one event per subscription every `queue_rewake_ms` (90 s) while the subscription's principal has a free lane and an item is eligible (inside `queue_rewake_window_ms` (2 h) always; past it at most once per `queue_rewake_stale_ms`, default 20 min); it is suppressed with no free lane, during pause, with no active subscription, for items with an uncertain owner delivery, and after a terminal HTTP 410/413. Items past the window raise `unclaimed_queued`. [Operations](operations.md) has the full rule.
32
+
33
+ ## Change and rollback
34
+
35
+ Back up configuration and state before changing issuer mappings or service settings. Record the original values and restore only the changed mappings if a test fails; restoring an entire identity-provider database would also erase unrelated later changes. Test a full worker login, job completion and token refresh after any authentication change. Follow [operations](operations.md#upgrade-and-rollback) for bridge rollback, preserving existing unit names and data roots.
36
+
37
+ Self-check metadata discovery inserts `/.well-known/oauth-protected-resource` before the resource path: `https://h/api` uses `https://h/.well-known/oauth-protected-resource/api`; a root resource uses `https://h/.well-known/oauth-protected-resource`. The metadata `resource` must equal the configured `DALAN_SELFCHECK_RESOURCE` exactly, as RFC 9728 section 3.3 requires; an origin-only value does not match a path resource, and a root resource must be spelled as the server publishes it (with or without the trailing slash). Metadata and JWKS probes reject redirects without following them and identify the failing setting without disclosing the redirect URL.