@onepointfour-packs/flaredeck-agent 0.2.170 → 0.2.172
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/agent.js +2 -0
- package/dist/agent.js.map +1 -1
- package/dist/config.d.ts +6 -0
- package/dist/config.js.map +1 -1
- package/dist/engine-antigravity.js +3 -0
- package/dist/engine-antigravity.js.map +1 -1
- package/dist/engine-claude.js +1 -1
- package/dist/engine-claude.js.map +1 -1
- package/dist/engine.d.ts +4 -0
- package/dist/engine.js.map +1 -1
- package/dist/helpers.d.ts +33 -0
- package/dist/helpers.js +196 -0
- package/dist/helpers.js.map +1 -0
- package/dist/serve.js +51 -2
- package/dist/serve.js.map +1 -1
- package/package.json +1 -1
- package/python/sidecar.py +17 -0
package/dist/serve.js
CHANGED
|
@@ -43,6 +43,8 @@ import { dirname, join } from 'node:path';
|
|
|
43
43
|
import { configDir, loadGitHub, saveConfig, slug } from './config.js';
|
|
44
44
|
import { boardArg, onMyBoards, outstandingCards } from './boards.js';
|
|
45
45
|
import { browserTools, ensureBrowser } from './browser.js';
|
|
46
|
+
import { AGY_HELPERS_BRIEF, HELPERS_BRIEF, helperTools } from './helpers.js';
|
|
47
|
+
import { jamEvidence as jamEvidenceFor, loadJam as loadJamTokens } from './jam.js';
|
|
46
48
|
import { environmentTools } from './envtools.js';
|
|
47
49
|
import { watchForDesperation } from './desperation.js';
|
|
48
50
|
import { note, recallWorktree, rememberWorktree, resumeBrief } from './journal.js';
|
|
@@ -2011,6 +2013,11 @@ export async function serve(opts) {
|
|
|
2011
2013
|
// Read from the board= field, and checked here as well as asked for — the server is deployed
|
|
2012
2014
|
// separately, and a board-scoped agent once picked up another team's cards (KD-1361).
|
|
2013
2015
|
const boardKey = /board=`([^`]+)`/.exec(answer)?.[1];
|
|
2016
|
+
// The card's KEY, not its code: worktrees and sessions are kept per key. Queued under the code,
|
|
2017
|
+
// a picked-up card got a second worktree and branch beside its own — HR-0949 ended with two
|
|
2018
|
+
// commits on agent/hr-0949 and agent/8zmkggmzfzndbd2ravdq, and the first branch's leftover
|
|
2019
|
+
// edits reported the card "left unfinished" (16 Oct).
|
|
2020
|
+
const cardKey = /card=`([^`]+)`/.exec(answer)?.[1];
|
|
2014
2021
|
if (!onMyBoards(myBoards, boardKey ? { boardKey } : {}))
|
|
2015
2022
|
return false;
|
|
2016
2023
|
const kind = answer.startsWith('▶') ? 'doing' : answer.startsWith('✅ Next') ? 'mine' : answer.startsWith('✅ Took') ? 'took' : '';
|
|
@@ -2037,7 +2044,8 @@ export async function serve(opts) {
|
|
|
2037
2044
|
event: 'assigned',
|
|
2038
2045
|
line: kind === 'doing' ? `${next.code} is still yours and in progress` : `${next.code} is your next card — FlareDeck chose it by priority, then due date. Work this one.`,
|
|
2039
2046
|
cardCode: next.code,
|
|
2040
|
-
cardKey: next.code,
|
|
2047
|
+
cardKey: cardKey || next.code,
|
|
2048
|
+
...(boardKey ? { boardKey } : {}),
|
|
2041
2049
|
}))
|
|
2042
2050
|
void drain();
|
|
2043
2051
|
return true;
|
|
@@ -3422,6 +3430,21 @@ export async function serve(opts) {
|
|
|
3422
3430
|
* the card waits for the reset, as it would for a spent plan.
|
|
3423
3431
|
*/
|
|
3424
3432
|
let turnEngine = engine;
|
|
3433
|
+
/* Helpers (helpers.ts): on for this agent while they are measured. The result of one running
|
|
3434
|
+
in the background is typed into THIS turn; if the turn has ended by then, it starts the
|
|
3435
|
+
next one on the card, so it is never lost and never polled for. */
|
|
3436
|
+
const helpersOn = !isAssistant && (config.helpers === true || process.env['FLAREDECK_AGENT_HELPERS'] === '1');
|
|
3437
|
+
let thisRun = null;
|
|
3438
|
+
const deliverHelper = async (text) => {
|
|
3439
|
+
if (thisRun && liveRun === thisRun && await thisRun.steer(text).catch(() => false))
|
|
3440
|
+
return;
|
|
3441
|
+
if (!event.cardKey) {
|
|
3442
|
+
log('warn', `a helper finished after the turn ended, with no card to bring it back to: ${text.split('\n')[0]}`);
|
|
3443
|
+
return;
|
|
3444
|
+
}
|
|
3445
|
+
if (enqueue({ id: `helper-${Date.now()}`, event: 'assigned', cardKey: event.cardKey, cardCode: event.cardCode, ...(event.boardKey ? { boardKey: event.boardKey } : {}), line: `A helper you started on this card finished after your last turn ended:\n${text.slice(0, 6000)}` }))
|
|
3446
|
+
void drain();
|
|
3447
|
+
};
|
|
3425
3448
|
if (engine.name === 'antigravity') {
|
|
3426
3449
|
const spend = await geminiSpend?.status().catch(() => null);
|
|
3427
3450
|
if (spend?.over) {
|
|
@@ -3452,6 +3475,29 @@ export async function serve(opts) {
|
|
|
3452
3475
|
geminiOver = false;
|
|
3453
3476
|
}
|
|
3454
3477
|
}
|
|
3478
|
+
const helperSet = helpersOn && turnEngine.name === 'claude' ? helperTools({
|
|
3479
|
+
cwd: () => tree?.path ?? cwd,
|
|
3480
|
+
...(claudePlan?.use === 'token' ? { claudeToken: claudePlan.token } : {}),
|
|
3481
|
+
// Its own browser, on the same environment the agent's points at.
|
|
3482
|
+
browser: () => browserTools({
|
|
3483
|
+
repo: config.repo,
|
|
3484
|
+
endpoints: () => env.endpoints,
|
|
3485
|
+
...(web ? { defaultPart: () => web } : {}),
|
|
3486
|
+
sites: () => declaredSites,
|
|
3487
|
+
contract: () => env.contract,
|
|
3488
|
+
cwd,
|
|
3489
|
+
onNote: (t) => log('tool', t),
|
|
3490
|
+
}),
|
|
3491
|
+
jam: async (url) => {
|
|
3492
|
+
const tokens = loadJamTokens();
|
|
3493
|
+
if (!tokens)
|
|
3494
|
+
return null;
|
|
3495
|
+
const e = await jamEvidenceFor(url, tokens, (t) => log('tool', t));
|
|
3496
|
+
return e.ok ? e.text : null;
|
|
3497
|
+
},
|
|
3498
|
+
deliver: deliverHelper,
|
|
3499
|
+
log: (t) => log('tool', t),
|
|
3500
|
+
}) : null;
|
|
3455
3501
|
const engineContext = {
|
|
3456
3502
|
...(leadGoal ? { goal: leadGoal } : {}),
|
|
3457
3503
|
config: { ...config, repo: cwd, ...(isAssistant ? { assistantMode: true } : {}) },
|
|
@@ -3489,7 +3535,9 @@ export async function serve(opts) {
|
|
|
3489
3535
|
...(prepared?.model ? { model: prepared.model } : {}),
|
|
3490
3536
|
...(prepared?.size ? { size: prepared.size } : {}),
|
|
3491
3537
|
...(claudePlan?.use === 'token' ? { claudeToken: claudePlan.token } : {}),
|
|
3538
|
+
...(helpersOn && turnEngine.name === 'antigravity' ? { subagents: true } : {}),
|
|
3492
3539
|
tools: {
|
|
3540
|
+
...(helperSet ? { helpers: helperSet } : {}),
|
|
3493
3541
|
...(job ? { git: { server: gitServer, toolNames: GIT_TOOL_NAMES } } : {}),
|
|
3494
3542
|
// The project's file storage, when a person has set one up for these boards.
|
|
3495
3543
|
...(await turnFileTools(cwd, forACard, event.environment) ?? {}),
|
|
@@ -3539,8 +3587,9 @@ export async function serve(opts) {
|
|
|
3539
3587
|
`the card, tell whoever owns the board that ${START_SCRIPT_NAME} does not survive parallel ` +
|
|
3540
3588
|
`worktrees — it must take a free port AND pass that port to the parts that call it — and stop.`
|
|
3541
3589
|
: '');
|
|
3542
|
-
const run = turnEngine.run(brief, engineContext);
|
|
3590
|
+
const run = turnEngine.run(brief + (helpersOn ? (turnEngine.name === 'antigravity' ? AGY_HELPERS_BRIEF : HELPERS_BRIEF) : ''), engineContext);
|
|
3543
3591
|
liveRun = run;
|
|
3592
|
+
thisRun = run;
|
|
3544
3593
|
if (isAssistant)
|
|
3545
3594
|
liveFeed?.start(String(event.message ?? event.line ?? '').split('\n').filter(Boolean).pop() ?? '');
|
|
3546
3595
|
// Connected MCP servers' tokens, kept current for as long as the session runs. FlareDeck hands
|