@sema-agent/server 1.186.0 → 1.188.0

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 (49) hide show
  1. package/dist/capabilities/sandbox-file-send.d.ts +19 -0
  2. package/dist/capabilities/sandbox-file-send.d.ts.map +1 -0
  3. package/dist/capabilities/sandbox-file-send.js +99 -0
  4. package/dist/capabilities/sandbox-file-send.js.map +1 -0
  5. package/dist/capabilities/send-user-file-tool.d.ts +32 -0
  6. package/dist/capabilities/send-user-file-tool.d.ts.map +1 -0
  7. package/dist/capabilities/send-user-file-tool.js +91 -0
  8. package/dist/capabilities/send-user-file-tool.js.map +1 -0
  9. package/dist/config.d.ts +6 -1
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +3 -1
  12. package/dist/config.js.map +1 -1
  13. package/dist/http/server.d.ts +2 -0
  14. package/dist/http/server.d.ts.map +1 -1
  15. package/dist/http/server.js +17 -3
  16. package/dist/http/server.js.map +1 -1
  17. package/dist/key-resolver.d.ts +2 -1
  18. package/dist/key-resolver.d.ts.map +1 -1
  19. package/dist/key-resolver.js +3 -0
  20. package/dist/key-resolver.js.map +1 -1
  21. package/dist/main.js +66 -3
  22. package/dist/main.js.map +1 -1
  23. package/dist/memory-sync-client.d.ts +3 -0
  24. package/dist/memory-sync-client.d.ts.map +1 -1
  25. package/dist/memory-sync-client.js +35 -9
  26. package/dist/memory-sync-client.js.map +1 -1
  27. package/dist/plugins/s3-presign.d.ts +1 -1
  28. package/dist/plugins/s3-presign.d.ts.map +1 -1
  29. package/dist/plugins/send-user-file.d.ts +8 -0
  30. package/dist/plugins/send-user-file.d.ts.map +1 -1
  31. package/dist/plugins/send-user-file.js +72 -1
  32. package/dist/plugins/send-user-file.js.map +1 -1
  33. package/dist/runs.d.ts +2 -1
  34. package/dist/runs.d.ts.map +1 -1
  35. package/dist/runs.js +5 -2
  36. package/dist/runs.js.map +1 -1
  37. package/dist/sealed-key.d.ts +16 -0
  38. package/dist/sealed-key.d.ts.map +1 -1
  39. package/dist/sealed-key.js +20 -0
  40. package/dist/sealed-key.js.map +1 -1
  41. package/dist/sema-registry.d.ts +1 -1
  42. package/dist/sema-registry.d.ts.map +1 -1
  43. package/dist/sema-registry.js +10 -5
  44. package/dist/sema-registry.js.map +1 -1
  45. package/dist/sighup-idle.d.ts +12 -0
  46. package/dist/sighup-idle.d.ts.map +1 -0
  47. package/dist/sighup-idle.js +53 -0
  48. package/dist/sighup-idle.js.map +1 -0
  49. package/package.json +2 -2
@@ -181,6 +181,14 @@ export function createHttpServer(deps) {
181
181
  let uncountedBillableInflight = 0;
182
182
  if (deps.drainState)
183
183
  deps.drainState.inflight = () => new Set([...inflightRuns.keys(), ...steerableRuns.keys()]).size + uncountedBillableInflight + (deps.leaderEndpoint?.inflight?.() ?? 0);
184
+ let lastBillableActivityAt = Date.now();
185
+ const noteActivity = (url) => {
186
+ if (url === "/health" || url.startsWith("/metrics"))
187
+ return;
188
+ lastBillableActivityAt = Date.now();
189
+ };
190
+ if (deps.drainState)
191
+ deps.drainState.lastActivityAt = () => lastBillableActivityAt;
184
192
  if (deps.hookWakeBus) {
185
193
  deps.hookWakeBus.deliver = async (sessionId, text) => {
186
194
  try {
@@ -249,6 +257,7 @@ export function createHttpServer(deps) {
249
257
  const startedAt = Date.now();
250
258
  const method = req.method ?? "GET";
251
259
  const url = (req.url ?? "/").split("?")[0];
260
+ noteActivity(url);
252
261
  let logged = false;
253
262
  const record = (viaClose) => {
254
263
  if (logged)
@@ -674,6 +683,7 @@ export function createHttpServer(deps) {
674
683
  }, 15_000);
675
684
  let ranLive = false;
676
685
  let resp;
686
+ uncountedBillableInflight++;
677
687
  try {
678
688
  resp = await idemCache.run(idemKey, async () => {
679
689
  ranLive = true;
@@ -850,9 +860,12 @@ export function createHttpServer(deps) {
850
860
  const withElicit = deps.elicitation
851
861
  ? () => deps.elicitation.runWithContext({ taskId: askTaskId, owner: askOwner, emit: emitAsk, abortSignal: ac.signal }, streamBody)
852
862
  : streamBody;
853
- await (deps.question
863
+ const withQuestion = () => deps.question
854
864
  ? deps.question.runWithContext({ taskId: askTaskId, owner: askOwner, emit: emitAsk, abortSignal: ac.signal }, withElicit)
855
- : withElicit());
865
+ : withElicit();
866
+ await (deps.sendUserFile
867
+ ? deps.sendUserFile.runWithContext({ taskId: askTaskId, emit: async (f) => void (await emitAsk(f)) }, withQuestion)
868
+ : withQuestion());
856
869
  if (durableTaskId && deps.runStore) {
857
870
  if (finalResult?.status === "suspended" && deps.checkpointStore)
858
871
  await deps.runStore.setSuspended(durableTaskId);
@@ -893,6 +906,7 @@ export function createHttpServer(deps) {
893
906
  throw e;
894
907
  }
895
908
  finally {
909
+ uncountedBillableInflight--;
896
910
  clearInterval(hb);
897
911
  }
898
912
  if (!ranLive && resp && !res.writableEnded) {
@@ -1033,7 +1047,7 @@ export function createHttpServer(deps) {
1033
1047
  rootTaskId: taskId,
1034
1048
  ...fleetRunLabels(prepared.spec.objective),
1035
1049
  });
1036
- void runInBackground(deps.runner, { ...prepared.spec, sessionId }, runStore, taskId, deps.metrics, prepared.auth?.principal, prepared.verify?.maxRounds, prepared.cascade ? cascadeConfig(deps.config.cascadeLadder, prepared.spec.maxCostUsd) : undefined, deps.instrumentDegenerate, deps.planCacheProbe, deps.config.traceThinking, inflightRuns, preemptableRuns, steerableRuns, deps.modelUsage, deps.elicitation, gatedPrincipal(req, deps.config) ?? null, captureTurnAnchor, fleetPub, captureUserMessageAnchor, deps.question, deps.workflowCompletionInbox, deps.subagentSteerRegistry, (m, x) => deps.logger?.info?.(m, x));
1050
+ void runInBackground(deps.runner, { ...prepared.spec, sessionId }, runStore, taskId, deps.metrics, prepared.auth?.principal, prepared.verify?.maxRounds, prepared.cascade ? cascadeConfig(deps.config.cascadeLadder, prepared.spec.maxCostUsd) : undefined, deps.instrumentDegenerate, deps.planCacheProbe, deps.config.traceThinking, inflightRuns, preemptableRuns, steerableRuns, deps.modelUsage, deps.elicitation, gatedPrincipal(req, deps.config) ?? null, captureTurnAnchor, fleetPub, captureUserMessageAnchor, deps.question, deps.workflowCompletionInbox, deps.subagentSteerRegistry, (m, x) => deps.logger?.info?.(m, x), deps.sendUserFile);
1037
1051
  return { status: 202, body: { taskId, sessionId, status: "running" } };
1038
1052
  }, (r) => r.status === 202);
1039
1053
  sendJson(res, resp.status, resp.body);