doer-agent 0.2.0 → 0.2.1

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 (2) hide show
  1. package/dist/agent.js +46 -2
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -764,7 +764,33 @@ function normalizeShellRpcRequest(args) {
764
764
  const cwd = typeof args.request.cwd === "string" && args.request.cwd.trim() ? args.request.cwd.trim() : null;
765
765
  const timeoutRaw = Number(args.request.timeoutMs);
766
766
  const timeoutMs = Number.isFinite(timeoutRaw) ? Math.max(1000, Math.min(Math.floor(timeoutRaw), 300000)) : 30000;
767
- return { requestId, command, cwd, timeoutMs, responseSubject };
767
+ return {
768
+ requestId,
769
+ command,
770
+ cwd,
771
+ timeoutMs,
772
+ responseSubject,
773
+ runtimeEnvPatch: normalizeEnvPatch(args.request.runtimeEnvPatch),
774
+ codexAuthBundle: normalizeShellRpcCodexAuthBundle(args.request.codexAuth),
775
+ };
776
+ }
777
+ function normalizeShellRpcCodexAuthBundle(value) {
778
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
779
+ return null;
780
+ }
781
+ const row = value;
782
+ const authJson = typeof row.authJson === "string" ? row.authJson : null;
783
+ if (!authJson) {
784
+ return null;
785
+ }
786
+ return {
787
+ taskId: typeof row.taskId === "string" ? row.taskId : undefined,
788
+ authMode: row.authMode === "oauth" ? "oauth" : row.authMode === "api_key" ? "api_key" : undefined,
789
+ issuedAt: typeof row.issuedAt === "string" ? row.issuedAt : undefined,
790
+ expiresAt: typeof row.expiresAt === "string" ? row.expiresAt : undefined,
791
+ authJson,
792
+ apiKey: typeof row.apiKey === "string" || row.apiKey === null ? row.apiKey : undefined,
793
+ };
768
794
  }
769
795
  function publishShellRpcResponse(args) {
770
796
  args.nc.publish(args.responseSubject, shellRpcCodec.encode(JSON.stringify(args.payload)));
@@ -781,6 +807,16 @@ async function handleShellRpcMessage(args) {
781
807
  responseSubject = request.responseSubject;
782
808
  const shellPath = resolveShellPath();
783
809
  const taskWorkspace = resolveTaskWorkspace(request.cwd);
810
+ const codexAuth = await prepareCodexAuthBundle(request.codexAuthBundle);
811
+ const baseTaskEnvPatch = {
812
+ ...request.runtimeEnvPatch,
813
+ ...(codexAuth?.envPatch ?? {}),
814
+ WORKSPACE: taskWorkspace,
815
+ };
816
+ const taskGitEnv = await prepareTaskGitEnv({
817
+ cwd: taskWorkspace,
818
+ baseEnvPatch: baseTaskEnvPatch,
819
+ });
784
820
  const runtimeBinPath = path.join(AGENT_PROJECT_DIR, "runtime/bin");
785
821
  const taskPath = [runtimeBinPath, process.env.PATH || ""].filter(Boolean).join(path.delimiter);
786
822
  const child = spawn(request.command, {
@@ -789,8 +825,10 @@ async function handleShellRpcMessage(args) {
789
825
  detached: process.platform !== "win32",
790
826
  env: {
791
827
  ...process.env,
792
- WORKSPACE: taskWorkspace,
828
+ ...baseTaskEnvPatch,
829
+ ...taskGitEnv.envPatch,
793
830
  PATH: taskPath,
831
+ DOER_AGENT_TOKEN: args.agentToken,
794
832
  },
795
833
  stdio: ["ignore", "pipe", "pipe"],
796
834
  });
@@ -866,6 +904,7 @@ function subscribeToShellRpc(args) {
866
904
  msg,
867
905
  jetstream: args.jetstream,
868
906
  agentId: args.agentId,
907
+ agentToken: args.agentToken,
869
908
  });
870
909
  },
871
910
  });
@@ -1042,6 +1081,9 @@ async function prepareTaskCodexAuth(args) {
1042
1081
  writeAgentError(`task=${args.taskId} codex auth sync skipped: ${message}`);
1043
1082
  return null;
1044
1083
  });
1084
+ return await prepareCodexAuthBundle(bundle);
1085
+ }
1086
+ async function prepareCodexAuthBundle(bundle) {
1045
1087
  if (!bundle || typeof bundle.authJson !== "string") {
1046
1088
  return null;
1047
1089
  }
@@ -1390,6 +1432,7 @@ async function main() {
1390
1432
  jetstream,
1391
1433
  userId,
1392
1434
  agentId: initialAgentId,
1435
+ agentToken,
1393
1436
  });
1394
1437
  for (const pendingTaskId of pendingTaskIds) {
1395
1438
  await waitForAvailableSlot();
@@ -1535,6 +1578,7 @@ async function main() {
1535
1578
  jetstream,
1536
1579
  userId,
1537
1580
  agentId: refreshedAgentId,
1581
+ agentToken,
1538
1582
  });
1539
1583
  for (const pendingTaskId of pendingTaskIds) {
1540
1584
  await waitForAvailableSlot();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doer-agent",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Reverse-polling agent runtime for doer",
5
5
  "type": "module",
6
6
  "main": "dist/agent.js",