@supporterino/ai-factory 0.3.0 → 0.3.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.
- package/CHANGELOG.md +6 -0
- package/dist/cli.js +29 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes per release. `ai-factory update` applies them to an installed workspace (see [docs/cli.md](docs/cli.md#update)).
|
|
4
4
|
|
|
5
|
+
## 0.3.1
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- 4ba83db: Keep polling opencode's `/wait` in 60 s slices so an agent turn longer than 5 minutes no longer fails with "opencode server unreachable" (Node's `fetch` headers timeout), and report client-side timeouts as such instead.
|
|
10
|
+
|
|
5
11
|
## 0.3.0
|
|
6
12
|
|
|
7
13
|
### Minor Changes
|
package/dist/cli.js
CHANGED
|
@@ -14743,7 +14743,7 @@ class TransientError extends Error {
|
|
|
14743
14743
|
}
|
|
14744
14744
|
|
|
14745
14745
|
// src/version.ts
|
|
14746
|
-
var FACTORY_VERSION = "0.3.
|
|
14746
|
+
var FACTORY_VERSION = "0.3.1";
|
|
14747
14747
|
var PACKAGE_NAME = "@supporterino/ai-factory";
|
|
14748
14748
|
var runVersion = (version) => `npx ${PACKAGE_NAME}@${version}`;
|
|
14749
14749
|
|
|
@@ -31707,6 +31707,19 @@ var minus = (a, b) => ({
|
|
|
31707
31707
|
cacheWrite: a.cacheWrite - b.cacheWrite,
|
|
31708
31708
|
cost: a.cost - b.cost
|
|
31709
31709
|
});
|
|
31710
|
+
var WAIT_POLL_MS = 60000;
|
|
31711
|
+
function isTimeout(err) {
|
|
31712
|
+
const seen = new Set;
|
|
31713
|
+
let current = err;
|
|
31714
|
+
while (current !== null && typeof current === "object" && !seen.has(current)) {
|
|
31715
|
+
seen.add(current);
|
|
31716
|
+
const { name, cause } = current;
|
|
31717
|
+
if (name === "TimeoutError" || name === "HeadersTimeoutError" || name === "BodyTimeoutError")
|
|
31718
|
+
return true;
|
|
31719
|
+
current = cause;
|
|
31720
|
+
}
|
|
31721
|
+
return false;
|
|
31722
|
+
}
|
|
31710
31723
|
|
|
31711
31724
|
class OpencodeRuntime {
|
|
31712
31725
|
#opts;
|
|
@@ -31733,7 +31746,10 @@ class OpencodeRuntime {
|
|
|
31733
31746
|
} catch (err) {
|
|
31734
31747
|
if (signal?.aborted)
|
|
31735
31748
|
throw err;
|
|
31736
|
-
|
|
31749
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
31750
|
+
if (isTimeout(err))
|
|
31751
|
+
throw new TransientError(`opencode client timed out during ${method} ${path}${this.#alive() ? "" : " (the server exited)"}: ${detail}`);
|
|
31752
|
+
throw new TransientError(`opencode server unreachable${this.#alive() ? "" : " (it exited)"}: ${detail}`);
|
|
31737
31753
|
}
|
|
31738
31754
|
const text = await res.text();
|
|
31739
31755
|
let json = text;
|
|
@@ -31887,8 +31903,15 @@ class OpencodeRuntime {
|
|
|
31887
31903
|
return cut === -1 ? messages : messages.slice(0, cut);
|
|
31888
31904
|
}
|
|
31889
31905
|
async#awaitTurn(id, marker, stop) {
|
|
31906
|
+
const pollMs = this.#opts.waitPollMs ?? WAIT_POLL_MS;
|
|
31890
31907
|
for (;; ) {
|
|
31891
|
-
|
|
31908
|
+
const poll = AbortSignal.any([stop, AbortSignal.timeout(pollMs)]);
|
|
31909
|
+
try {
|
|
31910
|
+
await this.#api("POST", `/api/experimental/session/${id}/wait`, undefined, poll);
|
|
31911
|
+
} catch (err) {
|
|
31912
|
+
if (stop.aborted || !poll.aborted)
|
|
31913
|
+
throw err;
|
|
31914
|
+
}
|
|
31892
31915
|
const all = await this.#recent(id);
|
|
31893
31916
|
const fresh = this.#since(all, marker);
|
|
31894
31917
|
const markerSeen = marker === undefined || all.some((m) => m.id === marker);
|
|
@@ -31916,7 +31939,9 @@ class OpencodeRuntime {
|
|
|
31916
31939
|
throw err;
|
|
31917
31940
|
interrupted = true;
|
|
31918
31941
|
await this.#api("POST", `/api/session/${id}/interrupt`);
|
|
31919
|
-
|
|
31942
|
+
try {
|
|
31943
|
+
await this.#api("POST", `/api/experimental/session/${id}/wait`, undefined, AbortSignal.timeout(this.#opts.waitPollMs ?? WAIT_POLL_MS));
|
|
31944
|
+
} catch {}
|
|
31920
31945
|
messages = this.#since(await this.#recent(id), marker);
|
|
31921
31946
|
}
|
|
31922
31947
|
const after = await this.#session(id);
|