fuli-context 0.25.1 → 0.25.2
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/web/assets/{CopyFixPrompt-DlarhfPK.js → CopyFixPrompt-CVFYWDSt.js} +1 -1
- package/dist/web/assets/{OverviewPage-BkJ17OYv.js → OverviewPage-_9e2idJR.js} +1 -1
- package/dist/web/assets/{SettingsPage-CWGk0XZ_.js → SettingsPage-bLssMIz6.js} +1 -1
- package/dist/web/assets/{index-RWEx1M91.js → index-C2VDC1uO.js} +3 -3
- package/dist/web/assets/{version-Ci3l8Vnb.js → version-lXtOG8uf.js} +1 -1
- package/dist/web/index.html +3 -3
- package/docs/agent-roundtable.md +8 -2
- package/docs/client-connections.md +4 -0
- package/graph-provider/pyproject.toml +1 -1
- package/native/win32/fuli-win-helper.exe +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/roundtable/src/roundtable/delivery-state.js +1 -1
- package/packages/roundtable/src/roundtable/service.js +15 -4
- package/packages/roundtable/src/roundtable/store.js +26 -17
- package/packages/roundtable/src/roundtable/wake-claim-release.js +88 -0
- package/packages/roundtable/src/roundtable/wake.js +3 -1
- package/src/agent-tools/project-agent-tool-definitions.js +1 -1
- package/src/agents/lifecycle-message.js +15 -4
- package/src/agents/token-usage-resolver.js +8 -0
- package/src/graphiti/local-runtimes.js +4 -1
- package/src/judgment/backend.js +8 -2
- package/src/presence/windows-helper-pin.js +1 -1
- package/src/whats-new/lines/0.25.2.json +13 -0
package/docs/agent-roundtable.md
CHANGED
|
@@ -224,8 +224,14 @@ honors both sender and recipient admission boundaries. Per-message delivery
|
|
|
224
224
|
receipts advance only a contiguous target cursor, so a newer member cannot erase
|
|
225
225
|
older unread history it was not allowed to see. Durable execution claims keep
|
|
226
226
|
one wake active per Agent; subsequent rooms wait for completion notifications.
|
|
227
|
-
A claim nothing ended within an hour
|
|
228
|
-
|
|
227
|
+
A claim its console lost (nothing ended it within an hour) is released only on
|
|
228
|
+
evidence: the process recorded when spawn() returned has ended or its PID now names
|
|
229
|
+
another process, and on POSIX no member of its process group is left (the woken
|
|
230
|
+
client leads its own group; Windows has none, so only that process is checked). A
|
|
231
|
+
running or unknown process, or a group that still answers, keeps the hold. A claim
|
|
232
|
+
with no recorded PID, a claim from before processes were recorded, and a reused PID
|
|
233
|
+
whose group still answers are released a day after they began. Its ask returns to
|
|
234
|
+
the inbox. Unconfirmed cleanup keeps its safety hold.
|
|
229
235
|
|
|
230
236
|
## Group discussions (#FLG, rec#55)
|
|
231
237
|
|
|
@@ -325,6 +325,10 @@ It does not start FULI:
|
|
|
325
325
|
- after 3 automatic starts within 10 minutes, until you start FULI yourself.
|
|
326
326
|
|
|
327
327
|
In those cases the hooks' "Fuli context is unavailable" text says which one applies.
|
|
328
|
+
When a hook itself fails, the same text names the error code, the rule that refused the call (never
|
|
329
|
+
the values it was given) and the FULI version the hook ran, for example
|
|
330
|
+
`the hook failed: validation (Task preference scope is immutable; …) in FULI 0.25.2`;
|
|
331
|
+
a refusal from the graph service shows only its HTTP status.
|
|
328
332
|
`FULI_CONSOLE_AUTOSTART=off` in a client's environment turns it off for that client's sessions.
|
|
329
333
|
|
|
330
334
|
## Remote clients
|
|
Binary file
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuli-context",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "fuli-context",
|
|
9
|
-
"version": "0.25.
|
|
9
|
+
"version": "0.25.2",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "1.5.0",
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ const INBOX = 'sees it in its inbox when its next task starts (task-entry agent_
|
|
|
12
12
|
const NOT_STARTED = {
|
|
13
13
|
execution_claimed: ({ name, blockedBy }) => `FULI started no session: an earlier message to ${name}`
|
|
14
14
|
+ (blockedBy?.messageId ? ` (${blockedBy.messageId}${blockedBy.since ? `, since ${blockedBy.since}` : ''})` : '')
|
|
15
|
-
+ ' still owns its one wake, and FULI never runs two at once.
|
|
15
|
+
+ ' still owns its one wake, and FULI never runs two at once. If that wake was lost (its console stopped), it is released once its process has ended, checked from an hour after it began.',
|
|
16
16
|
cleanup_unconfirmed: ({ name }) => `FULI started no session: ${name}'s previously woken process has not been confirmed to end.`,
|
|
17
17
|
chat_waiting: ({ name }) => `FULI started no session: ${name} is already waiting in this chat.`,
|
|
18
18
|
no_client: ({ name, clients }) => clients.length
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { waitForChatChange } from './chat-wait.js';
|
|
2
|
+
import { createWakeClaimRelease } from './wake-claim-release.js';
|
|
2
3
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
4
|
import { projectAddress, resolveProjectAddress, resolveProjectLead, verifiedProjectFolder } from './project-target.js';
|
|
4
5
|
import { observeReturnedMemory, taskContextHash } from './memory-observation.js';
|
|
@@ -29,6 +30,9 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
29
30
|
// Boot-anchor evidence recorded with a cleanup hold. Production records none
|
|
30
31
|
// (null) until a separately verified proof exists; release stays disabled.
|
|
31
32
|
bootEvidence = async () => null, now = Date.now,
|
|
33
|
+
// Which recorded wake processes still run (wake-claim-release.js); null = cannot tell.
|
|
34
|
+
inspectProcess = async () => null,
|
|
35
|
+
groupAlive = undefined,
|
|
32
36
|
// The installed desktop app of a client, or null. Runtimes pass
|
|
33
37
|
// createDesktopApps (agents/desktop-registry.js); without it every ask wakes headlessly.
|
|
34
38
|
desktopApp = () => null }) {
|
|
@@ -39,6 +43,7 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
39
43
|
const refreshes = new Map();
|
|
40
44
|
let refreshOffset = 0;
|
|
41
45
|
const store = new Proxy({}, { get: (_target, property) => (opened ??= openStore())[property] });
|
|
46
|
+
const wakeClaims = createWakeClaimRelease({ store, inspectProcess, groupAlive, now });
|
|
42
47
|
|
|
43
48
|
async function sender({ taskContextToken, sourceApplication }) {
|
|
44
49
|
if (!taskContextToken) return { agent: null, client: sourceApplication ?? 'other', session: null, projectId: null };
|
|
@@ -196,7 +201,8 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
196
201
|
try {
|
|
197
202
|
grant = await issueGrant(delivery, timeoutMs / 1000);
|
|
198
203
|
answer = await wake({ client: delivery.client, sessionId: delivery.sessionId, cwd: delivery.cwd,
|
|
199
|
-
timeoutMs, prompt, delegationToken: grant.token, peerDepth, signal,
|
|
204
|
+
timeoutMs, prompt, delegationToken: grant.token, peerDepth, signal, readOnly,
|
|
205
|
+
onSpawn: (pid) => { wakeClaims.recordSpawn(ask.id, pid); onSpawn?.(pid); },
|
|
200
206
|
onSession: session => host.sealDelegation({ token: grant.token, sessionId: session }) });
|
|
201
207
|
const verified = answer.sessionId && await host.verifyDelegation({ token: grant.token, sessionId: answer.sessionId });
|
|
202
208
|
if (!verified?.redeemed) throw Object.assign(new Error('The receiving session did not restore the Agent'),
|
|
@@ -294,6 +300,7 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
294
300
|
// with the reason, so the recipient still sees it when it next works.
|
|
295
301
|
async function wakeAsk({ thread, ask, target, targets, noTargets, prompt, timeoutMs, signal, issueGrant, replyTo,
|
|
296
302
|
chatWakeChatId = null, readOnly = false }) {
|
|
303
|
+
await wakeClaims.release(spaceId(), target.agentId);
|
|
297
304
|
const claim = store.claimExecution(spaceId(), target.agentId, ask.id, { chatWakeChatId });
|
|
298
305
|
if (!claim.claimed) {
|
|
299
306
|
// Recorded so the thread and get_agent_message_status say why no client has it.
|
|
@@ -451,6 +458,7 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
451
458
|
from: { agentId: `peer:${device.nodeId.slice(0, 16)}:${assertion.from.agentId}`, name: `${assertion.from.name} · ${device.name}`,
|
|
452
459
|
client: assertion.from.client ?? 'other' },
|
|
453
460
|
to: { agentId: target.agentId, name: label(target) } });
|
|
461
|
+
await wakeClaims.release(share.spaceId, target.agentId);
|
|
454
462
|
const execution = store.claimExecution(share.spaceId, target.agentId, ask.id);
|
|
455
463
|
if (!execution.claimed) {
|
|
456
464
|
store.updateMessage(ask.id, { status: 'failed', error: execution.reason });
|
|
@@ -538,8 +546,8 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
538
546
|
}
|
|
539
547
|
|
|
540
548
|
async function cancelAsk(ask) {
|
|
541
|
-
// A wake
|
|
542
|
-
if (ask.status === 'delivering' && !peer?.hasSent(ask.id) &&
|
|
549
|
+
// A wake its console lost, whose process has ended, no longer answers; its ask is back in the inbox.
|
|
550
|
+
if (ask.status === 'delivering' && !peer?.hasSent(ask.id) && await wakeClaims.release(spaceId(), ask.to_agent)) ask = store.getMessage(ask.id);
|
|
543
551
|
if (peer?.hasSent(ask.id)) {
|
|
544
552
|
if (!REMOTE_PENDING.has(ask.status)) return remoteView(ask);
|
|
545
553
|
return remoteView(applyRemote(ask.id, await peer.cancel(ask.id)));
|
|
@@ -668,7 +676,10 @@ export function createAgentRoundtable({ host, peer = null, openStore, wake = wak
|
|
|
668
676
|
};
|
|
669
677
|
// False when an earlier run of this Agent may still be running (a cleanup hold).
|
|
670
678
|
const waitUntilIdle = async (agentId, signal) => {
|
|
671
|
-
const state = await waitForChatChange(() =>
|
|
679
|
+
const state = await waitForChatChange(async () => {
|
|
680
|
+
await wakeClaims.release(spaceId(), agentId);
|
|
681
|
+
return store.executionState(spaceId(), agentId);
|
|
682
|
+
},
|
|
672
683
|
{ store: store.chat, signal, ready: state => state.held || !state.busy });
|
|
673
684
|
return !state.held;
|
|
674
685
|
};
|
|
@@ -50,22 +50,22 @@ export const ROUNDTABLE_FORMAT = sqliteFormat({
|
|
|
50
50
|
id: 'roundtable/6-reply-delivery', to: 6, kind: 'add-columns', table: 'messages',
|
|
51
51
|
summary: 'whether each reply reached the Agent that asked, and through which tool',
|
|
52
52
|
columns: { delivery_status: 'TEXT', delivered_via: 'TEXT', delivered_at: 'TEXT' }
|
|
53
|
+
}, {
|
|
54
|
+
// The process a claim started, so a claim its console lost is released only
|
|
55
|
+
// once that process is gone (wake-claim-release.js). Older claims carry none.
|
|
56
|
+
id: 'roundtable/7-wake-process', to: 7, kind: 'add-columns', table: 'messages',
|
|
57
|
+
summary: 'which process each roundtable wake started, so a lost wake is released only after it ended',
|
|
58
|
+
columns: { wake_process_evidence: 'TEXT', wake_pid: 'TEXT', wake_pid_identity: 'TEXT' }
|
|
53
59
|
}],
|
|
54
60
|
pragmas: 'PRAGMA journal_mode = WAL;'
|
|
55
61
|
});
|
|
56
62
|
|
|
57
|
-
// The longest wake waits 15 minutes for its answer. A claim still active an hour
|
|
58
|
-
// later has no wake behind it: the console restarted or crashed mid-wake. It
|
|
59
|
-
// stops blocking the Agent; a run whose exit is unconfirmed stays held.
|
|
60
|
-
export const WAKE_CLAIM_TTL_MS = 60 * 60 * 1000;
|
|
61
|
-
|
|
62
63
|
// Every Agent-to-Agent exchange is kept as a thread of messages so people can
|
|
63
64
|
// see who talked to whom, through which client, and what was said. The file
|
|
64
65
|
// is shared by the console and every client's MCP process.
|
|
65
66
|
export function createRoundtableStore(path = ':memory:', { clock = () => new Date() } = {}) {
|
|
66
67
|
const database = openFormattedDatabase(path, ROUNDTABLE_FORMAT);
|
|
67
68
|
const now = () => clock().toISOString();
|
|
68
|
-
const claimCutoff = () => new Date(clock().getTime() - WAKE_CLAIM_TTL_MS).toISOString();
|
|
69
69
|
const chat = createChatStore(database, path);
|
|
70
70
|
const attention = createAttentionInboxStore(database, chat);
|
|
71
71
|
const discussions = createGroupDiscussionStore(database, chat);
|
|
@@ -162,12 +162,11 @@ export function createRoundtableStore(path = ':memory:', { clock = () => new Dat
|
|
|
162
162
|
claimExecution(spaceId, agentId, askId, { chatWakeChatId = null } = {}) {
|
|
163
163
|
return transaction(() => {
|
|
164
164
|
if (chatWakeChatId && chat.waiting(spaceId, `local:${agentId}`, chatWakeChatId)) return { claimed: false, reason: 'chat_waiting' };
|
|
165
|
-
this.expireStaleClaims(spaceId, agentId);
|
|
166
165
|
const state = this.executionState(spaceId, agentId, askId);
|
|
167
166
|
if (state.held) return { claimed: false, reason: 'cleanup_unconfirmed' };
|
|
168
167
|
if (state.busy) return { claimed: false, reason: 'execution_claimed', blockedBy: state.claim };
|
|
169
|
-
const claimed = database.prepare(`UPDATE messages SET execution_claim = 'active', execution_claimed_at =
|
|
170
|
-
WHERE id = ? AND execution_claim IS NULL`).run(now(), askId).changes === 1;
|
|
168
|
+
const claimed = database.prepare(`UPDATE messages SET execution_claim = 'active', execution_claimed_at = ?,
|
|
169
|
+
wake_process_evidence = '1' WHERE id = ? AND execution_claim IS NULL`).run(now(), askId).changes === 1;
|
|
171
170
|
return claimed ? { claimed: true } : { claimed: false, reason: 'execution_claimed' };
|
|
172
171
|
});
|
|
173
172
|
},
|
|
@@ -178,21 +177,31 @@ export function createRoundtableStore(path = ':memory:', { clock = () => new Dat
|
|
|
178
177
|
(m.execution_claim='active' OR (m.cleanup_status='unconfirmed' AND m.cleanup_released_at IS NULL))
|
|
179
178
|
ORDER BY m.execution_claimed_at`)
|
|
180
179
|
.all(spaceId, agentId, exceptAskId);
|
|
181
|
-
const
|
|
182
|
-
const active = blocking.find(row => row.execution_claim === 'active' && row.execution_claimed_at >= cutoff);
|
|
180
|
+
const active = blocking.find(row => row.execution_claim === 'active');
|
|
183
181
|
// The earlier ask that holds the Agent, so a refused sender can name what it waits on.
|
|
184
182
|
return { busy: Boolean(active), claim: active ? { messageId: active.id, since: active.execution_claimed_at } : null,
|
|
185
183
|
held: blocking.some(row => row.cleanup_status === 'unconfirmed' && row.cleanup_released_at === null) };
|
|
186
184
|
},
|
|
187
|
-
//
|
|
188
|
-
|
|
185
|
+
// The process this claim started, recorded at spawn; its identity follows once read.
|
|
186
|
+
recordWakeProcess(askId, pid, identity = null) {
|
|
187
|
+
database.prepare(`UPDATE messages SET wake_pid = ?, wake_pid_identity = coalesce(?, wake_pid_identity)
|
|
188
|
+
WHERE id = ? AND execution_claim = 'active'`).run(String(pid), identity, askId);
|
|
189
|
+
},
|
|
190
|
+
// Active claims of this Agent made before the cutoff, with no cleanup hold.
|
|
191
|
+
claimsBefore(spaceId, agentId, cutoff) {
|
|
192
|
+
return database.prepare(`SELECT m.id, m.execution_claimed_at, m.wake_process_evidence, m.wake_pid, m.wake_pid_identity
|
|
193
|
+
FROM messages m JOIN threads t ON t.id = m.thread_id
|
|
194
|
+
WHERE t.space_id = ? AND m.to_agent = ? AND m.kind = 'ask' AND m.execution_claim = 'active'
|
|
195
|
+
AND m.execution_claimed_at < ? AND (m.cleanup_status IS NULL OR m.cleanup_status != 'unconfirmed')`)
|
|
196
|
+
.all(spaceId, agentId, cutoff);
|
|
197
|
+
},
|
|
198
|
+
// A released claim's ask goes back to the inbox, so it can be read or cancelled.
|
|
199
|
+
expireClaim(askId) {
|
|
189
200
|
const expired = database.prepare(`UPDATE messages SET execution_claim = 'expired',
|
|
190
201
|
status = CASE WHEN status = 'delivering' THEN 'queued' ELSE status END,
|
|
191
202
|
error = CASE WHEN status = 'delivering' THEN 'wake_expired' ELSE error END, updated_at = ?
|
|
192
|
-
WHERE
|
|
193
|
-
|
|
194
|
-
AND thread_id IN (SELECT id FROM threads WHERE space_id = ?)`)
|
|
195
|
-
.run(now(), agentId, claimCutoff(), spaceId).changes;
|
|
203
|
+
WHERE id = ? AND execution_claim = 'active' AND (cleanup_status IS NULL OR cleanup_status != 'unconfirmed')`)
|
|
204
|
+
.run(now(), askId).changes === 1;
|
|
196
205
|
if (expired) chat.publishChanges();
|
|
197
206
|
return expired;
|
|
198
207
|
},
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// A claim stays active until its wake ends (store.finishExecution). When the
|
|
2
|
+
// console restarts or crashes mid-wake nothing ends it, and the Agent could
|
|
3
|
+
// never be woken again (rec#97). A claim old enough that no live console still
|
|
4
|
+
// waits on it is released only on evidence that no process of it is running:
|
|
5
|
+
// the recorded process is gone, or its PID now belongs to another process, and
|
|
6
|
+
// on POSIX no member of its process group is left (the woken client leads its
|
|
7
|
+
// own group, wake.js; descendants outlive their leader). A process still
|
|
8
|
+
// running, a group that still answers, or an OS that cannot be asked keeps the
|
|
9
|
+
// hold: a woken client can outlive its console. Windows keeps no group, so the
|
|
10
|
+
// recorded process alone is checked there.
|
|
11
|
+
// A claim with no PID (its console was lost between the claim and the spawn),
|
|
12
|
+
// a claim written before processes were recorded, and a reused PID whose group
|
|
13
|
+
// still answers cannot be proven either way; they are released a day after
|
|
14
|
+
// they began, long after their delegation expired.
|
|
15
|
+
|
|
16
|
+
// The longest wake waits 15 minutes and is then stopped; an hour leaves margin.
|
|
17
|
+
export const WAKE_CLAIM_TTL_MS = 60 * 60 * 1000;
|
|
18
|
+
export const LEGACY_CLAIM_TTL_MS = 24 * 60 * 60 * 1000;
|
|
19
|
+
// A claim whose process is still running is asked about again at most this often.
|
|
20
|
+
const RECHECK_MS = 60 * 1000;
|
|
21
|
+
|
|
22
|
+
// inspectProcess(pids) -> Map<pid, { identity }> of the PIDs that exist, or null
|
|
23
|
+
// when the OS could not be asked (agent-services/process-identity.js).
|
|
24
|
+
// groupAlive(pgid) -> true while any process of the group exists, false when
|
|
25
|
+
// none does, null when the OS could not tell.
|
|
26
|
+
export function createWakeClaimRelease({ store, inspectProcess = async () => null, groupAlive = processGroupAlive,
|
|
27
|
+
now = Date.now }) {
|
|
28
|
+
const checked = new Map();
|
|
29
|
+
|
|
30
|
+
async function released(claim) {
|
|
31
|
+
const age = now() - Date.parse(claim.execution_claimed_at);
|
|
32
|
+
const unproven = age >= LEGACY_CLAIM_TTL_MS;
|
|
33
|
+
if (claim.wake_process_evidence !== '1' || !claim.wake_pid) return unproven;
|
|
34
|
+
const pid = Number(claim.wake_pid);
|
|
35
|
+
const running = await inspectProcess([pid]).catch(() => null);
|
|
36
|
+
if (!running) return false;
|
|
37
|
+
const current = running.get(pid);
|
|
38
|
+
const reused = Boolean(current && claim.wake_pid_identity && current.identity
|
|
39
|
+
&& String(current.identity) !== claim.wake_pid_identity);
|
|
40
|
+
if (current && !reused) return false;
|
|
41
|
+
const group = groupAlive(pid);
|
|
42
|
+
if (group === false) return true;
|
|
43
|
+
// A group that still answers may be the woken client's descendants, or the
|
|
44
|
+
// reused PID's own group: only the second is left to the day's limit.
|
|
45
|
+
return group === true && reused && unproven;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Releases what the evidence allows; the number of claims released.
|
|
49
|
+
async function release(spaceId, agentId) {
|
|
50
|
+
// A remote run is ended by its device's answer (applyRemote); this device sees no process of it.
|
|
51
|
+
if (String(agentId).startsWith('peer:')) return 0;
|
|
52
|
+
let count = 0;
|
|
53
|
+
for (const claim of store.claimsBefore(spaceId, agentId, new Date(now() - WAKE_CLAIM_TTL_MS).toISOString())) {
|
|
54
|
+
if (now() - (checked.get(claim.id) ?? -Infinity) < RECHECK_MS) continue;
|
|
55
|
+
checked.set(claim.id, now());
|
|
56
|
+
if (await released(claim) && store.expireClaim(claim.id)) {
|
|
57
|
+
count += 1;
|
|
58
|
+
checked.delete(claim.id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return count;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Recorded synchronously at spawn, so a console lost right after still knows the PID.
|
|
65
|
+
function recordSpawn(askId, pid) {
|
|
66
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return;
|
|
67
|
+
store.recordWakeProcess(askId, pid);
|
|
68
|
+
void inspectProcess([pid]).then((found) => {
|
|
69
|
+
const identity = found?.get(pid)?.identity;
|
|
70
|
+
if (identity) store.recordWakeProcess(askId, pid, String(identity));
|
|
71
|
+
}).catch(() => {});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return { release, recordSpawn };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// The woken client leads its own process group on POSIX (detached, wake.js).
|
|
78
|
+
// Signal 0 only asks whether any member exists.
|
|
79
|
+
export function processGroupAlive(pgid, { platform = process.platform, kill = process.kill } = {}) {
|
|
80
|
+
if (platform === 'win32') return false;
|
|
81
|
+
try {
|
|
82
|
+
kill(-pgid, 0);
|
|
83
|
+
return true;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error?.code === 'ESRCH') return false;
|
|
86
|
+
return error?.code === 'EPERM' ? true : null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -96,7 +96,9 @@ export function runProcess(command, args, { cwd, env, input, timeoutMs, maxOutpu
|
|
|
96
96
|
const child = spawn(command, args, { cwd, env, shell: false, windowsHide: true,
|
|
97
97
|
detached: process.platform !== 'win32', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
98
98
|
const closed = new Promise((resolve) => child.once('close', resolve));
|
|
99
|
-
|
|
99
|
+
// The PID is known as soon as spawn() returns: record it before anything can
|
|
100
|
+
// lose the console, not on the later spawn event (rec#97).
|
|
101
|
+
if (Number.isSafeInteger(child.pid)) onSpawn?.(child.pid);
|
|
100
102
|
let output = '', pending = '', bytes = 0, settled = false, childClosed = false;
|
|
101
103
|
const decoder = new StringDecoder('utf8');
|
|
102
104
|
const callbacks = new Set();
|
|
@@ -193,7 +193,7 @@ export const PROJECT_AGENT_TOOL_DEFINITIONS = [
|
|
|
193
193
|
{
|
|
194
194
|
name: 'record_project_agent_task_activity',
|
|
195
195
|
title: 'WRITE · Record task activity',
|
|
196
|
-
description: 'Record real task/worker activity and optional source-labelled cumulative token usage; never estimate. workerStatus requires workerId and agentId. Supply actualExecutorId, actualModelProvider, actualModel together only with
|
|
196
|
+
description: 'Record real task/worker activity and optional source-labelled cumulative token usage of agentId (none is collected without it); never estimate. workerStatus requires workerId and agentId. Supply actualExecutorId, actualModelProvider, actualModel together only with authorized preflight evidence; otherwise omit all three, report observed workerRuntime and explain mismatch in summary. Valid terminal execution records routing outcome.',
|
|
197
197
|
inputSchema: projectAgentTaskActivityInput
|
|
198
198
|
},
|
|
199
199
|
{
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { errorCode } from '../diagnostics/safe-event.js';
|
|
1
|
+
import { errorCode, failureReason } from '../diagnostics/safe-event.js';
|
|
2
|
+
import { FULI_VERSION } from '../package-metadata.js';
|
|
3
|
+
import { singleLineExcerpt } from '../text/single-line.js';
|
|
2
4
|
|
|
3
5
|
// Every listed rule fetch is a model round trip (Codex re-sends its whole
|
|
4
6
|
// prompt each time), so ordinary tasks must not read the shared rules at all.
|
|
5
7
|
// A call that carries its task token is decided by that session; without one
|
|
6
8
|
// it may be refused while another session of the client is off (rec#5 C3b).
|
|
7
9
|
// Why a lifecycle hook failed, as far as it is safe to say (rec#85): an error's
|
|
8
|
-
// code or class, which are fixed identifiers
|
|
9
|
-
//
|
|
10
|
+
// code or class, which are fixed identifiers; a controlled error's message,
|
|
11
|
+
// which names the refused rule without the values it was given; and the
|
|
12
|
+
// version the hook ran, so a report tells an old install from a regression.
|
|
13
|
+
// Never another error's message, which may carry a prompt, path or credential.
|
|
14
|
+
// A Provider refusal is controlled too, but its message relays the Provider's
|
|
15
|
+
// own detail, which may echo what was sent: it says only its HTTP status.
|
|
10
16
|
export function hookFailureCause(error) {
|
|
11
17
|
const code = errorCode(error);
|
|
12
|
-
|
|
18
|
+
const rule = error?.name === 'ProviderRequestError' ? providerStatus(error) : failureReason(error, null);
|
|
19
|
+
return `${code ? `the hook failed: ${code}` : 'the hook failed'}${rule ? ` (${singleLineExcerpt(rule, 160)})` : ''} in FULI ${FULI_VERSION}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function providerStatus(error) {
|
|
23
|
+
return Number.isInteger(error.status) && error.status >= 100 && error.status <= 599 ? `HTTP ${error.status}` : null;
|
|
13
24
|
}
|
|
14
25
|
|
|
15
26
|
export const PASS_TASK_TOKEN = 'Pass taskContextToken to every FULI call. ';
|
|
@@ -80,6 +80,10 @@ export async function enrichProjectAgentTaskActivity(input = {}, resolver = DEFA
|
|
|
80
80
|
const explicitTokenUsage = (Object.hasOwn(input, 'tokenUsage') && input.tokenUsage !== undefined) ||
|
|
81
81
|
(Object.hasOwn(input, 'token_usage') && input.token_usage !== undefined);
|
|
82
82
|
if (explicitTokenUsage) return input;
|
|
83
|
+
// Usage belongs to a participating Agent. A report without one (a
|
|
84
|
+
// coordinator's status line) collects none: the Provider refuses usage
|
|
85
|
+
// without its Agent, and the reporter's own session is not the task's (rec#85).
|
|
86
|
+
if (!nonEmptyText(input.agentId ?? input.agent_id)) return input;
|
|
83
87
|
|
|
84
88
|
const resolve = typeof resolver === 'function' ? resolver : resolver?.resolve;
|
|
85
89
|
if (typeof resolve !== 'function') return input;
|
|
@@ -145,3 +149,7 @@ function safeSessionId(value) {
|
|
|
145
149
|
!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(normalized)) return null;
|
|
146
150
|
return normalized;
|
|
147
151
|
}
|
|
152
|
+
|
|
153
|
+
function nonEmptyText(value) {
|
|
154
|
+
return typeof value === 'string' && value.trim() !== '';
|
|
155
|
+
}
|
|
@@ -36,6 +36,7 @@ import { createSessionPreferenceDelivery } from '../conversations/preference-ses
|
|
|
36
36
|
import { createSessionPromptSentences } from './session-prompt-sentences.js';
|
|
37
37
|
import { diagnosticEventLog } from '../diagnostics/event-log.js';
|
|
38
38
|
import { nativeChoiceAnswers } from '../agents/choice-answers.js';
|
|
39
|
+
import { createProcessInspector } from '../agent-services/process-identity.js';
|
|
39
40
|
|
|
40
41
|
// The local stores and runtimes an application opened from a runtime
|
|
41
42
|
// directory owns. Adding one means opening it here and closing it below.
|
|
@@ -116,7 +117,9 @@ export function openLocalRuntimes(app, { runtimeConfigPath, paths, env, fetchImp
|
|
|
116
117
|
env,
|
|
117
118
|
// Asks to a Codex FLA go to its inbox conversation in the Codex app when that app is installed.
|
|
118
119
|
desktopApp: createDesktopApps({ env }),
|
|
119
|
-
openStore: () => createRoundtableStore(join(dataDir, 'agent-roundtable.sqlite'))
|
|
120
|
+
openStore: () => createRoundtableStore(join(dataDir, 'agent-roundtable.sqlite')),
|
|
121
|
+
// A wake claim its console lost is released only once its process has ended.
|
|
122
|
+
inspectProcess: createProcessInspector().inspect
|
|
120
123
|
});
|
|
121
124
|
}
|
|
122
125
|
|
package/src/judgment/backend.js
CHANGED
|
@@ -69,6 +69,7 @@ export function failureProvenance(error) {
|
|
|
69
69
|
// Why a judgment failed, for the Agent that asked (rec#83): the step, a fixed
|
|
70
70
|
// category and what to do next. Only fixed words and the HTTP status, never
|
|
71
71
|
// the error's own message, which may carry Provider or model text.
|
|
72
|
+
const MODEL_STOP = Object.freeze({ stopped: 'model_stopped', paused: 'model_paused' });
|
|
72
73
|
const UNREACHABLE = new Set(['provider_unavailable', 'provider_timeout', 'provider_http_5xx']);
|
|
73
74
|
const FAILURE_RECOVERY = Object.freeze({
|
|
74
75
|
provider_unreachable: 'The graph service did not answer; try again once it is back.',
|
|
@@ -76,14 +77,19 @@ const FAILURE_RECOVERY = Object.freeze({
|
|
|
76
77
|
not_allowed: 'This Agent may not read what the judgment needs; ask from the project of the task.',
|
|
77
78
|
provider_refused: 'The graph service refused the read; check the input and ask again.',
|
|
78
79
|
model: 'The Tonborg model failed; see modelReceipt, then try again or check the model settings.',
|
|
80
|
+
// A refusal, permission or egress stop (model-backends/failures.js) is not retried anywhere.
|
|
81
|
+
model_stopped: 'The model call was stopped (modelReceipt.reason, e.g. egress not approved or permission denied). '
|
|
82
|
+
+ 'Do not retry it or judge it again with another model, endpoint or session; ask again only after the person grants what was refused.',
|
|
83
|
+
model_paused: 'The Tonborg budget is used up; ask again after it resets or the person raises it.',
|
|
79
84
|
invalid_answer: 'The answer did not match the eligible executors or conversations; ask again.',
|
|
80
85
|
unknown: 'Try again; if it repeats, report the error code and step.'
|
|
81
86
|
});
|
|
82
87
|
export const FAILED_JUDGMENT_GUIDANCE = 'The judgment failed: nothing was selected or run, and this is no execution receipt. '
|
|
83
|
-
+ 'What the person already chose stands
|
|
88
|
+
+ 'Do not make this judgment in its place. What the person already chose stands for the work it covers; '
|
|
89
|
+
+ 'record that work with its own run evidence, or ask them.';
|
|
84
90
|
|
|
85
91
|
function failureCategory(error) {
|
|
86
|
-
if (error.modelReceipt) return 'model';
|
|
92
|
+
if (error.modelReceipt) return MODEL_STOP[error.modelReceipt.status] ?? 'model';
|
|
87
93
|
if (error instanceof TypeError || error.name === 'ZodError') return 'invalid_answer';
|
|
88
94
|
if (UNREACHABLE.has(error.code)) return 'provider_unreachable';
|
|
89
95
|
if (error.code !== 'provider_error') return 'unknown';
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
// and writes its digest here before publishing (scripts/pin-win-helper.js); a
|
|
4
4
|
// source checkout has no helper and no pin, so Windows Hello is unavailable there.
|
|
5
5
|
// The helper is not Authenticode-signed: this digest is its only integrity check.
|
|
6
|
-
export const WIN_HELPER_SHA256 = '
|
|
6
|
+
export const WIN_HELPER_SHA256 = '7b33c593a701f78b84d9459ca3345a10dafc37b674badd34eebd7e93b28cb7d8';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.25.2",
|
|
3
|
+
"zh": [
|
|
4
|
+
"又一个小修版:叫不醒的同事,FULI 先看看它的进程还在不在,再决定让不让位。",
|
|
5
|
+
"Tonborg 的模型被拒或没额度时,直接说停下,不再劝你重试。",
|
|
6
|
+
"钩子出错时会说是哪条规则拦的、自己是哪个版本,排查快多了。"
|
|
7
|
+
],
|
|
8
|
+
"en": [
|
|
9
|
+
"Another small fix: before freeing a stuck wake, FULI checks whether its process still runs.",
|
|
10
|
+
"When Tonborg's model is refused or out of budget, it says stop, not try again.",
|
|
11
|
+
"A failed hook now names the rule that stopped it and its own version."
|
|
12
|
+
]
|
|
13
|
+
}
|