doer-agent 0.2.3 → 0.2.4

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 +38 -1
  2. package/package.json +1 -1
package/dist/agent.js CHANGED
@@ -556,6 +556,17 @@ async function startManagedRun(args) {
556
556
  activeRuns.delete(task.id);
557
557
  logStream.end();
558
558
  void prepared.codexAuthCleanup().catch(() => undefined);
559
+ if ((task.status === "completed" || task.status === "failed") && task.chatId) {
560
+ void notifyServerRunFinished({
561
+ serverBaseUrl: args.serverBaseUrl,
562
+ userId: args.userId,
563
+ agentToken: args.agentToken,
564
+ task,
565
+ }).catch((error) => {
566
+ const message = error instanceof Error ? error.message : String(error);
567
+ writeAgentInfraError(`run completion notify failed runId=${task.id}: ${message}`);
568
+ });
569
+ }
559
570
  writeRunStatus(task.id, `completed status=${task.status} exitCode=${task.resultExitCode ?? "null"} signal=${task.resultSignal ?? "null"}`);
560
571
  });
561
572
  activeRuns.set(task.id, { task, child, logPath, logStream, requestCancel });
@@ -563,6 +574,23 @@ async function startManagedRun(args) {
563
574
  writeRunStatus(task.id, `started requestId=${args.requestId} cwd=${prepared.taskWorkspace}`);
564
575
  return cloneRunTask(task);
565
576
  }
577
+ async function notifyServerRunFinished(args) {
578
+ if (!args.task.chatId || (args.task.status !== "completed" && args.task.status !== "failed")) {
579
+ return;
580
+ }
581
+ await postJson(`${args.serverBaseUrl}/api/agent/run-finished`, {
582
+ userId: args.userId,
583
+ agentToken: args.agentToken,
584
+ chatId: args.task.chatId,
585
+ runId: args.task.id,
586
+ command: args.task.command,
587
+ status: args.task.status,
588
+ exitCode: args.task.resultExitCode,
589
+ signal: args.task.resultSignal,
590
+ finishedAt: args.task.finishedAt,
591
+ error: args.task.error,
592
+ });
593
+ }
566
594
  async function handleRunRpcMessage(args) {
567
595
  let requestId = "unknown";
568
596
  let responseSubject = "";
@@ -575,6 +603,7 @@ async function handleRunRpcMessage(args) {
575
603
  const task = await startManagedRun({
576
604
  requestId,
577
605
  runId: request.runId ?? requestId,
606
+ serverBaseUrl: args.serverBaseUrl,
578
607
  userId: args.userId,
579
608
  agentId: args.agentId,
580
609
  command: request.command ?? "",
@@ -631,7 +660,14 @@ function subscribeToRunRpc(args) {
631
660
  writeAgentError(`run rpc subscription error: ${message}`);
632
661
  return;
633
662
  }
634
- void handleRunRpcMessage({ msg, jetstream: args.jetstream, userId: args.userId, agentId: args.agentId, agentToken: args.agentToken });
663
+ void handleRunRpcMessage({
664
+ msg,
665
+ jetstream: args.jetstream,
666
+ serverBaseUrl: args.serverBaseUrl,
667
+ userId: args.userId,
668
+ agentId: args.agentId,
669
+ agentToken: args.agentToken,
670
+ });
635
671
  },
636
672
  });
637
673
  writeAgentInfo(`run rpc subscribed subject=${subject}`);
@@ -1766,6 +1802,7 @@ async function main() {
1766
1802
  });
1767
1803
  subscribeToRunRpc({
1768
1804
  jetstream,
1805
+ serverBaseUrl,
1769
1806
  userId,
1770
1807
  agentId: initialAgentId,
1771
1808
  agentToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doer-agent",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Reverse-polling agent runtime for doer",
5
5
  "type": "module",
6
6
  "main": "dist/agent.js",