@agentqueue/worker 0.0.0 → 0.3.1-ci.g02c90ca5cd192c5a75a7d1d19329683cefb22d6e

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 (109) hide show
  1. package/README.md +159 -0
  2. package/THIRD_PARTY_NOTICES.md +27 -0
  3. package/dist/bin/aq-askpass.d.ts +2 -0
  4. package/dist/bin/aq-askpass.js +5 -0
  5. package/dist/bin/aq-askpass.js.map +1 -0
  6. package/dist/bin/aq.d.ts +2 -0
  7. package/dist/bin/aq.js +9 -0
  8. package/dist/bin/aq.js.map +1 -0
  9. package/dist/release.json +16 -0
  10. package/dist/src/app-server/checkpoint-codec.d.ts +4 -0
  11. package/dist/src/app-server/checkpoint-codec.js +31 -0
  12. package/dist/src/app-server/checkpoint-codec.js.map +1 -0
  13. package/dist/src/app-server/codex-token-snapshot.d.ts +11 -0
  14. package/dist/src/app-server/codex-token-snapshot.js +45 -0
  15. package/dist/src/app-server/codex-token-snapshot.js.map +1 -0
  16. package/dist/src/app-server/index.d.ts +70 -0
  17. package/dist/src/app-server/index.js +319 -0
  18. package/dist/src/app-server/index.js.map +1 -0
  19. package/dist/src/app-server/native-checkpoint.d.ts +12 -0
  20. package/dist/src/app-server/native-checkpoint.js +179 -0
  21. package/dist/src/app-server/native-checkpoint.js.map +1 -0
  22. package/dist/src/app-server/process-group.d.ts +6 -0
  23. package/dist/src/app-server/process-group.js +122 -0
  24. package/dist/src/app-server/process-group.js.map +1 -0
  25. package/dist/src/app-server/transports.d.ts +68 -0
  26. package/dist/src/app-server/transports.js +228 -0
  27. package/dist/src/app-server/transports.js.map +1 -0
  28. package/dist/src/app-server/worker-checkpoint.d.ts +15 -0
  29. package/dist/src/app-server/worker-checkpoint.js +76 -0
  30. package/dist/src/app-server/worker-checkpoint.js.map +1 -0
  31. package/dist/src/broker.d.ts +4 -0
  32. package/dist/src/broker.js +104 -0
  33. package/dist/src/broker.js.map +1 -0
  34. package/dist/src/cli.d.ts +14 -0
  35. package/dist/src/cli.js +212 -0
  36. package/dist/src/cli.js.map +1 -0
  37. package/dist/src/client.d.ts +19 -0
  38. package/dist/src/client.js +116 -0
  39. package/dist/src/client.js.map +1 -0
  40. package/dist/src/codex-owner-auth.d.ts +14 -0
  41. package/dist/src/codex-owner-auth.js +155 -0
  42. package/dist/src/codex-owner-auth.js.map +1 -0
  43. package/dist/src/codex-runtime.d.ts +32 -0
  44. package/dist/src/codex-runtime.js +383 -0
  45. package/dist/src/codex-runtime.js.map +1 -0
  46. package/dist/src/completion-outbox.d.ts +38 -0
  47. package/dist/src/completion-outbox.js +90 -0
  48. package/dist/src/completion-outbox.js.map +1 -0
  49. package/dist/src/config.d.ts +16 -0
  50. package/dist/src/config.js +57 -0
  51. package/dist/src/config.js.map +1 -0
  52. package/dist/src/diagnostics.d.ts +3 -0
  53. package/dist/src/diagnostics.js +40 -0
  54. package/dist/src/diagnostics.js.map +1 -0
  55. package/dist/src/isolation.d.ts +34 -0
  56. package/dist/src/isolation.js +690 -0
  57. package/dist/src/isolation.js.map +1 -0
  58. package/dist/src/planning-dev/analysis-runtime.d.ts +6 -0
  59. package/dist/src/planning-dev/analysis-runtime.js +65 -0
  60. package/dist/src/planning-dev/analysis-runtime.js.map +1 -0
  61. package/dist/src/planning-dev/index.d.ts +35 -0
  62. package/dist/src/planning-dev/index.js +244 -0
  63. package/dist/src/planning-dev/index.js.map +1 -0
  64. package/dist/src/planning-dev/native-binary.d.ts +1 -0
  65. package/dist/src/planning-dev/native-binary.js +67 -0
  66. package/dist/src/planning-dev/native-binary.js.map +1 -0
  67. package/dist/src/planning-dev/protocol.d.ts +30 -0
  68. package/dist/src/planning-dev/protocol.js +43 -0
  69. package/dist/src/planning-dev/protocol.js.map +1 -0
  70. package/dist/src/planning-dev/runtime.d.ts +11 -0
  71. package/dist/src/planning-dev/runtime.js +437 -0
  72. package/dist/src/planning-dev/runtime.js.map +1 -0
  73. package/dist/src/process-lock.d.ts +4 -0
  74. package/dist/src/process-lock.js +44 -0
  75. package/dist/src/process-lock.js.map +1 -0
  76. package/dist/src/provider-status.d.ts +21 -0
  77. package/dist/src/provider-status.js +73 -0
  78. package/dist/src/provider-status.js.map +1 -0
  79. package/dist/src/readiness.d.ts +15 -0
  80. package/dist/src/readiness.js +145 -0
  81. package/dist/src/readiness.js.map +1 -0
  82. package/dist/src/register.d.ts +5 -0
  83. package/dist/src/register.js +178 -0
  84. package/dist/src/register.js.map +1 -0
  85. package/dist/src/runtime.d.ts +100 -0
  86. package/dist/src/runtime.js +2288 -0
  87. package/dist/src/runtime.js.map +1 -0
  88. package/dist/src/service.d.ts +11 -0
  89. package/dist/src/service.js +119 -0
  90. package/dist/src/service.js.map +1 -0
  91. package/dist/src/supervisor.d.ts +9 -0
  92. package/dist/src/supervisor.js +157 -0
  93. package/dist/src/supervisor.js.map +1 -0
  94. package/dist/src/turn-checkpoint.d.ts +58 -0
  95. package/dist/src/turn-checkpoint.js +314 -0
  96. package/dist/src/turn-checkpoint.js.map +1 -0
  97. package/dist/src/types.d.ts +168 -0
  98. package/dist/src/types.js +2 -0
  99. package/dist/src/types.js.map +1 -0
  100. package/dist/src/usage-limit.d.ts +13 -0
  101. package/dist/src/usage-limit.js +75 -0
  102. package/dist/src/usage-limit.js.map +1 -0
  103. package/dist/src/version.d.ts +6 -0
  104. package/dist/src/version.js +49 -0
  105. package/dist/src/version.js.map +1 -0
  106. package/dist/src/worker-types.d.ts +12 -0
  107. package/dist/src/worker-types.js +2 -0
  108. package/dist/src/worker-types.js.map +1 -0
  109. package/package.json +56 -4
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Agent Queue self-hosted worker
2
+
3
+ Agent Queue operates the shared control plane. This package runs the customer-hosted
4
+ execution component and connects outward to that service over HTTPS. Customers do not
5
+ run core, Postgres, the portal, or the deployment CLI.
6
+
7
+ ## Prerequisites
8
+
9
+ - Node.js 24.22.1+ and a package manager with global installation support.
10
+ - Linux with a systemd user manager that supports filesystem sandboxing, or macOS
11
+ with `sandbox-exec`. Registration refuses machines without supported process isolation.
12
+ - At least one installed and authenticated runtime: Pi, OpenCode, Codex, or Claude Code 2.1.303 or newer.
13
+ - The Agent Queue service URL and your immutable Clerk Organization ID (`org_...`).
14
+
15
+ Set `WORKER_VERSION` to the qualified version recorded in its successful release run, then install it from npm:
16
+
17
+ ```sh
18
+ pnpm add --global "@agentqueue/worker@${WORKER_VERSION:?}"
19
+ ```
20
+
21
+ Authenticate a runtime using the instructions below, then use `aq auth` to inspect
22
+ local runtime authentication. Once the
23
+ machine is ready, register it with the service URL and tenant supplied by your team:
24
+
25
+ ```sh
26
+ aq register --server https://agentqueue.example.com --tenant org_YOUR_CLERK_ORGANIZATION_ID
27
+ ```
28
+
29
+ The URL and Organization ID above are placeholders. Use the service origin with
30
+ `--tenant`, which appends `/t/<organization-id>` and saves that tenant-bound address.
31
+ Do not use an organization slug or omit the tenant for the shared service; omission
32
+ is supported only for legacy single-tenant development. Registration opens an enrollment
33
+ page where you sign in to that organization and confirm the printed fingerprint.
34
+ Review requested permissions there; edit them after registration if needed.
35
+
36
+ A worker registration belongs to one tenant. Run data and results are sent to the
37
+ hosted service, and model requests go to the chosen model provider. Worker-local model
38
+ authentication is not a promise that task data stays only on your machine.
39
+
40
+ ## Capacity and authentication
41
+
42
+ For projects and workflows, “All accessible” includes every project in the organization
43
+ when the worker owner is an organization admin. Other owners must be project members,
44
+ either directly or through a linked Slack channel. New projects become eligible
45
+ automatically. “Selected” still restricts the worker to the chosen projects or workflows,
46
+ and “None” disables that category. Removing the owner's admin role restores membership
47
+ checks, including for active Runs. People starting chats still need project access.
48
+
49
+ Workers accept one assignment at a time by default. Set a higher isolated-run limit during registration with `--concurrency 4`, or change an existing worker with `aq capacity 4`. Valid capacity is 1–16; Agent Queue stores the limit and applies changes to the running service automatically.
50
+
51
+ Registration uses Agent Queue browser sign-in and fingerprint confirmation. Model credentials stay on the machine. `aq auth` reports local runtime authentication. After registration, `aq doctor` reports
52
+ the saved service and worker identity, available runtimes, and process isolation.
53
+
54
+ Codex uses the official, unmodified `@openai/codex@0.166.0` App Server. Install that qualified version before authenticating:
55
+
56
+ ```sh
57
+ pnpm add --global @openai/codex@0.166.0
58
+ ```
59
+
60
+ Subscription authentication uses the file-backed owner credential store. A trusted process outside the conversation refreshes it through the official account API and supplies short-lived external access tokens. Refresh tokens stay in the owner home:
61
+
62
+ ```sh
63
+ aq auth codex
64
+ ```
65
+
66
+ On a remote or headless machine, use Codex device authentication:
67
+
68
+ ```sh
69
+ aq auth codex --device-auth
70
+ ```
71
+
72
+ Claude subscription authentication must use an inference-only automation token because isolated Runs cannot access the macOS Keychain:
73
+
74
+ ```sh
75
+ aq auth claude --setup-token
76
+ ```
77
+
78
+ Codex and Claude advertise only their native model families. Authenticate Pi and OpenCode with their native login/configuration flows, then configure exact model eligibility during registration or with `AQ_WORKER_PI_MODELS` and `AQ_WORKER_OPENCODE_MODELS` as comma-separated lists. The selected model process receives only its worker-local model authentication and workflow-scoped Agent Queue broker access. Linear OAuth tokens, GitHub App or installation tokens, Agent Queue user tokens, and credentials for other model providers are never sent to it; temporary launch environment files are mode `0600` and removed during cleanup.
79
+
80
+ ## Managing the service
81
+
82
+ Use `aq status`, `aq start`, `aq stop`, `aq capacity`, `aq auth`, and `aq unregister` to manage the user-level worker service. The Workers page can drain a machine without revoking it: active assignments keep their leases and finish, while new claims stop until an operator resumes the worker. `aq auth codex` runs Codex's file-backed login, while `aq auth claude --setup-token` runs Claude's long-lived subscription-token flow and securely stores only the resulting token. Both commands verify that the isolated worker can use the credential. `aq upgrade --version <qualified-version>` installs the selected private release and detects npm, pnpm, Yarn Classic, and Bun global installations; pass `--package-manager npm|pnpm|yarn|bun` to override detection.
83
+
84
+ ## App Server protocol library
85
+
86
+ `@agentqueue/worker/app-server` exports the shared official Codex JSON-RPC client. Core imports this same implementation. The assignment runner uses this same client for Codex, including persistent native threads, supported steering, bounded event delivery and lifecycle cleanup. It has no Codex `exec` fallback. Other installed harnesses keep their adapters.
87
+
88
+ ```ts
89
+ import { CodexAppServer, connectCodexAppServer } from "@agentqueue/worker/app-server";
90
+
91
+ const local = new CodexAppServer({
92
+ binaryPath: "/opt/codex/bin/codex",
93
+ expectedVersion: "0.166.0",
94
+ cwd: "/data/workspace",
95
+ env: { PATH: "/usr/local/bin:/usr/bin:/bin", HOME: "/data/home", CODEX_HOME: "/data/codex" },
96
+ onNotification: async (method, params) => receiveEvent(method, params),
97
+ onRequest: async (method, params) => authorizeAndHandleRequest(method, params),
98
+ });
99
+ await local.initialize();
100
+
101
+ const hosted = await connectCodexAppServer({
102
+ url: trustedAppServerUrl,
103
+ headers: { Authorization: `Bearer ${transportCapability}` },
104
+ redactValues: [transportCapability],
105
+ onNotification: async (method, params) => receiveEvent(method, params),
106
+ onRequest: async (method, params) => authorizeAndHandleRequest(method, params),
107
+ });
108
+ await hosted.initialize();
109
+ ```
110
+
111
+ Both clients expose `request`, `notify`, `initialize`, `error`, `addRedactions` and idempotent `close`. Native image/tool/usage/child-thread payloads pass through without rewriting. Requests for the same native thread serialize; other threads and response settlement remain independent of an approval wait. An omitted server-request handler returns an explicit unsupported-method error. Consumers remain responsible for tool, approval, identity and live Run authority; this module supplies no such authorization.
112
+
113
+ Defaults are 16 MiB per JSON frame, separate 32 MiB budgets for queued outbound frames and retained inbound notifications/server requests, 1,024 pending requests and a 120-second client-request timeout. Callers may configure bounded limits and request-specific timeouts or abort signals; a zero request timeout explicitly disables that timer. Frames must be valid UTF-8 JSON-RPC. Oversize, malformed, disconnected, timed-out or aborted transports fail explicitly and never retry a native mutation. A failed request can have an unknown remote outcome; lifecycle/effect reconciliation remains outside the protocol client. Register renewed secrets through `addRedactions` before use. Diagnostics redact configured secrets, known provider environment credentials and transport headers; no wire payloads are logged.
114
+
115
+ The stdio client owns and closes its POSIX process group, including descendants that stay in that group. Escaped sessions, external jobs and hosted actor cancellation require the separately qualified lifecycle owner. Closing a hosted connection closes only that connection. It does not establish that guest commands stopped. WSS is required remotely; plain WS is allowed only for loopback connections, URL credentials are rejected and redirects are disabled. The official [App Server protocol](https://learn.chatgpt.com/docs/app-server) documents WebSocket transport as experimental and unsupported for production; this preparatory package does not waive the runtime support/activation gates. Local `expectedVersion` checks the official CLI version before spawning; a hosted supervisor must independently verify its qualified image/binary identity.
116
+
117
+ ## Releases and service compatibility
118
+
119
+ The following release steps are for package and service maintainers.
120
+
121
+ Each published package carries `dist/release.json` with its source commit and worker protocol, assignment, and checkpoint format versions. Release automation retains the exact tested tarball, a content-addressed file manifest, and a CycloneDX SBOM. Core operators can set `SELF_HOSTED_WORKER_MIN_VERSION`, `SELF_HOSTED_WORKER_RECOMMENDED_VERSION`, and comma-separated `SELF_HOSTED_WORKER_DENIED_VERSIONS`; incompatible workers are refused before they claim a Run, while workers below the recommended release receive an upgrade notice.
122
+
123
+ Worker protocol 3 adds qualified native Codex capabilities to the server-owned capacity envelope; assignment and checkpoint format 2 describe the acknowledged state contract.
124
+
125
+ After each push to main passes the applicable CI checks, release automation retains the exact tarball in private S3, qualifies it on Linux and publishes those bytes to npm from a GitHub-hosted runner through npm trusted publishing. npm generates no provenance attestation because the source repository is private. Each source commit receives a distinct next-patch prerelease version, such as `0.2.1-ci.g<SHA>` for source `0.2.0`. Install that exact qualified version. Linux native execution, cold restore and complete process cessation gate publication. An existing package version must have identical SHA-512 integrity for a retry to succeed.
126
+
127
+ macOS remains experimental and unqualified and does not gate release. The main-only worker workflow also supports manual recovery but does not move the backend deployment channel or remotely upgrade machines. S3 evidence expires after 90 days; npm versions are permanent. See the [CI storage runbook](../deploy/ci/README.md) and [backend release procedure](../deploy/q11-backend-release.md).
128
+
129
+ ## Native continuity and compatibility
130
+
131
+ Worker 0.2.0 advertises protocol 3, assignment format 2 and checkpoint format 2. Core must deploy the matching compatibility policy as part of the coordinated cutover; legacy workers are rejected for every harness, including Pi, OpenCode and Claude Code. Drain active assignments and deliver queued completions against the original compatible core before upgrading. Deploy the matching core and worker as one coordinated cutover. Upgrade the worker and qualified Codex package together. This source change does not deploy or publish either package.
132
+
133
+ Each conversation gets a tenant-bound workspace and native Codex home. Successful completion commits a quiesced native thread graph and its filesystem overlay together. A fresh process restores the acknowledged checkpoint and resumes the same native thread; it does not replay prior requests as new user messages. Current Run instructions and skills replace prior configuration, while broker authorization and approvals use current Run authority. Failed or cancelled native attempts never silently retry or publish their dirty state. Unacknowledged work and external effects require reconciliation; native continuity does not preserve live Python or shell memory.
134
+
135
+ Unmodified Codex currently retains absolute paths in native state. Eligible replacement workers must use the same platform and absolute `AQ_WORKSPACES` root, and the same or a newer Codex release than the one that wrote the state; a worker never resumes state a newer Codex wrote. Workers advertise their Codex version and workspace root; core routes a retained thread only to a worker advertising that root and a version at least the checkpoint's, before issuing assignment credentials. A newer worker records its own version in the native binding before Codex opens the state, so an upgraded conversation is never handed back to an older worker. Core sends an older checkpoint only to workers that also advertise `codexResumesOlderV1`, so workers from before this rule keep exact matching. A turn no matching worker takes within a day fails and keeps the checkpoint. Only plain `x.y.z` releases compare; any other version string must match exactly. Changing the platform or workspace root, or moving to an older Codex, requires a separately qualified migration; the worker does not rewrite upstream state.
136
+
137
+ Checkpoints use bounded gzip transport: at most 16 MiB encoded and 128 MiB of expanded JSON, including base64 file data. Files keep their original bytes. Historical JSON overlays remain readable. Native credentials, logs and temporary download caches are excluded. Source overlays omit repository metadata and build caches such as `node_modules`; workflow setup rebuilds excluded dependencies after restore. Use artifact publication for large user-facing output. Exceeding a bound fails visibly and preserves the prior acknowledged head. Completion delivery never drops native state to turn a failed upload into success.
138
+
139
+ Linux execution uses dedicated systemd units with control-group termination, a trusted parent-loss watchdog, a guarded start and durable process journals. Restart reconciles owned units and private launch files before accepting work. Keep runtime installations separate from worker registration data and workspaces. The worker exposes the resolved Node installation in the isolated PATH; non-login shell calls retain that PATH.
140
+
141
+ macOS uses its existing `sandbox-exec` boundary and POSIX process groups. Linux native continuity and complete process cessation must pass before publication. macOS native continuity is unqualified and does not block this release; the existing installed qualification script can be run manually on an owner-operated Mac. Complete containment of deliberately escaped descendants is not established by that boundary; macOS owner-operated workers are not a substitute for the hosted isolation boundary or eligible for pooled hostile workloads. Production activation remains a separately reviewed step.
142
+
143
+ Pending completion files are bound to the original tenant URL and worker registration. Re-registering elsewhere cannot send the old tenant's result or checkpoint to the new service. Operator-owned offline copies and backups require operator cleanup; a control-plane deletion does not prove remote erasure of an offline personal computer.
144
+
145
+ Before upgrading a worker with queued completions, drain its outbox against the original compatible control plane. A valid version 1 completion blocks startup and remains byte-for-byte at its original path. It must not be quarantined, deleted, or assigned the current registration's server by inference. Recovery requires verifying the original server, worker, Run, attempt and lease before an explicit version 2 migration. Reverting only the worker binary cannot drain it against a protocol-3-only core; retain the original file for verified recovery if the old control plane is unavailable.
146
+
147
+ Native continuity is bound to the core-issued actor, audience, roster and participant-tenure authorization context. A changed or missing context starts from the currently authorized transcript in a fresh workspace and native home; it does not replay old filesystem data or native history. The prior checkpoint generation still fences completion. Previously committed checkpoints and separately saved product artifacts retain their normal control-plane retention policy.
148
+
149
+ ## Planning development package
150
+
151
+ Ontra pins `@agentqueue/worker/planning-dev` and calls `startPlanningDevelopment` from its dev launcher. The package includes the qualified official Codex binary. Run `pnpm planning:login` once if a Codex subscription login is missing, then `pnpm planning:dev` in Ontra's TypeScript workspace. Set `PLANNING_QM_DEV_TENANT` to an Ontra-owned organization enabled in the hosted service's `QM_DEVELOPMENT_WORKER_TENANTS` allowlist.
152
+
153
+ The first launch asks for browser approval of a development-only worker. Later launches reuse a private registration per checkout. The foreground worker stops with the app; it does not install a background service. Routine Ontra development needs no QM checkout, local QM server, or QM database. Linux and a working systemd user manager are currently required.
154
+
155
+ Hosted QM assigns an integration namespace to each approved development worker. Its permanent purpose forbids customer/project/chat claims, while the subscription profile forbids paid-worker fallback. The ordinary hosted run owner retains tools, approvals, effects and checkpoint commits. Only isolated native execution and authenticated callbacks to the paired loopback app run locally. Subscription refresh credentials and local signing/HMAC secrets stay outside the agent filesystem.
156
+
157
+ The outbound signed HTTPS mailbox is durable across API and execution replicas. Session epochs, live run fences, bounded requests and local authority expiry reject stale execution. Worker-package changes can use Ontra's explicit `QM_WORKER_PATH` override; normal installs use the reviewed package artifact and integrity pin.
158
+
159
+ Maintain the older `scripts/planning-dev.ts` launcher for QM development itself. Qualify the hosted-control-plane adapter with `DATABASE_URL=<disposable loopback Postgres> node scripts/smoke-hosted-planning-development.ts`; this uses real subscription inference and synthetic headless enrollment, restarts the separate executor between turns, and verifies native checkpoint continuity. `PLANNING_DEV_WORKER_ENTRY` may select Ontra's installed package entry for qualification. No paid runtime is configured by this smoke.
@@ -0,0 +1,27 @@
1
+ # Third-party notices
2
+
3
+ Agent Queue includes material derived from [YC’s qm project](https://github.com/yc-software/qm).
4
+ The following notice applies to that upstream material; it does not grant a
5
+ project-wide license for Agent Queue or its original changes.
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2026 QM contributors
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ process.stderr.write("Git credentials are available only through the worker supervisor proxy.\n");
3
+ process.exit(1);
4
+ export {};
5
+ //# sourceMappingURL=aq-askpass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aq-askpass.js","sourceRoot":"","sources":["../../bin/aq-askpass.ts"],"names":[],"mappings":";AACA,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;AAClG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin/aq.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../src/cli.js";
3
+ main(process.argv.slice(2)).then((code) => {
4
+ process.exitCode = code;
5
+ }, (error) => {
6
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
7
+ process.exitCode = 1;
8
+ });
9
+ //# sourceMappingURL=aq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aq.js","sourceRoot":"","sources":["../../bin/aq.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9B,CAAC,IAAI,EAAE,EAAE;IACP,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "package": {
4
+ "name": "@agentqueue/worker",
5
+ "version": "0.3.1-ci.g02c90ca5cd192c5a75a7d1d19329683cefb22d6e"
6
+ },
7
+ "source": {
8
+ "repository": "git+https://github.com/mobility-solutions-inc/qm.git",
9
+ "commit": "02c90ca5cd192c5a75a7d1d19329683cefb22d6e"
10
+ },
11
+ "compatibility": {
12
+ "workerProtocol": 3,
13
+ "assignment": 2,
14
+ "checkpoint": 2
15
+ }
16
+ }
@@ -0,0 +1,4 @@
1
+ export declare const MAX_CHECKPOINT_BYTES: number;
2
+ export declare const MAX_CHECKPOINT_CONTENT_BYTES: number;
3
+ export declare function encodeCheckpoint(entries: unknown[]): Promise<string>;
4
+ export declare function decodeCheckpoint(archive: string): unknown[];
@@ -0,0 +1,31 @@
1
+ import { promisify } from "node:util";
2
+ import { gzip, gunzipSync } from "node:zlib";
3
+ export const MAX_CHECKPOINT_BYTES = 16 * 1024 * 1024;
4
+ export const MAX_CHECKPOINT_CONTENT_BYTES = 128 * 1024 * 1024;
5
+ const PREFIX = "aq-checkpoint-gzip-v1:";
6
+ export async function encodeCheckpoint(entries) {
7
+ const json = JSON.stringify(entries);
8
+ if (Buffer.byteLength(json) > MAX_CHECKPOINT_CONTENT_BYTES)
9
+ throw new Error("workspace checkpoint is too large");
10
+ const archive = `${PREFIX}${(await promisify(gzip)(json)).toString("base64")}`;
11
+ if (Buffer.byteLength(archive) > MAX_CHECKPOINT_BYTES)
12
+ throw new Error("workspace checkpoint is too large");
13
+ return archive;
14
+ }
15
+ export function decodeCheckpoint(archive) {
16
+ if (Buffer.byteLength(archive) > MAX_CHECKPOINT_BYTES)
17
+ throw new Error("workspace checkpoint is too large");
18
+ let json = archive;
19
+ if (archive.startsWith(PREFIX)) {
20
+ const data = archive.slice(PREFIX.length);
21
+ const bytes = Buffer.from(data, "base64");
22
+ if (bytes.toString("base64") !== data)
23
+ throw new Error("workspace checkpoint encoding is invalid");
24
+ json = gunzipSync(bytes, { maxOutputLength: MAX_CHECKPOINT_CONTENT_BYTES }).toString("utf8");
25
+ }
26
+ const entries = JSON.parse(json);
27
+ if (!Array.isArray(entries))
28
+ throw new Error("workspace checkpoint is invalid");
29
+ return entries;
30
+ }
31
+ //# sourceMappingURL=checkpoint-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-codec.js","sourceRoot":"","sources":["../../../src/app-server/checkpoint-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9D,MAAM,MAAM,GAAG,wBAAwB,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAkB;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,4BAA4B;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACjH,MAAM,OAAO,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC/E,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,oBAAoB;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAC5G,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,oBAAoB;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAC5G,IAAI,IAAI,GAAG,OAAO,CAAC;IACnB,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QACnG,IAAI,GAAG,UAAU,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,4BAA4B,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,OAAO,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAChF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface CodexTokenSnapshot {
2
+ accessToken: string;
3
+ accountId: string;
4
+ planType: string | null;
5
+ credentialRevision: number;
6
+ expiresAt: number | null;
7
+ }
8
+ export declare function codexTokenSnapshot<T extends {
9
+ authJson: string;
10
+ secretRevision: number;
11
+ }>(credential: T): CodexTokenSnapshot;
@@ -0,0 +1,45 @@
1
+ function objectValue(value) {
2
+ return value && typeof value === "object" ? value : null;
3
+ }
4
+ function jwtClaims(token) {
5
+ const payload = token.split(".")[1];
6
+ if (!payload)
7
+ return null;
8
+ try {
9
+ return objectValue(JSON.parse(Buffer.from(payload, "base64url").toString("utf8")));
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ }
15
+ export function codexTokenSnapshot(credential) {
16
+ let auth;
17
+ try {
18
+ auth = objectValue(JSON.parse(credential.authJson)) ?? {};
19
+ }
20
+ catch {
21
+ throw new Error("stored Codex authentication is invalid");
22
+ }
23
+ const tokens = objectValue(auth.tokens);
24
+ const accessToken = typeof tokens?.access_token === "string" ? tokens.access_token : "";
25
+ if (!accessToken)
26
+ throw new Error("stored Codex authentication has no access token");
27
+ const claims = jwtClaims(accessToken);
28
+ const openai = objectValue(claims?.["https://api.openai.com/auth"]);
29
+ const accountIds = [tokens?.account_id, openai?.chatgpt_account_id, claims?.chatgpt_account_id].filter((value) => typeof value === "string" && Boolean(value));
30
+ if (!accountIds.length)
31
+ throw new Error("stored Codex authentication has no account id");
32
+ if (new Set(accountIds).size !== 1)
33
+ throw new Error("stored Codex authentication has inconsistent account ids");
34
+ const accountId = accountIds[0];
35
+ const planType = [openai?.chatgpt_plan_type, claims?.chatgpt_plan_type].find((value) => typeof value === "string" && Boolean(value));
36
+ const exp = typeof claims?.exp === "number" && Number.isFinite(claims.exp) ? claims.exp : null;
37
+ return {
38
+ accessToken,
39
+ accountId,
40
+ planType: planType ?? null,
41
+ credentialRevision: credential.secretRevision,
42
+ expiresAt: exp === null ? null : exp * 1_000,
43
+ };
44
+ }
45
+ //# sourceMappingURL=codex-token-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-token-snapshot.js","sourceRoot":"","sources":["../../../src/app-server/codex-token-snapshot.ts"],"names":[],"mappings":"AAQA,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,IAAI,CAAC;AACxF,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,UAAa;IAEb,IAAI,IAA6B,CAAC;IAClC,IAAI,CAAC;QACH,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,OAAO,MAAM,EAAE,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACxF,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC,MAAM,CACpG,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CACxE,CAAC;IACF,IAAI,CAAC,UAAU,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACzF,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAChH,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAC1E,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CACxE,CAAC;IACF,MAAM,GAAG,GAAG,OAAO,MAAM,EAAE,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/F,OAAO;QACL,WAAW;QACX,SAAS;QACT,QAAQ,EAAE,QAAQ,IAAI,IAAI;QAC1B,kBAAkB,EAAE,UAAU,CAAC,cAAc;QAC7C,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK;KAC7C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ import { type AppServerTransport, type StdioOptions, type WebSocketOptions } from "./transports.ts";
3
+ export declare function codexServiceTier(fastMode: boolean): {
4
+ serviceTier: "priority" | "default";
5
+ };
6
+ export declare class CodexRpcError extends Error {
7
+ readonly code: number | undefined;
8
+ constructor(message: string, code?: number);
9
+ }
10
+ export declare class CodexTransportError extends Error {
11
+ readonly kind: "protocol" | "transport" | "timeout" | "limit" | "closed";
12
+ constructor(kind: CodexTransportError["kind"], message: string);
13
+ }
14
+ export interface CodexClientOptions {
15
+ onNotification?(method: string, params: unknown): void | Promise<void>;
16
+ onRequest?(method: string, params: unknown): Promise<unknown>;
17
+ redactValues?: readonly string[];
18
+ maxFrameBytes?: number;
19
+ maxPendingRequests?: number;
20
+ maxQueuedBytes?: number;
21
+ requestTimeoutMs?: number;
22
+ }
23
+ export interface CodexAppServerOptions extends CodexClientOptions, StdioOptions {
24
+ }
25
+ export interface HostedCodexAppServerOptions extends CodexClientOptions, WebSocketOptions {
26
+ }
27
+ export interface CodexRequestOptions {
28
+ timeoutMs?: number;
29
+ signal?: AbortSignal;
30
+ }
31
+ export declare class CodexAppServerClient {
32
+ private readonly pending;
33
+ private readonly serverRequests;
34
+ private readonly threadTails;
35
+ private readonly secrets;
36
+ private readonly maxFrameBytes;
37
+ private readonly maxPending;
38
+ private readonly maxQueuedBytes;
39
+ private readonly timeoutMs;
40
+ private nextId;
41
+ private queuedBytes;
42
+ private inboundBytes;
43
+ private callbacks;
44
+ private writeTail;
45
+ private eventTail;
46
+ private closed;
47
+ private closeError;
48
+ private closing;
49
+ private readonly transport;
50
+ private readonly options;
51
+ constructor(transport: AppServerTransport, options?: CodexClientOptions);
52
+ addRedactions(values: readonly string[]): void;
53
+ error(): Error | null;
54
+ drainNotifications(): Promise<void>;
55
+ initialize(): Promise<void>;
56
+ request<T = unknown>(method: string, params?: unknown, options?: CodexRequestOptions): Promise<T>;
57
+ notify(method: string, params?: unknown): Promise<void>;
58
+ close(): Promise<void>;
59
+ private receiveFrame;
60
+ private queueRequest;
61
+ private send;
62
+ private redact;
63
+ private rejectPending;
64
+ private fail;
65
+ }
66
+ export declare class CodexAppServer extends CodexAppServerClient {
67
+ readonly process: ChildProcess;
68
+ constructor(options: CodexAppServerOptions);
69
+ }
70
+ export declare function connectCodexAppServer(options: HostedCodexAppServerOptions): Promise<CodexAppServerClient>;