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.
Files changed (149) hide show
  1. package/README.md +224 -19
  2. package/README.zh-CN.md +3 -3
  3. package/bin/ucode.js +10 -2
  4. package/bin/ufoo.js +3 -0
  5. package/dist/tui/darwin-arm64/ufoo-tui +0 -0
  6. package/dist/tui/darwin-x64/ufoo-tui +0 -0
  7. package/dist/tui/linux-arm64/ufoo-tui +0 -0
  8. package/dist/tui/linux-x64/ufoo-tui +0 -0
  9. package/{OBSERVABILITY.md → docs/OBSERVABILITY.md} +3 -3
  10. package/docs/README.md +27 -0
  11. package/extensions/ufoo-browser/LICENSE +152 -0
  12. package/extensions/ufoo-browser/NOTICE +10 -0
  13. package/extensions/ufoo-browser/README.md +30 -0
  14. package/extensions/ufoo-browser/background.js +409 -0
  15. package/extensions/ufoo-browser/icons/icon-128.png +0 -0
  16. package/extensions/ufoo-browser/icons/icon-16.png +0 -0
  17. package/extensions/ufoo-browser/icons/icon-256.png +0 -0
  18. package/extensions/ufoo-browser/icons/icon-32.png +0 -0
  19. package/extensions/ufoo-browser/icons/icon-48.png +0 -0
  20. package/extensions/ufoo-browser/icons/logo.png +0 -0
  21. package/extensions/ufoo-browser/icons/toolbar-16.png +0 -0
  22. package/extensions/ufoo-browser/icons/toolbar-32.png +0 -0
  23. package/extensions/ufoo-browser/icons/toolbar-logo.png +0 -0
  24. package/extensions/ufoo-browser/manifest.json +30 -0
  25. package/extensions/ufoo-browser/popup.css +71 -0
  26. package/extensions/ufoo-browser/popup.html +44 -0
  27. package/extensions/ufoo-browser/popup.js +153 -0
  28. package/package.json +5 -3
  29. package/scripts/postinstall.js +6 -0
  30. package/src/agents/capabilities/browser/index.js +49 -0
  31. package/src/agents/capabilities/coding/backgroundHooks.js +94 -0
  32. package/src/agents/capabilities/coding/index.js +30 -1
  33. package/src/agents/capabilities/index.js +5 -2
  34. package/src/agents/capabilities/planning/index.js +44 -5
  35. package/src/agents/capabilities/turnRecall/index.js +341 -0
  36. package/src/agents/controller/controllerToolExecutor.js +2 -2
  37. package/src/agents/internal/internalRunner.js +30 -8
  38. package/src/agents/internal/taskControl.js +107 -0
  39. package/src/agents/profiles/coding.js +1 -1
  40. package/src/agents/profiles/main.js +1 -1
  41. package/src/agents/prompts/mainAgent.js +1 -0
  42. package/src/agents/prompts/native/toolDescriptions/bash.js +7 -1
  43. package/src/agents/providers/claudeSessionFiles.js +1 -1
  44. package/src/agents/providers/codexThreadProvider.js +6 -1
  45. package/src/agents/providers/credentials/agy.js +171 -0
  46. package/src/agents/providers/directAuthStatus.js +20 -2
  47. package/src/agents/providers/modelsCatalog.js +26 -5
  48. package/src/agents/providers/nativeTransport.js +36 -20
  49. package/src/agents/providers/providerId.js +17 -0
  50. package/src/agents/providers/runtimeConfig.js +26 -19
  51. package/src/agents/providers/transports/antigravityTransport.js +242 -0
  52. package/src/agents/providers/transports/index.js +1 -0
  53. package/src/agents/providers/transports/openaiChatTransport.js +3 -2
  54. package/src/agents/providers/transports/openaiResponsesTransport.js +2 -1
  55. package/src/agents/providers/transports/responsesProtocol.js +119 -18
  56. package/src/agents/providers/transports/transportContract.js +1 -0
  57. package/src/agents/providers/upstreamRuntime.js +3 -1
  58. package/src/agents/runtime/context/contextBudget.js +1 -19
  59. package/src/agents/runtime/context/contextWindow.js +5 -0
  60. package/src/agents/runtime/context/replayHistory.js +16 -10
  61. package/src/agents/runtime/context/runtimeStore.js +0 -2
  62. package/src/agents/runtime/context/sessionJournal.js +1 -1
  63. package/src/agents/runtime/context/slidingWindowManager.js +792 -0
  64. package/src/agents/runtime/context/topicSelector.js +338 -0
  65. package/src/agents/runtime/context/turnAnalyzer.js +767 -0
  66. package/src/agents/runtime/context/turnIndexStore.js +515 -0
  67. package/src/agents/runtime/core/agentLoop.js +95 -32
  68. package/src/agents/runtime/core/executionBudget.js +2 -1
  69. package/src/agents/runtime/core/toolErrorGuard.js +39 -0
  70. package/src/agents/runtime/createAgentRuntime.js +80 -7
  71. package/src/agents/runtime/index.js +5 -0
  72. package/src/agents/runtime/protocol/materialize.js +1 -1
  73. package/src/agents/runtime/tasks/hooks.js +137 -0
  74. package/src/app/chat/ChatController.js +8 -4
  75. package/src/app/chat/daemonMessageRouter.js +3 -1
  76. package/src/app/chat/inputSubmitHandler.js +2 -2
  77. package/src/app/chat/transport.js +1 -1
  78. package/src/app/cli/browserCommands.js +340 -0
  79. package/src/app/cli/features/doctor.js +21 -0
  80. package/src/app/cli/metricsCommands.js +1 -1
  81. package/src/app/cli/run.js +80 -1
  82. package/src/app/cli/setupCommands.js +200 -0
  83. package/src/code/UcodeController.js +31 -1
  84. package/src/code/agent.js +41 -7
  85. package/src/code/busConsumer.js +13 -12
  86. package/src/code/commands.js +0 -1
  87. package/src/code/context/assembler.js +11 -88
  88. package/src/code/context/planGraphService.js +83 -9
  89. package/src/code/context/planProjection.js +10 -2
  90. package/src/code/context/reducers.js +172 -4
  91. package/src/code/context/stateCommit.js +0 -32
  92. package/src/code/context/transcript.js +7 -4
  93. package/src/code/internalThread.js +9 -1
  94. package/src/code/launcher/ucode.js +4 -2
  95. package/src/code/nativeRunner.js +221 -10
  96. package/src/code/repl.js +27 -1
  97. package/src/code/runtime/agentWakeup.js +20 -3
  98. package/src/code/runtime/backgroundWakeHost.js +45 -0
  99. package/src/code/runtime/taskFocusContext.js +7 -0
  100. package/src/code/runtime/taskLoop.js +24 -1
  101. package/src/code/sessionStore.js +14 -10
  102. package/src/code/taskDecomposer.js +13 -7
  103. package/src/code/tools/backgroundProcess.js +23 -0
  104. package/src/code/tools/bash.js +764 -12
  105. package/src/code/tools/executor.js +12 -4
  106. package/src/code/tools/specs.js +60 -3
  107. package/src/code/tools/taskRun.js +38 -0
  108. package/src/config.js +92 -6
  109. package/src/coordination/bus/subscriber.js +1 -1
  110. package/src/coordination/history/agentPerformance.js +18 -18
  111. package/src/coordination/history/agentTrace.js +7 -3
  112. package/src/coordination/state/workspaceAccess.js +3 -1
  113. package/src/orchestration/groups/modelConfig.js +66 -0
  114. package/src/orchestration/groups/validateTemplate.js +2 -0
  115. package/src/runtime/browser/broker.js +1027 -0
  116. package/src/runtime/browser/brokerClient.js +108 -0
  117. package/src/runtime/browser/componentInstaller.js +275 -0
  118. package/src/runtime/browser/installState.js +329 -0
  119. package/src/runtime/browser/manifest.js +145 -0
  120. package/src/runtime/browser/native-host-runner.js +198 -0
  121. package/src/runtime/browser/nativeHost.js +213 -0
  122. package/src/runtime/browser/nativeMessagingProtocol.js +50 -0
  123. package/src/runtime/browser/paths.js +134 -0
  124. package/src/runtime/browser/playwrightSession.js +614 -0
  125. package/src/runtime/daemon/agentHost.js +175 -30
  126. package/src/runtime/daemon/busBridge.js +2 -1
  127. package/src/runtime/daemon/globalDaemon.js +20 -0
  128. package/src/runtime/daemon/groupOrchestrator.js +20 -1
  129. package/src/runtime/daemon/index.js +5 -4
  130. package/src/runtime/daemon/ops.js +14 -8
  131. package/src/tools/handlers/listAgents.js +1 -1
  132. package/src/tools/handlers/readBusSummary.js +1 -1
  133. package/src/tools/handlers/routeAgent.js +122 -5
  134. package/src/tools/schemaFixtures.js +1 -1
  135. package/src/ui/agentSurface.js +26 -3
  136. package/src/ui/format/index.js +34 -2
  137. package/src/ui/rustChatHost.js +22 -7
  138. package/src/ui/rustMultiSession.js +14 -2
  139. package/src/ui/rustUcodeHost.js +246 -77
  140. package/src/ui/ucodeAgentSession.js +88 -0
  141. package/templates/groups/build-lane.json +57 -3
  142. package/templates/groups/build-ultra.json +114 -6
  143. package/templates/groups/design-system.json +57 -3
  144. package/templates/groups/product-discovery.json +57 -3
  145. package/templates/groups/ui-plan-review.json +57 -3
  146. package/templates/groups/ui-polish.json +57 -3
  147. package/templates/groups/verify-ship.json +57 -3
  148. package/src/agents/runtime/context/checkpointStore.js +0 -52
  149. package/src/agents/runtime/context/compaction.js +0 -171
package/README.md CHANGED
@@ -47,8 +47,13 @@ Install the published package:
47
47
 
48
48
  ```bash
49
49
  npm install -g u-foo
50
+ ufoo setup
50
51
  ```
51
52
 
53
+ `ufoo setup` lets you choose whether to install the optional **ufoo Browser**
54
+ component (`ufoo setup --browser=install` or `--browser=skip`). Non-interactive
55
+ installs skip optional browser components by default.
56
+
52
57
  Or link this repository for local development:
53
58
 
54
59
  ```bash
@@ -296,7 +301,7 @@ A crash during an active round marks it interrupted: inspect actual
296
301
  effects before resubmitting. Writes, shell commands, launches, and uncertain
297
302
  deliveries are not automatically replayed. Managed writers share directory
298
303
  leases; verified git worktrees can run independently. These checks are not an OS
299
- sandbox for shell commands. See the [runtime implementation record](AGENT_RUNTIME_REFACTOR.md).
304
+ sandbox for shell commands. See the [runtime implementation record](docs/archive/AGENT_RUNTIME_REFACTOR.md).
300
305
 
301
306
  ### Chat Commands
302
307
 
@@ -325,8 +330,10 @@ sandbox for shell commands. See the [runtime implementation record](AGENT_RUNTIM
325
330
  ```
326
331
 
327
332
  The dashboard keeps three layouts: `main` (main agent only), `side` (main plus
328
- one selected internal agent), and `multi` (main plus all internal agents). Wrapper and MCP agents stay
329
- outside the dashboard. Dashboard child launches use internal mode and never
333
+ one selected internal agent), and `multi` (main plus all internal agents). Active
334
+ wrapper and MCP agents appear in the communication directory and `@` completion;
335
+ selecting one targets messages without opening a pane. Their detailed output
336
+ and process lifecycle stay with their own host. Dashboard child launches use internal mode and never
330
337
  open an external terminal. A project with no chat or input history shows the
331
338
  existing compact ufoo banner as its welcome screen.
332
339
  `Ctrl+W` cycles `main → side → multi → main`.
@@ -335,14 +342,23 @@ select each layout directly. The one-child layout selects the most recently
335
342
  activated live internal agent, or the first agent when none has been activated.
336
343
  With no children, split modes remain selected while showing only the full-width
337
344
  main pane; new children appear automatically when they become available.
338
- When the input has focus and contains text, `Ctrl+C` first clears the selected
339
- agent's draft without cancelling work or switching focus. `Esc` preserves the
340
- draft. In either split layout, both keys first leave the footer if it has focus,
341
- then return child focus to the main agent, then close the split. Running tasks
342
- are preserved while moving through these layers. Both keys also
343
- dismiss command completion and follow the main input's cancellation and project
344
- return layers. At the main-only root, `Esc` keeps the application open and only
345
- `Ctrl+C` exits. `Ctrl+Q` or `/window main` closes either split directly.
345
+ When an internal child owns the shared input, editing keys and shortcuts belong
346
+ to that child. `Ctrl+C` cancels only its current task, preserving its draft,
347
+ process and queued messages. `Esc` returns focus to the main input without
348
+ cancelling work; popup menus close before returning focus. `Ctrl+W` edits the
349
+ child's previous word and `Tab` inserts indentation. From the main input,
350
+ `Ctrl+W` cycles layouts and `Ctrl+Q` closes the split; main-only `Ctrl+C` clears
351
+ a nonempty draft before cancelling or exiting. `Esc` at the ufoo root preserves
352
+ the application and draft.
353
+ Standalone `ucode` uses the same side-pane implementation: clicking a footer
354
+ agent selects an `@` message target, and clicking it again opens an internal
355
+ agent on the right. Repeated selection of an external agent stays message-only.
356
+ Keyboard selection followed by empty Enter uses the same internal activation.
357
+ With focus on the Agents footer, `Ctrl+X` closes the selected internal agent
358
+ through its project daemon in both ufoo and ucode. External agents cannot be
359
+ closed from this menu. This differs from `Ctrl+C` in a child's input, which
360
+ cancels its current task while keeping the worker alive.
361
+ Restart existing internal workers to enable the per-task cancellation channel.
346
362
  Drag over visible text in the main or an internal agent pane to select it;
347
363
  releasing the mouse copies it to the clipboard. Selection stays within that pane,
348
364
  excluding its border and adjacent agents. Local macOS uses the system clipboard;
@@ -353,12 +369,12 @@ Selecting a group resumes its inactive members with saved sessions, skips member
353
369
  that are already active, and updates the group's member identities. Native
354
370
  coding agents register as `agent_type: ucode` with `ucode:<session>` identities;
355
371
  their saved conversations remain under `.ufoo/agent/ucode/`.
356
- `Tab` cycles keyboard focus through the main agent and the visible child panes;
357
- all agents share one bottom input, which follows the selected agent while
372
+ From main in a split layout, `Tab` enters a visible child. Once activated, only
373
+ `Esc` leaves its input. All agents share one bottom input, which follows the selected agent while
358
374
  preserving each draft. Each agent's live status sits in its pane's bottom border;
359
375
  the main agent's input is labelled `main`, and its status stays independent of
360
376
  child selection, focus changes and child activity.
361
- Internal Codex enables network access within its workspace sandbox, including
377
+ Internal Codex defaults to full host access without approval prompts, including
362
378
  local services such as ADB and Gradle. Peer replies contain the final answer;
363
379
  progress and tool output stay visible in the agent's pane. Reports and handoffs
364
380
  default to 1-4 short lines with checks and blockers; longer evidence is saved in
@@ -370,8 +386,9 @@ the main input. Command completion keeps its existing `Tab` behavior in the
370
386
  main-only layout. An open completion menu also owns `Tab` in split layouts.
371
387
  Layout commands also work from an internal child's input. Switching layouts
372
388
  keeps unsent child drafts and does not stop running agents.
373
- With a child active, `Down` from an empty input or a footer click opens the Agents
374
- selector. `Down` then opens provider settings and cron controls; `Esc` returns to
389
+ With a child active, a footer click opens the Agents selector in ufoo;
390
+ `Down` remains an editing key in the child input. In the footer selector,
391
+ `Down` advances to provider settings and cron controls; `Esc` returns to
375
392
  the same agent's input. In the selector, `Enter` opens the selected internal
376
393
  agent. The provider caption in the footer also opens its settings directly.
377
394
 
@@ -533,13 +550,63 @@ redacted; bounded or incomplete source reads are explicitly marked in JSON.
533
550
  errors/repetition, report size and delegation acceptance. Save a report and use
534
551
  `ufoo metrics --baseline baseline.json --json` to compare later samples. MCP
535
552
  provides `read_agent_metrics`; metric definitions and an optimization workflow
536
- are in [OBSERVABILITY.md](OBSERVABILITY.md). Missing evidence stays unknown,
553
+ are in [OBSERVABILITY.md](docs/OBSERVABILITY.md). Missing evidence stays unknown,
537
554
  and execution completion is separate from acceptance.
538
555
 
539
556
  ### Groups
540
557
 
541
558
  Built-in group templates live in `templates/groups/`.
542
559
 
560
+ Every member in all seven built-in groups includes three provider defaults plus a
561
+ manual override in `model_config`:
562
+
563
+ | Role | Codex model / reasoning effort | Claude model | agy model |
564
+ |---|---|---|---|
565
+ | Architect | `gpt-6-astra` / `high` | `claude-fable-5-2` | `gemini-4-carbon-high` |
566
+ | Builder | `gpt-6.1-sol` / `high` | `claude-opus-5-5` | `gemini-4-hydrogen-high` |
567
+ | Reviewer | `gpt-6.1-sol` / `xhigh` | `claude-opus-5-5` | `gemini-4-argon-high` |
568
+ | Design consultant, discovery facilitator, debugger | `gpt-6-astra` / `high` | `claude-fable-5-2` | `gemini-4-carbon-high` |
569
+ | PMO | `gpt-6-astra` / `high` | `claude-fable-5-2` | `gemini-4-argon-high` |
570
+ | Frontend refiner | `gpt-6.1-sol` / `high` | `claude-opus-5-5` | `gemini-4-hydrogen-high` |
571
+ | Scope challenger, UI plan critic, design critic, release coordinator | `gpt-6.1-sol` / `xhigh` | `claude-opus-5-5` | `gemini-4-argon-high` |
572
+ | QA | `gpt-6.1-sol` / `xhigh` | `claude-opus-5-5` | `gemini-4-hydrogen-high` |
573
+
574
+ Settings follow each member's prompt-profile role, including numbered builders.
575
+ Claude reasoning effort is left unset. All 24 built-in members have an empty
576
+ manual override ready to customize.
577
+ agy's selected model IDs include the thinking tier, so their separate
578
+ `reasoning_effort` defaults are empty. Carbon is reserved for architectural and
579
+ root-cause work, Argon for coordination and critical review, and Hydrogen for
580
+ implementation and verification.
581
+
582
+ For example, an architect member contains:
583
+
584
+ ```json
585
+ "model_config": {
586
+ "codex": { "model": "gpt-6-astra", "reasoning_effort": "high" },
587
+ "claude": { "model": "claude-fable-5-2", "reasoning_effort": "" },
588
+ "agy": { "model": "gemini-4-carbon-high", "reasoning_effort": "" },
589
+ "override": { "model": "", "reasoning_effort": "" }
590
+ }
591
+ ```
592
+
593
+ A nonempty `override.model` replaces the entire selected provider configuration;
594
+ an empty override effort does not inherit effort from any provider default.
595
+ Otherwise the member's provider selects `codex`, `claude` or `agy`. Empty model
596
+ settings keep the existing project/provider defaults. Overrides select a model,
597
+ not a different provider. Internal auto members under the agy provider run as
598
+ native ucode workers with explicit agy provider/model settings; external agy
599
+ members use the CLI's `--model` and optional `--effort` flags. Other native
600
+ provider settings remain unchanged when no matching model setting exists. Explicit
601
+ `type: "ucode"` members select defaults using their effective native provider
602
+ (`UFOO_UCODE_PROVIDER`, global `ucodeProvider`, then project `agentProvider`).
603
+ Codex maps to `codex`, Anthropic to `claude`, and agy to `agy`; manual overrides
604
+ also work with other native providers. Model, provider and effort are carried
605
+ through launch and resume. Project/global custom templates remain
606
+ authoritative over built-ins.
607
+ Dry runs and group state expose the selected model, effort and source. Recovery
608
+ preserves the saved selection; edits affect newly launched groups, not live workers.
609
+
543
610
  ```text
544
611
  /group templates
545
612
  /group template show build-lane
@@ -587,6 +654,110 @@ ufoo ucode build
587
654
  `ucode` can discover built-in and local `SKILL.md` workflow capabilities. Full
588
655
  skill bodies are loaded only when explicitly referenced.
589
656
 
657
+ ### Background Command Notifications
658
+
659
+ Native ufoo and ucode can continue automatically when a background command exits
660
+ or a condition is met. For example, the agent can start a development server with:
661
+
662
+ ```json
663
+ {
664
+ "command": "npm run dev",
665
+ "background": true,
666
+ "wake": {
667
+ "conditions": [{ "type": "log_contains", "text": "ready" }]
668
+ }
669
+ }
670
+ ```
671
+
672
+ Supported conditions are `log_contains` (literal `text`), `file_exists`
673
+ (workspace `path`), and `port_open` (a `port` on `127.0.0.1`). Each fires once;
674
+ exit notification is enabled by default and can be disabled with
675
+ `wake.onExit: false`. `wake.timeoutMs` bounds the subscription (default and
676
+ maximum 12 hours). Expiry sends one notification without stopping the command.
677
+
678
+ The host watches without model polling. Notifications continue the same session
679
+ after its current turn and any pending user question. Stopping the command or
680
+ cancelling its task revokes its watches. Pending watches survive host restart;
681
+ ucode must reopen the original session to resume delivery. Interrupted wake
682
+ invocations with uncertain effects are not automatically replayed. Inspect
683
+ `bash` with `action: "status"` and its `backgroundId` for delivery status.
684
+ One-shot command-line runs without a resident host do not provide auto-wake.
685
+
686
+ ### Your Everyday Chrome
687
+
688
+ The native project main agent, writable native child tasks, and `ucode` have a
689
+ shared `browser` tool powered by Playwright. It connects to an existing browser
690
+ and preserves its signed-in sessions; it never falls back to launching a fresh
691
+ profile. SDK-managed Codex/Claude wrappers keep their own tool configuration.
692
+
693
+ Browser automation requires Node.js 20 or newer (the ufoo core still supports
694
+ Node.js 18.17+).
695
+
696
+ ufoo Browser is an optional user-level component managed outside individual
697
+ projects (`~/.ufoo/browser/` and `~/.ufoo/config.json`):
698
+
699
+ ```bash
700
+ ufoo setup --browser=install # or interactive `ufoo setup`
701
+ ufoo browser status --json
702
+ ufoo browser doctor
703
+ ufoo browser enable | disable
704
+ ufoo browser update
705
+ ufoo browser uninstall
706
+ ```
707
+
708
+ During developer preview (before the Chrome Web Store listing is published),
709
+ register developer mode and load the unpacked extension from
710
+ `extensions/ufoo-browser/`:
711
+
712
+ ```bash
713
+ ufoo browser install --dev
714
+ ```
715
+
716
+ Once installed and enabled, the extension connects automatically via Chrome
717
+ Native Messaging to the user-scoped broker (`ufoo` and `ucode` share one
718
+ broker). Agents list tabs with `browser_tabs` (`action=list`) and claim tabs by
719
+ `tabId`; a tab already in use by another agent returns `browser_tab_busy`
720
+ without preemption. You can release individual tabs or pause all control from
721
+ the extension popup at any time.
722
+
723
+ Compatibility modes remain supported: set `backend: "playwright-extension"`
724
+ (with `UFOO_BROWSER_PROFILE` if needed) for the official
725
+ [Playwright Extension](https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm),
726
+ or use Chrome 144+ remote debugging (`chrome://inspect/#remote-debugging`):
727
+
728
+ ```bash
729
+ UFOO_BROWSER_CDP_ENDPOINT=chrome ucode
730
+ ```
731
+
732
+ You can also supply an existing `http://127.0.0.1:9222` or WebSocket endpoint.
733
+ An already-running daily Chrome does not automatically expose that port.
734
+ For the project main agent, set this environment variable when starting the
735
+ ufoo daemon; an existing daemon must be restarted to pick up changed settings.
736
+ CDP mode grants one ufoo/ucode session exclusive control until it disconnects,
737
+ because multiple clients would otherwise manipulate the same tabs. Other
738
+ applications and manual browser use are not covered by this lease.
739
+
740
+ The agent can list/select tabs, navigate, inspect snapshots, click/type, fill
741
+ forms, upload workspace files, handle dialogs, and take screenshots. Tool
742
+ operations also include screenshot-guided mouse clicks, dragging and scrolling
743
+ for canvas-based pages. Plan mode allows inspection only; browser actions run
744
+ through the direct capability, not synchronous `plan_graph` tool nodes. Tool
745
+ schemas are discovered on demand behind one stable model-facing tool. Page
746
+ content is data, not instructions; external actions stay within the user's
747
+ authorized task. Screenshot images are delivered to the model and saved under
748
+ `.ufoo/browser/`; long results include an `outputPath` for further reading.
749
+
750
+ `browser` supports `status`, `connect`, `tools`, `call`, and `disconnect`.
751
+ `tools` with a `tool` name returns its argument schema. A lost connection or
752
+ an action with an unknown outcome requires explicit reconnection and inspection,
753
+ not an automatic repeated click. Idle connections disconnect after ten minutes.
754
+ Disconnect releases control without closing Chrome or its existing tabs.
755
+
756
+ Browser setup instructions: [Playwright existing-browser connections](https://playwright.dev/mcp/configuration/browser-extension).
757
+ Developers can run the optional real-Chrome fixture with
758
+ `UFOO_TEST_BROWSER=1 npm test -- --runTestsByPath test/integration/browser-existing-chrome.test.js`;
759
+ it uses a disposable profile and a local test page, never the user's profile.
760
+
590
761
  ## Configuration
591
762
 
592
763
  Project configuration is stored in `.ufoo/config.json`. `ucode` provider
@@ -609,9 +780,15 @@ Common project settings:
609
780
  ```
610
781
 
611
782
  Internal Codex and Claude always use their SDKs; there is no thread-mode setting.
783
+ Internal Codex currently defaults to full host access (`danger-full-access`),
784
+ network enabled, and no approval prompts (`approvalPolicy: never`). It can access
785
+ simulators, system services and build caches outside the project with the current
786
+ OS user's permissions. Granular permissions and approval controls are deferred;
787
+ explicit SDK thread options still override these defaults. Relaunch existing
788
+ internal Codex workers after updating to apply the new policy.
612
789
 
613
790
  Supported `launchMode` values: `auto`, `internal`, `tmux`, `terminal`, and
614
- `host`. The dashboard supports internal Codex, Claude and ucode workers only; provider selections remain independent.
791
+ `host`. Dashboard panes and process management support internal Codex, Claude and ucode workers; provider selections remain independent. The `@` directory and main-agent communication also include active external agents. External agents receive messages through their own host and can return replies/reports, without exposing their terminal or detailed output in ufoo.
615
792
 
616
793
  The dashboard always uses internal children and has no `/mode` command;
617
794
  the binary has no `ufoo mode` command either.
@@ -620,6 +797,12 @@ and iTerm2 from their environment, then register the actual terminal type, TTY
620
797
  and delivery channels with the daemon. Their event-bus communication works
621
798
  without a dashboard. MCP agents communicate through MCP message interfaces
622
799
  without requiring a terminal adapter.
800
+ With the project daemon running, a registered worker can initiate contact with
801
+ `ufoo-agent` using `dispatch_message` or `ufoo bus send ufoo-agent "<message>"`
802
+ from its project and inherited worker identity. No prior delegation or open
803
+ chat window is required: the daemon durably accepts the message and wakes the
804
+ main runtime. Use this for substantive results, questions or changed blockers;
805
+ assigned task completion still requires a lifecycle report with its task ID.
623
806
  The main agent uses one runtime for coding and routing, configured by
624
807
  `agentProvider` and `agentModel`. `/settings agent` manages these settings;
625
808
  `/settings ucode` manages the independent ucode gateway settings.
@@ -643,6 +826,28 @@ Custom APIs use OpenAI Chat Completions by default, or Responses when the URL
643
826
  ends in `/responses`. There is no Anthropic protocol selector for custom APIs.
644
827
  Internal Claude retains its native provider transport and credentials.
645
828
 
829
+ #### Antigravity
830
+
831
+ Select `/provider agy` for the main agent, or run `ucode --provider agy` for
832
+ standalone coding. The default model is `gemini-4-carbon-high` and the
833
+ default auxiliary model is `gemini-4-hydrogen-high`. The native provider uses
834
+ the Antigravity Cloud Code API for streaming, tool calls, and
835
+ the `/model` catalog. Select a text model available to your account with
836
+ `/model`. If a session was created with the earlier `agy` setting, start a
837
+ fresh session to bind the Antigravity transport.
838
+
839
+ Sign in with `agy` once. ufoo reuses the local Antigravity login from the
840
+ macOS Keychain, Linux Secret Service, or the CLI's fallback auth file. macOS
841
+ may ask for permission to read the existing Keychain item. ufoo discovers
842
+ the Cloud Code project and asks `agy` to renew an expiring login.
843
+
844
+ To choose credentials explicitly, set `UFOO_AGY_AUTH_PATH` to your Antigravity
845
+ auth JSON from CLIProxyAPI, or set `UFOO_AGY_ACCESS_TOKEN`. Set
846
+ `UFOO_AGY_PROJECT_ID` to override project discovery. For the main agent, these
847
+ variables must be available to the ufoo daemon when it starts.
848
+ `UFOO_AGY_BASE_URL` overrides the Cloud Code base URL. `UFOO_AGY_USER_AGENT`
849
+ overrides the Antigravity client header if the endpoint requires a newer version.
850
+
646
851
  Ordinary provider sessions authenticate through their provider-owned adapters;
647
852
  MCP `agent_handle` is never model authentication. Standalone and internal ucode
648
853
  use the independent gateway settings below.
@@ -675,7 +880,7 @@ src/
675
880
  online/ relay client/server/runner/token helpers
676
881
  ```
677
882
 
678
- See [PROJECT.md](PROJECT.md) for the maintainer-facing map and detailed package
883
+ See [PROJECT.md](docs/PROJECT.md) for the maintainer-facing map and detailed package
679
884
  ownership.
680
885
 
681
886
  Reports share one task ID across lifecycle phases. Pass `--task <id>` to
package/README.zh-CN.md CHANGED
@@ -214,7 +214,7 @@ ufoo -g
214
214
  interrupted,需检查实际结果后决定是否重新提交;不会自动重复文件修改、shell、
215
215
  启动或投递。相同目录的托管写操作共用锁,独立且经过验证的 git worktree 可并行。
216
216
  这些约束不构成 shell 的操作系统沙箱。实现与恢复契约见
217
- [Agent Runtime 改造记录](AGENT_RUNTIME_REFACTOR.md)。
217
+ [Agent Runtime 改造记录](docs/archive/AGENT_RUNTIME_REFACTOR.md)。
218
218
 
219
219
  ### Chat 内命令
220
220
 
@@ -392,7 +392,7 @@ Decision 只用于计划级约束;长期项目事实应写入 memory。
392
392
  `ufoo metrics --json` 汇总执行结果、耗时、tokens、工具错误/重复、报告长度
393
393
  与委派验收。保存报告后,可用 `ufoo metrics --baseline baseline.json --json`
394
394
  对比后续样本。MCP 提供 `read_agent_metrics`;指标口径和优化流程见
395
- [OBSERVABILITY.md](OBSERVABILITY.md)。缺失证据保留 unknown,执行完成与
395
+ [OBSERVABILITY.md](docs/OBSERVABILITY.md)。缺失证据保留 unknown,执行完成与
396
396
  验收通过分开统计。
397
397
 
398
398
  report 和 agent 交接默认使用 1–4 行短消息,包含结果、改动、检查和阻塞;
@@ -530,7 +530,7 @@ src/
530
530
  online/ relay client/server/runner/token helpers
531
531
  ```
532
532
 
533
- 维护者视角的项目地图见 [PROJECT.md](PROJECT.md),更细的目录 ownership 见
533
+ 维护者视角的项目地图见 [PROJECT.md](docs/PROJECT.md),更细的目录 ownership 见
534
534
  [docs/source-structure.md](docs/source-structure.md)。
535
535
 
536
536
  ## 开发
package/bin/ucode.js CHANGED
@@ -15,6 +15,7 @@ const AgentLauncher = require("../src/agents/launch/launcher");
15
15
  const { resolveUcodeLaunch } = require("../src/code/launcher/ucode");
16
16
  const { prepareUcodeBootstrap } = require("../src/code/launcher/ucodeBootstrap");
17
17
  const { prepareUcodeRuntimeConfig } = require("../src/code/launcher/ucodeRuntimeConfig");
18
+ const { maybeRunFirstTimeSetup } = require("../src/app/cli/setupCommands");
18
19
 
19
20
  // CLI-wrapper startup text belongs to the parent agent. Native ucode loads
20
21
  // its own system prompt; do not inject or pass the parent's text to its tools.
@@ -175,5 +176,12 @@ if (mode !== "always" && bootstrapFile && !fs.existsSync(bootstrapFile) && !pres
175
176
  }
176
177
  }
177
178
 
178
- const launcher = new AgentLauncher(resolved.agentType, resolved.command);
179
- launcher.launch(resolved.args);
179
+ (async () => {
180
+ try {
181
+ await maybeRunFirstTimeSetup({ surface: "ucode", argv: cleanArgs });
182
+ } catch {
183
+ // First-run setup must never block launching ucode
184
+ }
185
+ const launcher = new AgentLauncher(resolved.agentType, resolved.command);
186
+ launcher.launch(resolved.args);
187
+ })();
package/bin/ufoo.js CHANGED
@@ -6,6 +6,7 @@ const { runMcpServer } = require("../src/runtime/daemon/mcpServer");
6
6
  const { runChat } = require("../src/app/chat");
7
7
  const { runInternalRunner } = require("../src/agents/internal/internalRunner");
8
8
  const { resolveGlobalControllerProjectRoot } = require("../src/runtime/projects");
9
+ const { maybeRunFirstTimeSetup } = require("../src/app/cli/setupCommands");
9
10
 
10
11
  const rawArgv = process.argv.slice(2);
11
12
 
@@ -40,6 +41,7 @@ async function main() {
40
41
  const chatProjectRoot = globalMode ? resolveGlobalControllerProjectRoot() : process.cwd();
41
42
 
42
43
  if (!cmd) {
44
+ await maybeRunFirstTimeSetup({ surface: "ufoo", argv: rawArgv });
43
45
  await runChat(chatProjectRoot, { globalMode });
44
46
  return;
45
47
  }
@@ -75,6 +77,7 @@ async function main() {
75
77
  return;
76
78
  }
77
79
  if (cmd === "chat") {
80
+ await maybeRunFirstTimeSetup({ surface: "ufoo", argv: rawArgv });
78
81
  await runChat(chatProjectRoot, { globalMode });
79
82
  return;
80
83
  }
Binary file
Binary file
Binary file
Binary file
@@ -35,8 +35,8 @@ MCP 提供只读 `read_agent_metrics`;`read_agent_trace` 的结果及 JSONL fo
35
35
  | 模型 | 主模型调用、SDK turns、失败、空回复重试、上下文溢出重试、自动续跑 | SDK 内部 HTTP 次数不可见,不推算。模型阶段与工具阶段累计耗时是服务时间,不能当作互不重叠的总耗时分解。 |
36
36
  | 工具 | 执行、错误、执行异常、校验拒绝、未配对调用、相同工具参数重复、loop guard 警告/停止 | 执行异常单独计数并保留副作用未知的状态。同参数重复是调查线索,合法轮询或重读也可能重复。进行中的工具及等待用户的工具可以暂时未配对;这不等于失败。 |
37
37
  | 用量 | input、output、cacheRead、cacheCreation | 按已有 provider 解析器的字段语义分别汇总,不把 SDK/API 数据或缓存字段重复相加。未回传 usage 不按零计算。部分回传仅汇总可见部分,并标出完整用量覆盖率;不估算费用。 |
38
- | 缓存 | cache.hitRate、cachedTokens、promptTokens、样本和完整覆盖率 | 按 tokens 加权:命中 tokens 总量 / 同批样本的输入总量。OpenAI 的输入总量已含缓存;Anthropic 的分母为 input + cacheRead + cacheCreation。缺少缓存字段或无法确定输入口径的样本不参加缓存率计算;明确回传 cached_tokens=0 才能作为零命中样本。压缩缓存另列 compactionCache。 |
39
- | 压缩 | 尝试、完成、失败、耗时、压缩调用用量 | 压缩用量单独放在 compactionUsage,避免藏在主模型用量里。 |
38
+ | 缓存 | cache.hitRate、cachedTokens、promptTokens、样本和完整覆盖率 | 按 tokens 加权:命中 tokens 总量 / 同批样本的输入总量。OpenAI 的输入总量已含缓存;Anthropic 的分母为 input + cacheRead + cacheCreation。缺少缓存字段或无法确定输入口径的样本不参加缓存率计算;明确回传 cached_tokens=0 才能作为零命中样本。 |
39
+ | 上下文 | contextSelections、windowProjections、maxEvictionLevel、contextSelectMs | 记录话题召回次数与耗时、滑动窗口投影次数及触发的最高水位退让等级(0~3)。 |
40
40
  | 协作 | 委派数、报告数、待验收、accepted、rejected、投递不确定、报告到验收延迟 | acceptedOfReviewed = accepted / (accepted + rejected);没有验收样本时为 null。不会用 done 报告代替 accepted。 |
41
41
  | 输出 | 流式文字量、最终回复长度、报告长度 | 按 Unicode 字符计数;报告超过协议默认 600 字符会出现 long_report 线索。最终回复与过程流分开计数。 |
42
42
  | 活动 | 最后事件距今时间、队列年龄 | running 五分钟无可见事件会标出线索;模型/SDK 可能仍在工作,不自动判定卡死。排队耗时只来自 request.accepted 或精确匹配的 bus sequence。 |
@@ -49,7 +49,7 @@ Provider/model、thinking、版本、执行引擎指纹、请求类型形成 coh
49
49
 
50
50
  1. 选一组固定的开发任务,保存任务说明、仓库起点、预期产物和验证命令;同时覆盖直接编码、委派、group、错误纠正和长会话。
51
51
  2. 固定模型、thinking、凭据来源和任务环境;运行后保存 metrics JSON、精确任务的 trace,以及代码 diff 和验证结果。
52
- 3. 一次改一个变量,例如系统提示词、路由策略、报告约束或压缩策略;复跑同一任务集。
52
+ 3. 一次改一个变量,例如系统提示词、路由策略、报告约束或上下文窗口策略;复跑同一任务集。
53
53
  4. 对比验收、错误和重复行为,再看耗时、用量及输出长度;同时人工检查真实产物。快、少 tokens 或短报告本身不代表质量提高。
54
54
 
55
55
  `--baseline` 输出指标差值和变化比例;不同任务、样本量、模型或不完整来源可能影响结果,因此它是观测差异,不是因果结论。没有真实质量评分或独立验收的数据,不生成质量评分。
package/docs/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Documentation
2
+
3
+ Current behavior is documented in the root [README](../README.md) and
4
+ [Chinese README](../README.zh-CN.md).
5
+
6
+ ## Maintained references
7
+
8
+ - [Project guide and source ownership](PROJECT.md)
9
+ - [Agent observability, metrics and tracing](OBSERVABILITY.md)
10
+ - [Delivery queue developer guide](delivery-queue-developer-guide.md)
11
+ - [External MCP client examples](mcp-client-examples.md)
12
+ - [MCP bridge implementation and remaining backlog](daemon-mcp-integration-plan.md)
13
+ - [Contributor and agent instructions](../AGENTS.md)
14
+
15
+ ## Archived implementation records
16
+
17
+ These plans have landed in the current codebase. They are retained as design
18
+ history, not as a backlog or a guarantee that every optional proposal shipped.
19
+ Current support and limits belong in the maintained references above.
20
+
21
+ - [Shared agent runtime migration](archive/AGENT_RUNTIME_REFACTOR.md)
22
+ - [Agent Runtime V2 and context engine](archive/AGENT_RUNTIME_V2_DESIGN.md)
23
+ - [Optional browser extension](archive/BROWSER_EXTENSION_PLAN.md)
24
+ - [Grok Build provider V2](archive/GROK_PROVIDER_V2.md)
25
+
26
+ The browser extension's store publication and Grok OAuth/ACP follow-ups remain
27
+ outside those implemented scopes; consult the current README before use.
@@ -0,0 +1,152 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the Work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the Work
38
+ (which shall not include communications that are clearly marked or
39
+ otherwise designated in writing by the Licensor as "Not a Work").
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the Licensor as "Not a Work".
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to retain prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright notices, patent notices,
103
+ trademark notices, and attribution notices from the Source
104
+ form of the Work, excluding those notices that do not
105
+ pertain to any part of the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a copy of that NOTICE file, except with respect to
110
+ attribution notices that do not pertain to any part of the
111
+ Derivative Works.
112
+
113
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
114
+ any Contribution intentionally submitted for inclusion in the Work
115
+ by You shall be under the terms and conditions of this License,
116
+ without any additional terms or conditions. Notwithstanding the above,
117
+ nothing herein shall supersede or modify the terms of any separate
118
+ license agreement you may have executed with Licensor regarding
119
+ such Contributions.
120
+
121
+ 6. Trademarks. This License does not grant permission to use the trademarks
122
+ or trade names of the Licensor, except as required for reasonable and
123
+ customary use in describing the origin of the Work and reproducing the
124
+ content of the NOTICE file.
125
+
126
+ 7. Disclaimer of Warranty. Unless required by applicable law or
127
+ agreed to in writing, Licensor supplies the Work (and each
128
+ Contributor supplies its Contributions) on an "AS IS" BASIS,
129
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
130
+ implied, including, without limitation, any warranties or conditions
131
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
132
+ PARTICULAR PURPOSE. You are solely responsible for determining the
133
+ appropriateness of using or redistributing the Work and assume any
134
+ risks associated with Your exercise of permissions under this License.
135
+
136
+ 8. Limitation of Liability. In no event and under no legal theory,
137
+ whether in tort (including negligence), contract, or otherwise,
138
+ unless required by applicable law (such as deliberate gross
139
+ negligence) or agreed to in writing, shall any Contributor be liable
140
+ to You for damages, including any direct, indirect, special,
141
+ incidental, or consequential damages of any kind arising out of this
142
+ use or inability to use the Work (including but not limited to damages
143
+ for loss of business profits, business interruption, loss of business
144
+ information, or any other pecuniary loss).
145
+
146
+ 9. Accepting Warranty or Additional Liability. While redistributing
147
+ the Work or Derivative Works thereof, You may choose to offer,
148
+ and charge a fee for, acceptance of support, warranty, indemnity,
149
+ or other liability obligations and/or rights consistent with this
150
+ License. However, in accepting such obligations, You may act only
151
+ on Your own behalf and on Your sole responsibility, not on behalf
152
+ of any other Contributor.
@@ -0,0 +1,10 @@
1
+ Ufoo Chrome Extension
2
+
3
+ Based on the Chrome extension CDP-bridge architecture pioneered by Microsoft Playwright
4
+ (`packages/extension`, Apache-2.0 License).
5
+
6
+ Copyright (c) Microsoft Corporation (original Playwright extension protocol and debugger bridge design).
7
+ Modifications for Ufoo (Native Messaging auto-discovery, per-session tab ownership,
8
+ and Ufoo control panel) Copyright (c) ufoo Contributors.
9
+
10
+ Licensed under the Apache License, Version 2.0. See LICENSE for full terms.