u-foo 4.0.3 → 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 +239 -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 +7 -5
- 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 +145 -73
- package/src/agents/providers/providerId.js +17 -0
- package/src/agents/providers/runtimeConfig.js +67 -20
- 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 -1
- 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 +140 -35
- 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/busCoreCommands.js +63 -3
- package/src/app/cli/features/doctor.js +21 -0
- package/src/app/cli/metricsCommands.js +1 -1
- package/src/app/cli/run.js +81 -1
- package/src/app/cli/setupCommands.js +200 -0
- package/src/code/UcodeController.js +31 -1
- package/src/code/agent.js +76 -25
- 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 +121 -6
- 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/modelCommand.js +6 -5
- package/src/code/nativeRunner.js +232 -62
- 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 +16 -7
- package/src/code/tools/backgroundProcess.js +23 -0
- package/src/code/tools/bash.js +764 -12
- package/src/code/tools/executor.js +13 -4
- package/src/code/tools/planGraph.js +1 -0
- package/src/code/tools/specs.js +62 -4
- package/src/code/tools/taskRun.js +38 -0
- package/src/config.js +92 -6
- package/src/coordination/bus/index.js +2 -2
- package/src/coordination/bus/message.js +10 -1
- package/src/coordination/bus/nickname.js +3 -1
- package/src/coordination/bus/subscriber.js +25 -10
- package/src/coordination/bus/utils.js +4 -0
- package/src/coordination/bus/wakeEndpoint.js +198 -0
- package/src/coordination/history/agentPerformance.js +18 -18
- package/src/coordination/history/agentTrace.js +7 -3
- package/src/coordination/state/paths.js +4 -0
- 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 -28
- package/src/runtime/daemon/busBridge.js +2 -1
- package/src/runtime/daemon/deliveryScheduler.js +70 -2
- package/src/runtime/daemon/globalDaemon.js +20 -0
- package/src/runtime/daemon/groupOrchestrator.js +20 -1
- package/src/runtime/daemon/index.js +6 -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 +60 -6
- package/src/ui/format/index.js +34 -2
- package/src/ui/format/markdownRenderer.js +4 -2
- package/src/ui/rustChatHost.js +22 -7
- package/src/ui/rustMultiSession.js +14 -2
- package/src/ui/rustUcodeHost.js +249 -80
- 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 -38
- package/src/agents/runtime/context/compaction.js +0 -151
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { createHash } = require("crypto");
|
|
4
3
|
const { stripVisionBase64, retireMessageImages } = require("../../providers/transports/visionBlocks");
|
|
5
|
-
const { stableStringify } = require("../core/stableJson");
|
|
6
4
|
|
|
7
5
|
// Conservative local estimate; provider usage calibrates it in the loop.
|
|
8
6
|
function estimateTextTokens(text = "") {
|
|
@@ -36,22 +34,6 @@ function estimateMessagesTokens(messages = []) {
|
|
|
36
34
|
+ estimateTextTokens(JSON.stringify(summaryMessage(message))), 0);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
function historyDigest(messages = []) {
|
|
40
|
-
// Artifact previews can change after restoration; their immutable artifact
|
|
41
|
-
// identity stays stable. Non-artifact results still hash their full text.
|
|
42
|
-
const identity = messages.map(message => {
|
|
43
|
-
const value = summaryMessage(message);
|
|
44
|
-
if (value.role === "tool" && value.tool_call_id && typeof value.content === "string") {
|
|
45
|
-
try {
|
|
46
|
-
const artifactId = JSON.parse(value.content)?.artifactId;
|
|
47
|
-
if (artifactId) value.content = { artifactId };
|
|
48
|
-
} catch { /* Plain results use their original content. */ }
|
|
49
|
-
}
|
|
50
|
-
return value;
|
|
51
|
-
});
|
|
52
|
-
return createHash("sha256").update(stableStringify(identity)).digest("hex");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
37
|
function toolCalls(message = {}) {
|
|
56
38
|
return Array.isArray(message.tool_calls) ? message.tool_calls.map(call => call.id)
|
|
57
39
|
: Array.isArray(message.content) ? message.content.filter(block => block.type === "tool_use").map(block => block.id) : [];
|
|
@@ -90,4 +72,4 @@ function userInstruction(message = {}) {
|
|
|
90
72
|
return message.content.filter(block => block.type === "text").map(block => block.text || "").join("\n");
|
|
91
73
|
}
|
|
92
74
|
|
|
93
|
-
module.exports = { estimateTextTokens, estimateMessagesTokens, summaryMessage,
|
|
75
|
+
module.exports = { estimateTextTokens, estimateMessagesTokens, summaryMessage, historyUnits, userInstruction };
|
|
@@ -108,6 +108,10 @@ function normalizeContextMeter(value = null, model = "") {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
function isContextOverflow(error) {
|
|
112
|
+
return /context_length_exceeded|context_window_exceeded|maximum context|context (?:length|window|limit).*(?:exceed|too|limit)|(?:input|request).{0,40}exceeds?.{0,40}context|prompt.{0,40}too long|too many (?:input )?tokens/i.test(`${error?.code || ""} ${error?.message || ""}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
111
115
|
module.exports = {
|
|
112
116
|
toTokenCount,
|
|
113
117
|
contextTokensFromUsage,
|
|
@@ -116,4 +120,5 @@ module.exports = {
|
|
|
116
120
|
formatContextMeter,
|
|
117
121
|
buildContextMeter,
|
|
118
122
|
normalizeContextMeter,
|
|
123
|
+
isContextOverflow,
|
|
119
124
|
};
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function replayTurnMessages(request, event) {
|
|
4
|
+
const messages = [];
|
|
5
|
+
const result = event.result;
|
|
6
|
+
if (Array.isArray(result?.messages) && Number.isInteger(result.historyOffset)) {
|
|
7
|
+
messages.push(...result.messages.filter(message => message.role !== "system").slice(result.historyOffset));
|
|
8
|
+
} else {
|
|
9
|
+
messages.push({ role: "user", content: request?.text });
|
|
10
|
+
if (Array.isArray(result?.turnItems)) messages.push(...result.turnItems);
|
|
11
|
+
else if (result?.text) messages.push({ role: "assistant", content: result.text });
|
|
12
|
+
else messages.push({ role: "assistant", content: `Previous request ended ${event.type.split(".")[1]}: ${event.error || "no verified result"}` });
|
|
13
|
+
}
|
|
14
|
+
return messages;
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/** Derive full conversation inputs from accepted requests and terminal events. */
|
|
4
18
|
function replayHistory(events = [], excludeTask = "") {
|
|
5
19
|
const requests = new Map();
|
|
@@ -12,17 +26,9 @@ function replayHistory(events = [], excludeTask = "") {
|
|
|
12
26
|
for (const [id, request] of requests) {
|
|
13
27
|
const event = terminal.get(id);
|
|
14
28
|
if (id === excludeTask || !event) continue;
|
|
15
|
-
|
|
16
|
-
if (Array.isArray(result?.messages) && Number.isInteger(result.historyOffset)) {
|
|
17
|
-
history.push(...result.messages.filter(message => message.role !== "system").slice(result.historyOffset));
|
|
18
|
-
} else {
|
|
19
|
-
history.push({ role: "user", content: request.text });
|
|
20
|
-
if (Array.isArray(result?.turnItems)) history.push(...result.turnItems);
|
|
21
|
-
else if (result?.text) history.push({ role: "assistant", content: result.text });
|
|
22
|
-
else history.push({ role: "assistant", content: `Previous request ended ${event.type.split(".")[1]}: ${event.error || "no verified result"}` });
|
|
23
|
-
}
|
|
29
|
+
history.push(...replayTurnMessages(request, event));
|
|
24
30
|
}
|
|
25
31
|
return history;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
module.exports = { replayHistory };
|
|
34
|
+
module.exports = { replayHistory, replayTurnMessages };
|
|
@@ -32,7 +32,6 @@ function projectEvent(state, event) {
|
|
|
32
32
|
if (event.type === "runtime.opened" && !state.capabilities) state.capabilities = event.owner.capabilities;
|
|
33
33
|
if (event.type === "runtime.closed") state.owner = null;
|
|
34
34
|
if (event.type === "runtime.binding") state.binding = event.binding;
|
|
35
|
-
if (event.type === "context.checkpoint") state.contextCheckpoint = event.checkpoint;
|
|
36
35
|
if (event.type === "capability.state_committed") state.capabilityState[event.capabilityId] = { version: event.version, value: event.value };
|
|
37
36
|
if (event.type === "command.started") state.commands[event.commandId] = { ...event, status: "uncertain" };
|
|
38
37
|
if (event.type === "command.resolved") Object.assign(state.commands[event.commandId], { status: "resolved", result: event.result });
|
|
@@ -124,7 +124,7 @@ function createSessionJournal({ namespace = "runtime" } = {}) {
|
|
|
124
124
|
const artifactPreview = String(message.preview || (parsedArtifact && parsedArtifact.preview) || "").trim();
|
|
125
125
|
const payload = {
|
|
126
126
|
role,
|
|
127
|
-
content:
|
|
127
|
+
content: contentForStorage(message.content),
|
|
128
128
|
toolCalls: Array.isArray(message.tool_calls) ? message.tool_calls : undefined,
|
|
129
129
|
toolCallId: toolCallId || undefined,
|
|
130
130
|
artifactId: artifactId || undefined,
|