u-foo 4.0.5 → 4.0.10
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/README.md +224 -19
- package/README.zh-CN.md +3 -3
- package/bin/ucode.js +10 -2
- package/bin/ufoo.js +3 -0
- package/dist/tui/darwin-arm64/ufoo-tui +0 -0
- package/dist/tui/darwin-x64/ufoo-tui +0 -0
- package/dist/tui/linux-arm64/ufoo-tui +0 -0
- package/dist/tui/linux-x64/ufoo-tui +0 -0
- package/{OBSERVABILITY.md → docs/OBSERVABILITY.md} +3 -3
- package/docs/README.md +27 -0
- package/extensions/ufoo-browser/LICENSE +152 -0
- package/extensions/ufoo-browser/NOTICE +10 -0
- package/extensions/ufoo-browser/README.md +30 -0
- package/extensions/ufoo-browser/background.js +409 -0
- package/extensions/ufoo-browser/icons/icon-128.png +0 -0
- package/extensions/ufoo-browser/icons/icon-16.png +0 -0
- package/extensions/ufoo-browser/icons/icon-256.png +0 -0
- package/extensions/ufoo-browser/icons/icon-32.png +0 -0
- package/extensions/ufoo-browser/icons/icon-48.png +0 -0
- package/extensions/ufoo-browser/icons/logo.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-16.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-32.png +0 -0
- package/extensions/ufoo-browser/icons/toolbar-logo.png +0 -0
- package/extensions/ufoo-browser/manifest.json +30 -0
- package/extensions/ufoo-browser/popup.css +71 -0
- package/extensions/ufoo-browser/popup.html +44 -0
- package/extensions/ufoo-browser/popup.js +153 -0
- package/package.json +5 -3
- package/scripts/postinstall.js +6 -0
- package/src/agents/capabilities/browser/index.js +49 -0
- package/src/agents/capabilities/coding/backgroundHooks.js +94 -0
- package/src/agents/capabilities/coding/index.js +30 -1
- package/src/agents/capabilities/index.js +5 -2
- package/src/agents/capabilities/planning/index.js +44 -5
- package/src/agents/capabilities/turnRecall/index.js +341 -0
- package/src/agents/controller/controllerToolExecutor.js +2 -2
- package/src/agents/internal/internalRunner.js +30 -8
- package/src/agents/internal/taskControl.js +107 -0
- package/src/agents/profiles/coding.js +1 -1
- package/src/agents/profiles/main.js +1 -1
- package/src/agents/prompts/mainAgent.js +1 -0
- package/src/agents/prompts/native/toolDescriptions/bash.js +7 -1
- package/src/agents/providers/claudeSessionFiles.js +1 -1
- package/src/agents/providers/codexThreadProvider.js +6 -1
- package/src/agents/providers/credentials/agy.js +171 -0
- package/src/agents/providers/directAuthStatus.js +20 -2
- package/src/agents/providers/modelsCatalog.js +26 -5
- package/src/agents/providers/nativeTransport.js +36 -20
- package/src/agents/providers/providerId.js +17 -0
- package/src/agents/providers/runtimeConfig.js +26 -19
- package/src/agents/providers/transports/antigravityTransport.js +242 -0
- package/src/agents/providers/transports/index.js +1 -0
- package/src/agents/providers/transports/openaiChatTransport.js +3 -2
- package/src/agents/providers/transports/openaiResponsesTransport.js +2 -1
- package/src/agents/providers/transports/responsesProtocol.js +119 -18
- package/src/agents/providers/transports/transportContract.js +1 -0
- package/src/agents/providers/upstreamRuntime.js +3 -1
- package/src/agents/runtime/context/contextBudget.js +1 -19
- package/src/agents/runtime/context/contextWindow.js +5 -0
- package/src/agents/runtime/context/replayHistory.js +16 -10
- package/src/agents/runtime/context/runtimeStore.js +0 -2
- package/src/agents/runtime/context/sessionJournal.js +1 -1
- package/src/agents/runtime/context/slidingWindowManager.js +792 -0
- package/src/agents/runtime/context/topicSelector.js +338 -0
- package/src/agents/runtime/context/turnAnalyzer.js +767 -0
- package/src/agents/runtime/context/turnIndexStore.js +515 -0
- package/src/agents/runtime/core/agentLoop.js +95 -32
- package/src/agents/runtime/core/executionBudget.js +2 -1
- package/src/agents/runtime/core/toolErrorGuard.js +39 -0
- package/src/agents/runtime/createAgentRuntime.js +80 -7
- package/src/agents/runtime/index.js +5 -0
- package/src/agents/runtime/protocol/materialize.js +1 -1
- package/src/agents/runtime/tasks/hooks.js +137 -0
- package/src/app/chat/ChatController.js +8 -4
- package/src/app/chat/daemonMessageRouter.js +3 -1
- package/src/app/chat/inputSubmitHandler.js +2 -2
- package/src/app/chat/transport.js +1 -1
- package/src/app/cli/browserCommands.js +340 -0
- package/src/app/cli/features/doctor.js +21 -0
- package/src/app/cli/metricsCommands.js +1 -1
- package/src/app/cli/run.js +80 -1
- package/src/app/cli/setupCommands.js +200 -0
- package/src/code/UcodeController.js +31 -1
- package/src/code/agent.js +41 -7
- package/src/code/busConsumer.js +13 -12
- package/src/code/commands.js +0 -1
- package/src/code/context/assembler.js +11 -88
- package/src/code/context/planGraphService.js +83 -9
- package/src/code/context/planProjection.js +10 -2
- package/src/code/context/reducers.js +172 -4
- package/src/code/context/stateCommit.js +0 -32
- package/src/code/context/transcript.js +7 -4
- package/src/code/internalThread.js +9 -1
- package/src/code/launcher/ucode.js +4 -2
- package/src/code/nativeRunner.js +221 -10
- package/src/code/repl.js +27 -1
- package/src/code/runtime/agentWakeup.js +20 -3
- package/src/code/runtime/backgroundWakeHost.js +45 -0
- package/src/code/runtime/taskFocusContext.js +7 -0
- package/src/code/runtime/taskLoop.js +24 -1
- package/src/code/sessionStore.js +14 -10
- package/src/code/taskDecomposer.js +13 -7
- package/src/code/tools/backgroundProcess.js +23 -0
- package/src/code/tools/bash.js +764 -12
- package/src/code/tools/executor.js +12 -4
- package/src/code/tools/specs.js +60 -3
- package/src/code/tools/taskRun.js +38 -0
- package/src/config.js +92 -6
- package/src/coordination/bus/subscriber.js +1 -1
- package/src/coordination/history/agentPerformance.js +18 -18
- package/src/coordination/history/agentTrace.js +7 -3
- package/src/coordination/state/workspaceAccess.js +3 -1
- package/src/orchestration/groups/modelConfig.js +66 -0
- package/src/orchestration/groups/validateTemplate.js +2 -0
- package/src/runtime/browser/broker.js +1027 -0
- package/src/runtime/browser/brokerClient.js +108 -0
- package/src/runtime/browser/componentInstaller.js +275 -0
- package/src/runtime/browser/installState.js +329 -0
- package/src/runtime/browser/manifest.js +145 -0
- package/src/runtime/browser/native-host-runner.js +198 -0
- package/src/runtime/browser/nativeHost.js +213 -0
- package/src/runtime/browser/nativeMessagingProtocol.js +50 -0
- package/src/runtime/browser/paths.js +134 -0
- package/src/runtime/browser/playwrightSession.js +614 -0
- package/src/runtime/daemon/agentHost.js +175 -30
- package/src/runtime/daemon/busBridge.js +2 -1
- package/src/runtime/daemon/globalDaemon.js +20 -0
- package/src/runtime/daemon/groupOrchestrator.js +20 -1
- package/src/runtime/daemon/index.js +5 -4
- package/src/runtime/daemon/ops.js +14 -8
- package/src/tools/handlers/listAgents.js +1 -1
- package/src/tools/handlers/readBusSummary.js +1 -1
- package/src/tools/handlers/routeAgent.js +122 -5
- package/src/tools/schemaFixtures.js +1 -1
- package/src/ui/agentSurface.js +26 -3
- package/src/ui/format/index.js +34 -2
- package/src/ui/rustChatHost.js +22 -7
- package/src/ui/rustMultiSession.js +14 -2
- package/src/ui/rustUcodeHost.js +246 -77
- package/src/ui/ucodeAgentSession.js +88 -0
- package/templates/groups/build-lane.json +57 -3
- package/templates/groups/build-ultra.json +114 -6
- package/templates/groups/design-system.json +57 -3
- package/templates/groups/product-discovery.json +57 -3
- package/templates/groups/ui-plan-review.json +57 -3
- package/templates/groups/ui-polish.json +57 -3
- package/templates/groups/verify-ship.json +57 -3
- package/src/agents/runtime/context/checkpointStore.js +0 -52
- package/src/agents/runtime/context/compaction.js +0 -171
|
@@ -19,9 +19,6 @@ const {
|
|
|
19
19
|
renderStateEpoch,
|
|
20
20
|
applyStateCommit,
|
|
21
21
|
applyValidatedStateCommit,
|
|
22
|
-
buildDeterministicToolCommit,
|
|
23
|
-
resolveCommitInterval,
|
|
24
|
-
shouldCommitAfterToolCall,
|
|
25
22
|
ensureStateEpoch,
|
|
26
23
|
} = require("./stateCommit");
|
|
27
24
|
const {
|
|
@@ -34,7 +31,7 @@ const { renderExecutionSegmentContext } = require("./executionSegment");
|
|
|
34
31
|
const { renderPlanModeContext } = require("./planMode");
|
|
35
32
|
const { drainAgentMailboxForTurn } = require("../runtime/agentWakeup");
|
|
36
33
|
const { stripVisionBase64, degradeVisionContent } = require("../providers/visionBlocks");
|
|
37
|
-
const {
|
|
34
|
+
const { DEFAULT_V2_POLICY } = require("../../agents/runtime/context/slidingWindowManager");
|
|
38
35
|
|
|
39
36
|
const DEFAULT_TRANSCRIPT_WINDOW = 12;
|
|
40
37
|
const DEFAULT_RECENT_TOOL_EVENTS = 4;
|
|
@@ -45,10 +42,9 @@ function resolveTranscriptWindow(env = process.env) {
|
|
|
45
42
|
return DEFAULT_TRANSCRIPT_WINDOW;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
function defaultContextPolicy(
|
|
45
|
+
function defaultContextPolicy() {
|
|
49
46
|
return {
|
|
50
|
-
...
|
|
51
|
-
commitInterval: resolveCommitInterval(env),
|
|
47
|
+
...DEFAULT_V2_POLICY,
|
|
52
48
|
};
|
|
53
49
|
}
|
|
54
50
|
|
|
@@ -64,12 +60,15 @@ function eventToModelMessage(event = {}, options = {}) {
|
|
|
64
60
|
if (!event || typeof event !== "object") return null;
|
|
65
61
|
|
|
66
62
|
if (preferArtifact && event.artifactId) {
|
|
63
|
+
const hasFullContent = event.content !== undefined && event.content !== null && event.content !== "";
|
|
67
64
|
return {
|
|
68
65
|
role: event.role || "tool",
|
|
69
|
-
content:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
content: hasFullContent
|
|
67
|
+
? event.content
|
|
68
|
+
: JSON.stringify({
|
|
69
|
+
artifactId: event.artifactId,
|
|
70
|
+
preview: event.preview || "",
|
|
71
|
+
}),
|
|
73
72
|
tool_call_id: event.toolCallId,
|
|
74
73
|
};
|
|
75
74
|
}
|
|
@@ -85,70 +84,6 @@ function eventToModelMessage(event = {}, options = {}) {
|
|
|
85
84
|
return message;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
function buildRollingSummary(transcriptEvents = [], existingSummary = "", session = null) {
|
|
89
|
-
const events = Array.isArray(transcriptEvents) ? transcriptEvents : [];
|
|
90
|
-
const window = resolveTranscriptWindow();
|
|
91
|
-
const parts = [];
|
|
92
|
-
|
|
93
|
-
const contract = session && session.taskContract && typeof session.taskContract === "object"
|
|
94
|
-
? session.taskContract
|
|
95
|
-
: null;
|
|
96
|
-
if (contract && contract.objective) {
|
|
97
|
-
parts.push(`Objective: ${String(contract.objective).slice(0, 200)}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const epoch = session && session.stateEpoch && session.stateEpoch.snapshot
|
|
101
|
-
? session.stateEpoch.snapshot
|
|
102
|
-
: null;
|
|
103
|
-
if (epoch) {
|
|
104
|
-
if (epoch.currentObjective) {
|
|
105
|
-
parts.push(`Current objective: ${String(epoch.currentObjective).slice(0, 160)}`);
|
|
106
|
-
}
|
|
107
|
-
if (Array.isArray(epoch.facts) && epoch.facts.length > 0) {
|
|
108
|
-
parts.push(`Facts: ${epoch.facts.slice(-4).map((f) => String(f).slice(0, 120)).join(" | ")}`);
|
|
109
|
-
}
|
|
110
|
-
if (Array.isArray(epoch.decisions) && epoch.decisions.length > 0) {
|
|
111
|
-
parts.push(`Decisions: ${epoch.decisions.slice(-3).map((d) => String(d).slice(0, 120)).join(" | ")}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const modified = session
|
|
116
|
-
&& session.executionState
|
|
117
|
-
&& Array.isArray(session.executionState.modifiedFiles)
|
|
118
|
-
? session.executionState.modifiedFiles.slice(-8)
|
|
119
|
-
: [];
|
|
120
|
-
if (modified.length > 0) {
|
|
121
|
-
parts.push(`Modified files: ${modified.join(", ")}`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (events.length > window) {
|
|
125
|
-
const omitted = events.length - window;
|
|
126
|
-
parts.push(`Earlier transcript (${omitted} events omitted from model input).`);
|
|
127
|
-
const userGoals = events
|
|
128
|
-
.filter((e) => e.role === "user")
|
|
129
|
-
.map((e) => {
|
|
130
|
-
const text = typeof e.content === "string" ? e.content : "";
|
|
131
|
-
return text.split(/\r?\n/)[0].trim();
|
|
132
|
-
})
|
|
133
|
-
.filter(Boolean)
|
|
134
|
-
.slice(-3);
|
|
135
|
-
const toolErrors = events
|
|
136
|
-
.filter((e) => e.preview && /error|failed/i.test(e.preview))
|
|
137
|
-
.slice(-2)
|
|
138
|
-
.map((e) => String(e.preview).slice(0, 160));
|
|
139
|
-
if (userGoals.length > 0) parts.push(`Recent goals: ${userGoals.join(" | ")}`);
|
|
140
|
-
if (toolErrors.length > 0) parts.push(`Recent errors: ${toolErrors.join(" | ")}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const prior = String(existingSummary || "").trim();
|
|
144
|
-
// Keep a short prior digest only when it adds distinct content.
|
|
145
|
-
if (prior && !parts.some((part) => prior.includes(part.slice(0, 40)))) {
|
|
146
|
-
parts.unshift(prior.split(/\n/).slice(0, 3).join("\n").slice(0, 400));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return parts.join("\n").slice(0, 1800);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
87
|
function selectRecentToolArtifactIds(events = [], limit = DEFAULT_RECENT_TOOL_EVENTS) {
|
|
153
88
|
const list = Array.isArray(events) ? events : [];
|
|
154
89
|
const ids = [];
|
|
@@ -473,10 +408,9 @@ function persistToolResultToContext({
|
|
|
473
408
|
};
|
|
474
409
|
}
|
|
475
410
|
|
|
476
|
-
function recordToolCallInSession(session = {}, persisted = {}
|
|
411
|
+
function recordToolCallInSession(session = {}, persisted = {}) {
|
|
477
412
|
if (!session || typeof session !== "object") return;
|
|
478
413
|
ensureStateEpoch(session);
|
|
479
|
-
session.toolCallsSinceCommit = (Number(session.toolCallsSinceCommit) || 0) + 1;
|
|
480
414
|
if (!Array.isArray(session.workingSet)) session.workingSet = [];
|
|
481
415
|
if (!session.executionState || typeof session.executionState !== "object") {
|
|
482
416
|
session.executionState = require("./executionSegment").emptyExecutionState();
|
|
@@ -538,16 +472,6 @@ function recordToolCallInSession(session = {}, persisted = {}, workspaceRoot = p
|
|
|
538
472
|
retries[toolKey] = (Number(retries[toolKey]) || 0) + 1;
|
|
539
473
|
session.executionState.retries = retries;
|
|
540
474
|
}
|
|
541
|
-
|
|
542
|
-
const interval = resolveCommitInterval();
|
|
543
|
-
if (shouldCommitAfterToolCall(session, interval)) {
|
|
544
|
-
const commit = buildDeterministicToolCommit(persisted);
|
|
545
|
-
if (commit) {
|
|
546
|
-
applyValidatedStateCommit(session, commit, workspaceRoot);
|
|
547
|
-
} else {
|
|
548
|
-
session.toolCallsSinceCommit = 0;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
475
|
}
|
|
552
476
|
|
|
553
477
|
function applyContextSideEffects(session = {}, sideEffects = {}, workspaceRoot = process.cwd()) {
|
|
@@ -601,7 +525,6 @@ module.exports = {
|
|
|
601
525
|
DEFAULT_TRANSCRIPT_WINDOW,
|
|
602
526
|
DEFAULT_RECENT_TOOL_EVENTS,
|
|
603
527
|
defaultContextPolicy,
|
|
604
|
-
buildRollingSummary,
|
|
605
528
|
buildRecentMessages,
|
|
606
529
|
buildModelMessagesFromTranscript,
|
|
607
530
|
selectRecentToolArtifactIds,
|
|
@@ -210,9 +210,17 @@ function validateCommandNodes(command, validateToolArgs = false) {
|
|
|
210
210
|
if (Object.hasOwn(node, "arguments")) errors.push({ code: "INVALID_NODE_ARGUMENTS", field: `${field}.arguments`, nodeId: node.id || "",
|
|
211
211
|
message: `${field}.arguments is unsupported; use ${field}.args for tool parameters` });
|
|
212
212
|
if (node.args != null && (typeof node.args !== "object" || Array.isArray(node.args))) errors.push({ code: "INVALID_NODE_ARGUMENTS", field: `${field}.args`, nodeId: node.id || "", message: `${field}.args must be an object` });
|
|
213
|
-
if (!Object.hasOwn(node, "arguments"))
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
if (!Object.hasOwn(node, "arguments")) {
|
|
214
|
+
const requiredKeys = [...(specs?.get(node.tool)?.required || [])];
|
|
215
|
+
if (specs?.has("bash") && node.tool === "bash") {
|
|
216
|
+
const bashAction = String((node.args && node.args.action) || "run").trim().toLowerCase() || "run";
|
|
217
|
+
if (bashAction === "run") requiredKeys.push("command");
|
|
218
|
+
else if (["logs", "status", "stop"].includes(bashAction)) requiredKeys.push("backgroundId");
|
|
219
|
+
}
|
|
220
|
+
for (const key of requiredKeys) {
|
|
221
|
+
if (!Object.hasOwn(node.args || {}, key)) errors.push({ code: "MISSING_TOOL_ARGUMENT", field: `${field}.args.${key}`, nodeId: node.id || "",
|
|
222
|
+
message: `${field}.args.${key} is required for ${node.tool}; correct the node and resubmit the command` });
|
|
223
|
+
}
|
|
216
224
|
}
|
|
217
225
|
}
|
|
218
226
|
for (const key of ["nodes", "children", "steps"]) if (Array.isArray(node[key])) node[key].forEach((child, index) => visit(child, `${field}.${key}[${index}]`));
|
|
@@ -631,9 +639,9 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
631
639
|
return { ...payload, executionState, modelPayload: payload };
|
|
632
640
|
}
|
|
633
641
|
|
|
634
|
-
// create/
|
|
635
|
-
// select a TaskLoop child via command.graphId.
|
|
636
|
-
const selected = (operation === "patch" || operation === "inspect")
|
|
642
|
+
// create/cancel_graph/clear target the primary agent graph; patch/inspect/control
|
|
643
|
+
// may select a TaskLoop child via command.graphId.
|
|
644
|
+
const selected = (operation === "patch" || operation === "inspect" || operation === "control")
|
|
637
645
|
? selectGraphForCommand(executionState, command)
|
|
638
646
|
: {
|
|
639
647
|
ok: true,
|
|
@@ -652,6 +660,7 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
652
660
|
|
|
653
661
|
const primaryGraphId = selected.primaryGraphId
|
|
654
662
|
|| String(executionState.planGraph && executionState.planGraph.graphId || "");
|
|
663
|
+
const priorMode = executionState.mode || "single_action";
|
|
655
664
|
// Work on the selected graph for this command; restore primary afterward if child.
|
|
656
665
|
if (!selected.isPrimary) {
|
|
657
666
|
executionState.planGraph = selected.graph;
|
|
@@ -662,13 +671,42 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
662
671
|
if (executionState.planGraph && executionState.planGraph.graphId) {
|
|
663
672
|
executionState.graphs[executionState.planGraph.graphId] = executionState.planGraph;
|
|
664
673
|
}
|
|
665
|
-
if (!selected.isPrimary
|
|
666
|
-
|
|
674
|
+
if (!selected.isPrimary) {
|
|
675
|
+
if (primaryGraphId && executionState.graphs[primaryGraphId]) {
|
|
676
|
+
executionState.planGraph = executionState.graphs[primaryGraphId];
|
|
677
|
+
} else {
|
|
678
|
+
executionState.planGraph = emptyPlanGraphState();
|
|
679
|
+
executionState.mode = priorMode === "plan_graph" && primaryGraphId ? "plan_graph" : "single_action";
|
|
680
|
+
}
|
|
667
681
|
} else if (executionState.planGraph && executionState.planGraph.graphId) {
|
|
668
682
|
executionState.graphs[executionState.planGraph.graphId] = executionState.planGraph;
|
|
669
683
|
}
|
|
670
684
|
}
|
|
671
685
|
|
|
686
|
+
function attachChildTaskLoopHint(payload = null, resumed = null, targetGraph = null) {
|
|
687
|
+
if (
|
|
688
|
+
selected.isPrimary
|
|
689
|
+
|| !payload
|
|
690
|
+
|| payload.status !== "accepted"
|
|
691
|
+
|| !resumed
|
|
692
|
+
|| resumed.yieldReason !== "awaiting_complete_task"
|
|
693
|
+
|| !targetGraph
|
|
694
|
+
|| !targetGraph.owner
|
|
695
|
+
|| !targetGraph.owner.taskRunId
|
|
696
|
+
) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
const ownerRunId = String(targetGraph.owner.taskRunId);
|
|
700
|
+
const parentBound = Boolean(targetGraph.parentNodeId);
|
|
701
|
+
const nextAction = parentBound
|
|
702
|
+
? `All child nodes finished for taskRunId="${ownerRunId}". Call plan_graph operation="control" with actions=[{"op":"complete_task","taskRunId":"${ownerRunId}","result":{"summary":"..."}}] to finish this TaskRun, or patch graphId="${targetGraph.graphId}" if more steps are needed.`
|
|
703
|
+
: `All child nodes finished for standalone taskRunId="${ownerRunId}". Call task_run operation="complete" with taskRunId="${ownerRunId}" and result={"summary":"..."} to finish this TaskRun, or patch graphId="${targetGraph.graphId}" if more steps are needed.`;
|
|
704
|
+
payload.taskRunId = ownerRunId;
|
|
705
|
+
payload.awaitingCompleteTask = true;
|
|
706
|
+
payload.nextAction = nextAction;
|
|
707
|
+
payload.summary = `${payload.summary || "graph_terminal"} — ${nextAction}`;
|
|
708
|
+
}
|
|
709
|
+
|
|
672
710
|
function resumeChildTaskLoopIfNeeded(payload = null) {
|
|
673
711
|
if (selected.isPrimary) return null;
|
|
674
712
|
if (!payload || payload.status !== "accepted") return null;
|
|
@@ -752,11 +790,38 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
752
790
|
};
|
|
753
791
|
}
|
|
754
792
|
if (advanced.advance) advance = advanced.advance;
|
|
793
|
+
} else if (
|
|
794
|
+
controlResult.ok
|
|
795
|
+
&& touchedStatus
|
|
796
|
+
&& options.autoAdvance !== false
|
|
797
|
+
&& executionState.planGraph
|
|
798
|
+
&& Array.isArray(executionState.planGraph.nodes)
|
|
799
|
+
&& executionState.planGraph.nodes.length > 0
|
|
800
|
+
&& !executionState.planGraph.waitingFor
|
|
801
|
+
) {
|
|
802
|
+
const terminalSet = new Set(["succeeded", "failed", "blocked", "cancelled", "skipped"]);
|
|
803
|
+
const allTerminal = executionState.planGraph.nodes.every((n) => (
|
|
804
|
+
n && terminalSet.has(String(n.status || "").trim().toLowerCase())
|
|
805
|
+
));
|
|
806
|
+
if (allTerminal) {
|
|
807
|
+
advance = { ...advance, yieldReason: "graph_terminal" };
|
|
808
|
+
executionState.planGraph.lastYieldReason = "graph_terminal";
|
|
809
|
+
}
|
|
755
810
|
}
|
|
756
811
|
const completedGraph = executionState.planGraph;
|
|
757
812
|
const terminal = selected.isPrimary
|
|
758
813
|
? finalizeTerminalPrimaryPlan(executionState, completedGraph, advance)
|
|
759
814
|
: null;
|
|
815
|
+
if (!terminal && !selected.isPrimary && advance.yieldReason === "graph_terminal") {
|
|
816
|
+
const childId = String(completedGraph.graphId || "").trim();
|
|
817
|
+
if (childId) {
|
|
818
|
+
executionState.graphs[childId] = {
|
|
819
|
+
...completedGraph,
|
|
820
|
+
completedAt: new Date().toISOString(),
|
|
821
|
+
lastYieldReason: "graph_terminal",
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
}
|
|
760
825
|
const live = terminal
|
|
761
826
|
? completedGraph
|
|
762
827
|
: executionState.planGraph;
|
|
@@ -803,7 +868,15 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
803
868
|
cacheCommand(executionState.planGraph, commandId, payload);
|
|
804
869
|
}
|
|
805
870
|
restorePrimaryGraph();
|
|
806
|
-
|
|
871
|
+
const resumed = resumeChildTaskLoopIfNeeded(payload);
|
|
872
|
+
attachChildTaskLoopHint(payload, resumed, completedGraph);
|
|
873
|
+
return {
|
|
874
|
+
...payload,
|
|
875
|
+
executionState,
|
|
876
|
+
modelPayload: payload,
|
|
877
|
+
ok: payload.status === "accepted",
|
|
878
|
+
taskLoopResume: resumed || null,
|
|
879
|
+
};
|
|
807
880
|
}
|
|
808
881
|
|
|
809
882
|
if (operation === "cancel_graph" || operation === "clear") {
|
|
@@ -1191,6 +1264,7 @@ function runPlanGraphCommand(commandInput = {}, options = {}) {
|
|
|
1191
1264
|
|
|
1192
1265
|
restorePrimaryGraph();
|
|
1193
1266
|
const resumed = resumeChildTaskLoopIfNeeded(payload);
|
|
1267
|
+
attachChildTaskLoopHint(payload, resumed, completedGraph);
|
|
1194
1268
|
|
|
1195
1269
|
return {
|
|
1196
1270
|
...payload,
|
|
@@ -543,12 +543,20 @@ function buildPlanUiProjection(executionState = null, options = {}) {
|
|
|
543
543
|
const narrow = cols < 60;
|
|
544
544
|
const activityMessage = String(options.activityMessage || "").trim();
|
|
545
545
|
|
|
546
|
-
const
|
|
546
|
+
const rawPg = state.planGraph && typeof state.planGraph === "object" ? state.planGraph : {};
|
|
547
|
+
const activeRuns = listActiveWritingTaskRuns(state);
|
|
548
|
+
const isChildGraph = Boolean(rawPg.owner && rawPg.owner.kind === "task_loop");
|
|
549
|
+
const isTerminalGraph = String(rawPg.lastYieldReason || "").trim().toLowerCase() === "graph_terminal"
|
|
550
|
+
&& !rawPg.waitingFor
|
|
551
|
+
&& activeRuns.length === 0;
|
|
552
|
+
let pg = (isChildGraph || isTerminalGraph) ? {} : rawPg;
|
|
553
|
+
if (!pg.graphId && activeRuns.length > 0 && activeRuns[0].childGraphId && state.graphs && state.graphs[activeRuns[0].childGraphId]) {
|
|
554
|
+
pg = state.graphs[activeRuns[0].childGraphId];
|
|
555
|
+
}
|
|
547
556
|
const view = projectPlanView(pg);
|
|
548
557
|
const taskNodes = view.filter((node) => node && node.type === "task" && !node.generated);
|
|
549
558
|
const hasPlan = Boolean(pg.graphId) && taskNodes.length > 0;
|
|
550
559
|
const progress = countTaskProgress(view);
|
|
551
|
-
const activeRuns = listActiveWritingTaskRuns(state);
|
|
552
560
|
const focus = resolveFocus(view, pg, activeRuns);
|
|
553
561
|
const taskRun = buildTaskRunProjection(state, view);
|
|
554
562
|
const leaseHeld = hasActiveWriteLease(state);
|
|
@@ -1,7 +1,102 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const PREVIEW_MAX_CHARS = 600;
|
|
4
|
-
const MODEL_PAYLOAD_MAX_CHARS =
|
|
4
|
+
const MODEL_PAYLOAD_MAX_CHARS = 16000;
|
|
5
|
+
const JSON_ARRAY_FOLD_LIMIT = 12;
|
|
6
|
+
const JSON_OBJECT_KEY_LIMIT = 60;
|
|
7
|
+
const JSON_STRING_FIELD_MAX_CHARS = 1600;
|
|
8
|
+
const BASH_JSON_MAX_CHARS = 3600;
|
|
9
|
+
const BASH_STDOUT_MAX_CHARS = 2200;
|
|
10
|
+
const BASH_STDERR_MAX_CHARS = 1200;
|
|
11
|
+
|
|
12
|
+
function looksLikeLargeBase64(value = "") {
|
|
13
|
+
if (typeof value !== "string") return false;
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
if (trimmed.length < 256) return false;
|
|
16
|
+
if (/^data:[a-zA-Z0-9.+-]+\/[a-zA-Z0-9.+-]+;base64,/i.test(trimmed)) return true;
|
|
17
|
+
const compact = trimmed.replace(/\r?\n/g, "");
|
|
18
|
+
if (compact.length < 256 || /\s/.test(compact)) return false;
|
|
19
|
+
if (!/^[A-Za-z0-9+/=_-]+$/.test(compact)) return false;
|
|
20
|
+
// Require a mix of upper, lower, and digits or base64 padding/symbols so
|
|
21
|
+
// ordinary long paths or repeated single-char banners are not misclassified.
|
|
22
|
+
const hasUpper = /[A-Z]/.test(compact);
|
|
23
|
+
const hasLower = /[a-z]/.test(compact);
|
|
24
|
+
const hasDigitOrSym = /[0-9+/=]/.test(compact);
|
|
25
|
+
return hasUpper && hasLower && hasDigitOrSym;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function stripEmbeddedBase64(text = "") {
|
|
29
|
+
const source = String(text || "");
|
|
30
|
+
if (!source) return "";
|
|
31
|
+
return source
|
|
32
|
+
.replace(/data:[a-zA-Z0-9.+-]+\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=\s]{128,}/gi, (match) => `[omitted data-uri base64 (${match.length} chars)]`)
|
|
33
|
+
.replace(/\b[A-Za-z0-9+/]{256,}={0,2}\b/g, (match) => (looksLikeLargeBase64(match) ? `[omitted base64 blob (${match.length} chars)]` : match));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function dehydrateJsonValue(value, {
|
|
37
|
+
maxArrayItems = JSON_ARRAY_FOLD_LIMIT,
|
|
38
|
+
maxObjectKeys = JSON_OBJECT_KEY_LIMIT,
|
|
39
|
+
maxStringChars = JSON_STRING_FIELD_MAX_CHARS,
|
|
40
|
+
depth = 0,
|
|
41
|
+
} = {}) {
|
|
42
|
+
if (value === null || value === undefined) return value;
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
if (looksLikeLargeBase64(value)) {
|
|
45
|
+
return `[omitted base64 blob (${value.length} chars)]`;
|
|
46
|
+
}
|
|
47
|
+
const cleaned = stripEmbeddedBase64(value);
|
|
48
|
+
return cleaned.length > maxStringChars ? clipText(cleaned, maxStringChars) : cleaned;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value !== "object") return value;
|
|
51
|
+
if (depth >= 8) {
|
|
52
|
+
return Array.isArray(value) ? `[array(${value.length})]` : "[object]";
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
const kept = value
|
|
56
|
+
.slice(0, maxArrayItems)
|
|
57
|
+
.map((item) => dehydrateJsonValue(item, { maxArrayItems, maxObjectKeys, maxStringChars, depth: depth + 1 }));
|
|
58
|
+
if (value.length > maxArrayItems) {
|
|
59
|
+
kept.push(`[omitted ${value.length - maxArrayItems} additional items]`);
|
|
60
|
+
}
|
|
61
|
+
return kept;
|
|
62
|
+
}
|
|
63
|
+
const keys = Object.keys(value);
|
|
64
|
+
const out = {};
|
|
65
|
+
const sliceKeys = keys.slice(0, maxObjectKeys);
|
|
66
|
+
for (const key of sliceKeys) {
|
|
67
|
+
out[key] = dehydrateJsonValue(value[key], { maxArrayItems, maxObjectKeys, maxStringChars, depth: depth + 1 });
|
|
68
|
+
}
|
|
69
|
+
if (keys.length > maxObjectKeys) {
|
|
70
|
+
out._omittedKeys = keys.length - maxObjectKeys;
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function compactToolOutputForPrompt(rawText = "", {
|
|
76
|
+
maxArrayItems = JSON_ARRAY_FOLD_LIMIT,
|
|
77
|
+
maxJsonChars = BASH_JSON_MAX_CHARS,
|
|
78
|
+
maxTextChars = BASH_STDOUT_MAX_CHARS,
|
|
79
|
+
tailLineCount = 20,
|
|
80
|
+
} = {}) {
|
|
81
|
+
const source = String(rawText || "");
|
|
82
|
+
if (!source) return "";
|
|
83
|
+
const trimmed = source.trim();
|
|
84
|
+
if ((trimmed.startsWith("{") && trimmed.endsWith("}")) || (trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(trimmed);
|
|
87
|
+
if (parsed && typeof parsed === "object") {
|
|
88
|
+
const dehydrated = dehydrateJsonValue(parsed, { maxArrayItems });
|
|
89
|
+
const serialized = JSON.stringify(dehydrated, null, 2);
|
|
90
|
+
return clipText(serialized, maxJsonChars);
|
|
91
|
+
}
|
|
92
|
+
} catch {
|
|
93
|
+
// Fall through to text dehydration when output is not valid JSON.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const stripped = stripEmbeddedBase64(source);
|
|
97
|
+
const tailed = tailLineCount > 0 ? tailLines(stripped, tailLineCount) : stripped;
|
|
98
|
+
return clipText(tailed, maxTextChars);
|
|
99
|
+
}
|
|
5
100
|
|
|
6
101
|
function clipText(value = "", maxChars = PREVIEW_MAX_CHARS) {
|
|
7
102
|
const text = String(value || "");
|
|
@@ -206,6 +301,63 @@ function reduceBashResult(raw = {}, artifactId = "", args = {}) {
|
|
|
206
301
|
const stderr = String(source.stderr || "");
|
|
207
302
|
const command = String((args && args.command) || source.command || "");
|
|
208
303
|
|
|
304
|
+
if (source.kind === "background_bash") {
|
|
305
|
+
if (source.action === "list") {
|
|
306
|
+
const processes = Array.isArray(source.processes) ? source.processes : [];
|
|
307
|
+
const runningCount = Number.isFinite(source.runningCount)
|
|
308
|
+
? source.runningCount
|
|
309
|
+
: processes.filter((item) => item && item.running).length;
|
|
310
|
+
const summary = `bash bg list (${runningCount}/${processes.length} running)`;
|
|
311
|
+
return {
|
|
312
|
+
preview: summary,
|
|
313
|
+
summary,
|
|
314
|
+
modelPayload: {
|
|
315
|
+
ok: source.ok !== false,
|
|
316
|
+
artifactId,
|
|
317
|
+
kind: "background_bash",
|
|
318
|
+
action: "list",
|
|
319
|
+
count: processes.length,
|
|
320
|
+
runningCount,
|
|
321
|
+
processes,
|
|
322
|
+
error: source.error ? String(source.error) : undefined,
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const logOutput = String(source.logOutput ?? stdout);
|
|
328
|
+
const previewLines = tailLines(logOutput, 8);
|
|
329
|
+
const statusLabel = source.status || (source.running ? "running" : "exited");
|
|
330
|
+
const summary = `bash bg ${source.action || "run"} ${source.backgroundId || ""} status=${statusLabel}`.trim();
|
|
331
|
+
const preview = clipText(
|
|
332
|
+
[summary, previewLines ? `logs:\n${previewLines}` : ""].filter(Boolean).join("\n"),
|
|
333
|
+
PREVIEW_MAX_CHARS,
|
|
334
|
+
);
|
|
335
|
+
return {
|
|
336
|
+
preview,
|
|
337
|
+
summary,
|
|
338
|
+
modelPayload: {
|
|
339
|
+
ok: source.ok !== false,
|
|
340
|
+
artifactId,
|
|
341
|
+
kind: "background_bash",
|
|
342
|
+
action: source.action || "run",
|
|
343
|
+
backgroundId: source.backgroundId || "",
|
|
344
|
+
pid: source.pid ?? null,
|
|
345
|
+
running: Boolean(source.running),
|
|
346
|
+
status: statusLabel,
|
|
347
|
+
exitCode: source.exitCode ?? source.code ?? null,
|
|
348
|
+
signal: source.signal || undefined,
|
|
349
|
+
command: source.command || command || undefined,
|
|
350
|
+
logPath: source.logPath || undefined,
|
|
351
|
+
offset: Number.isFinite(source.offset) ? source.offset : 0,
|
|
352
|
+
nextOffset: Number.isFinite(source.nextOffset) ? source.nextOffset : 0,
|
|
353
|
+
totalBytes: Number.isFinite(source.totalBytes) ? source.totalBytes : 0,
|
|
354
|
+
truncated: Boolean(source.truncated) || logOutput.length > 12000,
|
|
355
|
+
logOutput: clipText(logOutput, 12000),
|
|
356
|
+
error: source.error ? String(source.error) : undefined,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
209
361
|
if (isTestCommand(command, stdout)) {
|
|
210
362
|
return reduceTestResult(raw, artifactId, args);
|
|
211
363
|
}
|
|
@@ -216,8 +368,20 @@ function reduceBashResult(raw = {}, artifactId = "", args = {}) {
|
|
|
216
368
|
return reduceSearchResult(raw, artifactId, args);
|
|
217
369
|
}
|
|
218
370
|
|
|
371
|
+
const compactedStdout = compactToolOutputForPrompt(stdout, {
|
|
372
|
+
maxArrayItems: JSON_ARRAY_FOLD_LIMIT,
|
|
373
|
+
maxJsonChars: BASH_JSON_MAX_CHARS,
|
|
374
|
+
maxTextChars: BASH_STDOUT_MAX_CHARS,
|
|
375
|
+
tailLineCount: 20,
|
|
376
|
+
});
|
|
377
|
+
const compactedStderr = compactToolOutputForPrompt(stderr, {
|
|
378
|
+
maxArrayItems: JSON_ARRAY_FOLD_LIMIT,
|
|
379
|
+
maxJsonChars: BASH_STDERR_MAX_CHARS,
|
|
380
|
+
maxTextChars: BASH_STDERR_MAX_CHARS,
|
|
381
|
+
tailLineCount: 20,
|
|
382
|
+
});
|
|
219
383
|
const preview = clipText(
|
|
220
|
-
[
|
|
384
|
+
[compactedStdout ? `stdout:\n${tailLines(compactedStdout, 8)}` : "", compactedStderr ? `stderr:\n${tailLines(compactedStderr, 8)}` : ""]
|
|
221
385
|
.filter(Boolean)
|
|
222
386
|
.join("\n"),
|
|
223
387
|
PREVIEW_MAX_CHARS,
|
|
@@ -229,8 +393,8 @@ function reduceBashResult(raw = {}, artifactId = "", args = {}) {
|
|
|
229
393
|
ok: source.ok !== false,
|
|
230
394
|
artifactId,
|
|
231
395
|
exitCode: source.code ?? source.exitCode ?? null,
|
|
232
|
-
stdoutTail:
|
|
233
|
-
stderrTail:
|
|
396
|
+
stdoutTail: compactedStdout,
|
|
397
|
+
stderrTail: compactedStderr,
|
|
234
398
|
error: source.error ? String(source.error) : undefined,
|
|
235
399
|
},
|
|
236
400
|
};
|
|
@@ -360,4 +524,8 @@ module.exports = {
|
|
|
360
524
|
reduceWriteResult,
|
|
361
525
|
reduceEditResult,
|
|
362
526
|
reduceArtifactReadResult,
|
|
527
|
+
looksLikeLargeBase64,
|
|
528
|
+
stripEmbeddedBase64,
|
|
529
|
+
dehydrateJsonValue,
|
|
530
|
+
compactToolOutputForPrompt,
|
|
363
531
|
};
|
|
@@ -267,12 +267,6 @@ function parseStructuredSideEffects(text = "") {
|
|
|
267
267
|
return null;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
function resolveCommitInterval(env = process.env) {
|
|
271
|
-
const parsed = Number.parseInt(String(env.UFOO_UCODE_COMMIT_INTERVAL || ""), 10);
|
|
272
|
-
if (Number.isFinite(parsed) && parsed > 0) return Math.floor(parsed);
|
|
273
|
-
return 4;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
270
|
function validateStateCommit(commit = {}) {
|
|
277
271
|
const normalized = normalizeStateCommit(commit);
|
|
278
272
|
const errors = [];
|
|
@@ -296,29 +290,6 @@ function validateStateCommit(commit = {}) {
|
|
|
296
290
|
return { ok: errors.length === 0, errors, commit: normalized };
|
|
297
291
|
}
|
|
298
292
|
|
|
299
|
-
function buildDeterministicToolCommit(toolEvent = {}) {
|
|
300
|
-
const source = toolEvent && typeof toolEvent === "object" ? toolEvent : {};
|
|
301
|
-
const tool = String(source.tool || "").trim().toLowerCase();
|
|
302
|
-
const preview = String(source.preview || source.summary || "").trim();
|
|
303
|
-
const artifactId = String(source.artifactId || "").trim();
|
|
304
|
-
if (!tool && !preview) return null;
|
|
305
|
-
const fact = [
|
|
306
|
-
tool ? `tool:${tool}` : "",
|
|
307
|
-
artifactId ? `artifact:${artifactId}` : "",
|
|
308
|
-
preview ? preview.slice(0, 180) : "",
|
|
309
|
-
].filter(Boolean).join(" ");
|
|
310
|
-
if (!fact) return null;
|
|
311
|
-
return {
|
|
312
|
-
factsAdd: [fact],
|
|
313
|
-
nextObjective: "",
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function shouldCommitAfterToolCall(session = {}, interval = resolveCommitInterval()) {
|
|
318
|
-
const count = Number(session.toolCallsSinceCommit) || 0;
|
|
319
|
-
return count >= interval;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
293
|
function appendCommitLog(workspaceRoot = process.cwd(), sessionId = "", commitEntry = {}) {
|
|
323
294
|
if (!sessionId) return { ok: false, error: "invalid session id" };
|
|
324
295
|
const fs = require("fs");
|
|
@@ -398,11 +369,8 @@ module.exports = {
|
|
|
398
369
|
renderTaskContract,
|
|
399
370
|
normalizeStateCommit,
|
|
400
371
|
validateStateCommit,
|
|
401
|
-
buildDeterministicToolCommit,
|
|
402
|
-
resolveCommitInterval,
|
|
403
372
|
resolveCommitFoldThreshold,
|
|
404
373
|
foldCommitsIfNeeded,
|
|
405
|
-
shouldCommitAfterToolCall,
|
|
406
374
|
appendCommitLog,
|
|
407
375
|
applyValidatedStateCommit,
|
|
408
376
|
applyStateCommit,
|
|
@@ -124,12 +124,15 @@ function transcriptEventsToMessages(events = [], options = {}) {
|
|
|
124
124
|
const messages = [];
|
|
125
125
|
for (const event of list) {
|
|
126
126
|
if (preferArtifact && event.artifactId) {
|
|
127
|
+
const hasFullContent = event.content !== undefined && event.content !== null && event.content !== "";
|
|
127
128
|
messages.push({
|
|
128
129
|
role: event.role || "tool",
|
|
129
|
-
content:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
content: hasFullContent
|
|
131
|
+
? event.content
|
|
132
|
+
: JSON.stringify({
|
|
133
|
+
artifactId: event.artifactId,
|
|
134
|
+
preview: event.preview || "",
|
|
135
|
+
}),
|
|
133
136
|
tool_call_id: event.toolCallId,
|
|
134
137
|
});
|
|
135
138
|
continue;
|
|
@@ -18,6 +18,12 @@ function createInternalCodingThread(options = {}) {
|
|
|
18
18
|
if (restored?.ok === false) throw new Error(restored.error || `Could not resume session: ${options.sessionId}`);
|
|
19
19
|
}
|
|
20
20
|
let abort = null;
|
|
21
|
+
let wakeDelivery = null;
|
|
22
|
+
const wakeHost = require("./runtime/backgroundWakeHost").createUcodeWakeHost({ state,
|
|
23
|
+
canDeliver: () => !abort && Boolean(wakeDelivery),
|
|
24
|
+
deliver: (event, claim, text) => wakeDelivery(event, claim, text),
|
|
25
|
+
onError: error => options.onError?.(error),
|
|
26
|
+
});
|
|
21
27
|
|
|
22
28
|
async function* runStreamed(input, runOptions = {}) {
|
|
23
29
|
if (abort) throw new Error("internal coding thread is already running");
|
|
@@ -101,7 +107,9 @@ function createInternalCodingThread(options = {}) {
|
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
return { id: state.sessionId, runStreamed,
|
|
110
|
+
return { id: state.sessionId, runStreamed,
|
|
111
|
+
async pollWakes(deliver) { wakeDelivery = deliver; try { await wakeHost.tick(); } finally { wakeDelivery = null; } },
|
|
112
|
+
close: async () => { wakeHost.close(); if (abort) abort.abort("runtime_closed"); } };
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
module.exports = { createInternalCodingThread };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { loadConfig } = require("../../config");
|
|
1
|
+
const { loadConfig, sameModelProvider } = require("../../config");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
|
|
@@ -95,9 +95,11 @@ function resolveUcodeLaunch({
|
|
|
95
95
|
|| config.ucodeProvider
|
|
96
96
|
|| ""
|
|
97
97
|
).trim();
|
|
98
|
+
const requestedProvider = readLastArgValue(argv, "--provider") || configuredProvider || config.agentProvider;
|
|
99
|
+
const useConfiguredModel = !sameModelProvider(requestedProvider, "agy") || sameModelProvider(config.ucodeProvider, "agy");
|
|
98
100
|
const configuredModel = String(
|
|
99
101
|
env.UFOO_UCODE_MODEL
|
|
100
|
-
|| config.ucodeModel
|
|
102
|
+
|| (useConfiguredModel ? config.ucodeModel : "")
|
|
101
103
|
|| ""
|
|
102
104
|
).trim();
|
|
103
105
|
|