freddie 0.0.110 → 0.0.112
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freddie",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.112",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Open JS agent harness built on pi-mono, floosie, xstate, and anentrypoint-design",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mariozechner/pi-ai": "^0.70.6",
|
|
27
27
|
"@mariozechner/pi-coding-agent": "^0.70.6",
|
|
28
28
|
"@mariozechner/pi-tui": "^0.70.6",
|
|
29
|
-
"acptoapi": "^1.0.
|
|
29
|
+
"acptoapi": "^1.0.107",
|
|
30
30
|
"anentrypoint-design": "^0.0.132",
|
|
31
31
|
"commander": "^14.0.0",
|
|
32
32
|
"express": "^5.0.0",
|
|
@@ -32,11 +32,23 @@ export async function callLLM({ messages, tools = [], model } = {}) {
|
|
|
32
32
|
const headers = { 'content-type': 'application/json', authorization: 'Bearer none' }
|
|
33
33
|
const cwd = process.cwd()
|
|
34
34
|
if (Array.isArray(tools) && tools.length) headers['x-cwd'] = cwd
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
35
|
+
// Fast-fail timeout + skip loopback when page is on a remote origin
|
|
36
|
+
// (gh-pages → http://localhost:4800 hangs forever under Chrome private-network rules).
|
|
37
|
+
const _u = (() => { try { return new URL(base, (typeof location !== 'undefined' && location.href) || 'http://_/') } catch { return null } })()
|
|
38
|
+
const _isLb = _u && /^(localhost|127\.0\.0\.1|0\.0\.0\.0|::1)$/i.test(_u.hostname)
|
|
39
|
+
const _pageLb = (() => { try { const h = ((typeof location !== 'undefined' && location.hostname) || '').toLowerCase(); return h === 'localhost' || h === '127.0.0.1' || h === '' || h === '::1' } catch { return true } })()
|
|
40
|
+
if (_isLb && !_pageLb) throw new Error(`acptoapi unreachable: page on ${typeof location !== 'undefined' ? location.hostname : '?'} cannot reach loopback ${base}`)
|
|
41
|
+
const _ac = new AbortController()
|
|
42
|
+
const _tid = setTimeout(() => _ac.abort(new Error('acptoapi fetch timeout')), 8000)
|
|
43
|
+
let res
|
|
44
|
+
try {
|
|
45
|
+
res = await fetch(base.replace(/\/$/, '') + '/chat/completions', {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers,
|
|
48
|
+
body: JSON.stringify(body),
|
|
49
|
+
signal: _ac.signal,
|
|
50
|
+
})
|
|
51
|
+
} finally { clearTimeout(_tid) }
|
|
40
52
|
if (!res.ok) {
|
|
41
53
|
const text = await res.text()
|
|
42
54
|
throw new Error(`acptoapi ${res.status}: ${text.slice(0, 400)}`)
|
package/src/observability/log.js
CHANGED
|
@@ -9,8 +9,14 @@ let _streams = new Map()
|
|
|
9
9
|
function streamFor(name) {
|
|
10
10
|
if (_streams.has(name)) return _streams.get(name)
|
|
11
11
|
const dir = path.join(getFreddieHome(), 'logs')
|
|
12
|
-
fs.mkdirSync(dir, { recursive: true })
|
|
13
|
-
|
|
12
|
+
try { fs.mkdirSync(dir, { recursive: true }) } catch {}
|
|
13
|
+
let s
|
|
14
|
+
if (typeof fs.createWriteStream === 'function') {
|
|
15
|
+
s = fs.createWriteStream(path.join(dir, `${name}.log`), { flags: 'a' })
|
|
16
|
+
} else {
|
|
17
|
+
// Browser fs shim without createWriteStream — fall back to console.
|
|
18
|
+
s = { write(line) { try { console.log('[' + name + ']', line.trim()) } catch {} }, end() {} }
|
|
19
|
+
}
|
|
14
20
|
_streams.set(name, s)
|
|
15
21
|
return s
|
|
16
22
|
}
|