Further updates to Agent

This commit is contained in:
Raven Scott
2026-04-21 21:56:24 -04:00
parent 7f6e6507e1
commit 52fec92c2c
10 changed files with 261 additions and 6 deletions
+85
View File
@@ -558,6 +558,91 @@ function bareEditCreateStdinReader(stdin) {
}
}
/** Minimal AbortController for Bare/Pear when globalThis lacks it (drive-resident /bin preamble). */
function bareAgentEnsureAbortPolyfill() {
const g =
typeof globalThis !== 'undefined'
? globalThis
: typeof global !== 'undefined'
? global
: typeof self !== 'undefined'
? self
: /** @type {Record<string, unknown>} */ ({})
if (typeof g.AbortController === 'function') return
function BareAbortSignal() {
/** @type {boolean} */
this.aborted = false
/** @type {unknown} */
this.reason = undefined
/** @type {{ fn: () => void, once: boolean }[]} */
this._listeners = []
}
BareAbortSignal.prototype.addEventListener = function (type, fn, opts) {
if (type !== 'abort' || typeof fn !== 'function') return
const once = !!(opts && opts.once)
if (this.aborted) {
if (once) {
try {
fn.call(this)
} catch {
/* ignore */
}
}
return
}
this._listeners.push({ fn: /** @type {() => void} */ (fn), once })
}
BareAbortSignal.prototype.removeEventListener = function (type, fn) {
if (type !== 'abort' || typeof fn !== 'function') return
this._listeners = this._listeners.filter((x) => x.fn !== fn)
}
BareAbortSignal.prototype.throwIfAborted = function () {
if (!this.aborted) return
const DOMException = g.DOMException
if (typeof DOMException === 'function') {
throw new DOMException('Aborted', 'AbortError')
}
const e = new Error('Aborted')
e.name = 'AbortError'
throw e
}
function BareAbortController() {
this.signal = new BareAbortSignal()
}
BareAbortController.prototype.abort = function (reason) {
const s = this.signal
if (s.aborted) return
s.aborted = true
s.reason = reason
const list = s._listeners.slice()
s._listeners.length = 0
for (const x of list) {
try {
x.fn.call(s)
} catch {
/* ignore */
}
}
}
if (typeof globalThis !== 'undefined') {
globalThis.AbortController = BareAbortController
globalThis.AbortSignal = BareAbortSignal
} else {
g.AbortController = BareAbortController
g.AbortSignal = BareAbortSignal
}
}
bareAgentEnsureAbortPolyfill()
/** ~/.agent paths, config, history trim, man digest (preamble for /bin/agent). */
/**
+1 -1
View File
@@ -1,7 +1,7 @@
{
"schema": 2,
"profileId": "bare-os-posix-like",
"generatedAt": "2026-04-22T01:50:08.329Z",
"generatedAt": "2026-04-22T01:56:10.729Z",
"note": "Sparse POSIX Issue 7 coverage hints for /bin utilities. Omitted command names are not yet profiled here.",
"commandIndex": [
{
+1 -1
View File
@@ -1,6 +1,6 @@
{
"schema": 1,
"atMs": 1776822608328,
"atMs": 1776822970728,
"commands": [
"agent",
"arch",
File diff suppressed because one or more lines are too long