@parcha/agentrun-client 0.1.0-beta.32 → 0.1.0-beta.33

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.
package/dist/client.js CHANGED
@@ -135,6 +135,10 @@ export class AgentRun {
135
135
  throw LATE;
136
136
  const timeout = AbortSignal.timeout(wholeMs(Math.min(x.timeoutMs ?? this.timeoutMs, left)));
137
137
  const signal = x.signal ? AbortSignal.any([x.signal, timeout]) : timeout;
138
+ // This try's timer is the wait's deadline when the deadline is what bounds it. A timer can fire a little before the
139
+ // clock reads the deadline, so the deadline is reached when that timer fired, or when the clock says so.
140
+ const bounded = left <= (x.timeoutMs ?? this.timeoutMs);
141
+ const late = () => (bounded && timeout.aborted) || Date.now() >= deadline;
138
142
  let response;
139
143
  try {
140
144
  response = await this.#follow(x, signal);
@@ -147,7 +151,7 @@ export class AgentRun {
147
151
  throw x.signal.reason;
148
152
  if (error instanceof AgentRunError)
149
153
  throw error;
150
- if (Date.now() >= deadline)
154
+ if (late())
151
155
  throw LATE;
152
156
  const cause = causeOf(error);
153
157
  // A server never reached is unreachable at once; a dropped connection is tried again, even on the first request,
@@ -167,7 +171,7 @@ export class AgentRun {
167
171
  }
168
172
  if (response.ok)
169
173
  return response;
170
- throw await refusal(x, response, this.#apiKey);
174
+ throw await refusal(x, response, this.#apiKey, late);
171
175
  }
172
176
  };
173
177
  /** fetch with the key, following a redirect only for a GET and only within the base URL's origin: the key never goes
@@ -208,7 +212,7 @@ function secretAt(method, url) {
208
212
  * read into a message. A caller's abort while the body is still coming is thrown as the caller's own reason, and a read
209
213
  * that ends at or past the exchange's deadline (a wait's timeout) as LATE: cancelled or late work is never reported as a
210
214
  * refusal or a bad key. */
211
- async function refusal(x, response, apiKey) {
215
+ async function refusal(x, response, apiKey, late) {
212
216
  let error;
213
217
  try {
214
218
  const parsed = JSON.parse(new TextDecoder().decode(await response.arrayBuffer()));
@@ -218,7 +222,7 @@ async function refusal(x, response, apiKey) {
218
222
  catch {
219
223
  if (x.signal?.aborted)
220
224
  throw x.signal.reason;
221
- if (Date.now() >= (x.deadline ?? Infinity))
225
+ if (late())
222
226
  throw LATE;
223
227
  error = undefined;
224
228
  }
@@ -610,6 +610,7 @@ export type Capabilities = {
610
610
  reason?: string;
611
611
  network?: "allowlist" | "none";
612
612
  network_reason?: string;
613
+ host_addresses?: Array<string>;
613
614
  }>;
614
615
  default_place?: {
615
616
  mode: "runner";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-client",
3
- "version": "0.1.0-beta.32",
3
+ "version": "0.1.0-beta.33",
4
4
  "description": "A typed TypeScript client for a self-hosted AgentRun server: a method per operation of its API, typed from its OpenAPI document, with waiting for a run and following its timeline. No dependencies; fetch only.",
5
5
  "keywords": [
6
6
  "agentrun",