Commit Graph
66 Commits
Author SHA1 Message Date
lsdsjy 3be1ea10b9 refactor(headless): move the runner process hooks out of the package entry
Address the Code Entropy follow-up on d9c4f53758: the runner entry still
expanded its process-substitution object with a `readStdin` hook used only by
tests. Move that seam to `src/runner-internals.ts`, mirroring
`src/startup-internals.ts`, so neither entry grows package API for tests.
2026-09-10 19:13:05 +08:00
lsdsjy 40dc25fe1d Merge remote-tracking branch 'origin/master' into HEAD 2026-09-10 17:32:26 +08:00
lsdsjy 6d05765405 refactor(headless): keep the startup process seam out of the public entry
Address the Code Entropy finding on f67d722243: the `./startup` entry exported
`internals` only so tests could substitute process facts, which added avoidable
package API. Move the seam to `src/startup-internals.ts`, which no package
export names, and have the provider and its tests import it from there.
2026-09-10 17:29:15 +08:00
lsdsjy 9b330b653f docs(headless): correct the adopt-only wording and lockfile attribution
Address the ds-review-bot suggestions on 4099b84ee8:

- The post-resume comment scopes the write lease to other processes, so it no
  longer contradicts the post-idle re-check that defends against a same-process
  overlay writer.
- The Agent Note attributes `pnpm-lock.yaml` to the new
  `@deepseek-ai/dsh-session-query` workspace link instead of the shared chunk,
  which `scripts/check-workspace-constraints.ts` and the manifest publish.
- The package summary keeps "leaves nothing running behind", so it does not
  imply the runner leaves no persisted Session behind.
2026-09-10 16:52:43 +08:00
lsdsjy ef34e9d888 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-10 16:42:31 +08:00
lsdsjy 31be030ccc fix(headless): keep --json stderr free of commander's error print
Address the ds-review-bot findings on 8724223621:

- The JSON error override throws commander's control-flow error instead of
  delegating to `program.error`, whose own printer wrote an unprefixed
  `error: …` line to stderr and broke the documented `--json` contract.
- Cover the post-idle adoptability re-check with a focused case: an overlay that
  appends a preset while the runner awaits idle is still rejected, and the stale
  "live Session" comment now names that residual writer.
- Scope the Agent Note change sentence to the product change so it no longer
  claims the whole patch is confined to one package.
2026-09-10 16:25:19 +08:00
lsdsjy 9098a58f94 refactor(loader-smoke): model the smoke cwd as a discriminated input
Address the review suggestion that a caller-provided `cwd` left
`tempDirPrefix`/`tempDirParent` as dead but still-required inputs. The options
are now a union of "expand a prefix into a fresh temporary cwd" and "reuse this
existing directory", so the type system rejects passing both; the two callers
that reuse a directory drop their unused prefix.
2026-09-10 16:03:46 +08:00
lsdsjy 8d56babe15 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-10 16:01:12 +08:00
lsdsjy 9bcb1e214c fix(headless): refuse a live Agent identity and finish the adopt-only docs
Address the ds-review-bot findings on 472554a29e:

- resolveAgent refuses an Agent already live under the requested id: its owner
  may still drive it, and `whenIdle` is not a single-message signal, so the
  one-shot runner cannot own an exclusive run interval over it. The adoptability
  rules still run first so the refusal stays specific.
- Refresh the README intro, identity section, and limitations, and the Agent
  Note live-identity rule and change scope, for adopt-only.
- Clarify the loader-smoke `cwd` JSDoc (the prefix/parent inputs are ignored)
  and pin the resumed wake's final text in the two-wake e2e.
2026-09-10 16:00:53 +08:00
lsdsjy f0724ba7e8 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-10 15:54:21 +08:00
lsdsjy 249d583892 feat(web): add hours to turn duration labels
Turns running at or past 3600s now read 1小时05分03秒 / 1h 05m 03s in the
running clock, the settled Ran-for footer, and the turn-time dialog, which
share formatRunDuration. Below an hour the second and minute branches are
unchanged, and the hour rolls at the unit boundary so 60分00秒 never appears.
2026-09-10 15:51:43 +08:00
lsdsjy 349a84e81d Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-10 15:31:53 +08:00
lsdsjy 127d2c8eb5 fix(headless): align the adopt-only docs and prove resume end to end
Address the ds-review-bot findings on 9aea4b0804:

- Drop the stale "freshly created" wording from the resolveAgent `@returns`
  and rewrite its leading comment for the two remaining identity paths.
- Rewrite the README run-flow paragraph (EN and ZH), the intro sentence, and
  the cordis.patch.yml header comment for adopt-only.
- Add a real-composition two-wake e2e: capture the generated id from the first
  `--json` wake, resume it by `--session-id`, and assert one persisted log holds
  both tasks. `runLoaderSmoke` gains an optional caller-owned `cwd` so both
  wakes share one world; the harness leaves that directory in place.
2026-09-10 15:19:17 +08:00
lsdsjy ea84ad31b6 feat(headless): require --session-id to name an existing Session
`--session-id` now adopts only: an id with no stored Session fails before the
task runs instead of creating an empty history the caller believes it is
resuming. A first round omits the flag, and the runtime reports the minted
`session-<uuid>` identity in the opening `session` event, so a supervisor
persists it and names it on every later wake.

Updates the help text, the README pair, the Agent Note pair, the generated
config catalog, the unit suite, and the product-profile e2e.
2026-09-10 14:44:44 +08:00
lsdsjy 25f95302fd Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run
# Conflicts:
#	packages/bundle/headless/README.i18n.yaml
#	packages/bundle/headless/README.zh.md
2026-09-10 14:20:35 +08:00
lsdsjy a69933d3e5 fix(headless): omit step usage when any attempt lacks a sample
Address the ds-review-bot v12 critical on PR #3849: `addUsage` published the
sum of the attempts that reported usage while silently dropping the ones that
did not, so `step_end.usage` looked exact but under-counted billed tokens.
Track completeness per step and omit usage entirely when any attempt in the
step reports no sample, matching `deriveTurnTokenUsage`'s fail-closed rule.
2026-09-09 21:05:19 +08:00
lsdsjy 980b4b77af fix(headless): close the v11 review gaps in the json run surface
Address the ds-review-bot v11 review on PR #3849:

- Accumulate every attempt's usage into `step_end.usage`, including a retried
  attempt whose only sample sits in its discarded `assistant/attempt` stream.
- Re-check the adopted Session after the idle wait, so a preset selected in
  that window is still rejected.
- Reject a whitespace-only `sessionId` supplied through a Cordis overlay, which
  bypasses the CLI trim check.
- Narrow the documented error contract: a profile whose own plugins fail to
  load exits before the runner mounts and keeps only stderr diagnostics.
2026-09-09 20:46:16 +08:00
lsdsjy b3f6c5e991 fix(headless): count the line terminator inside the 32 KiB event cap
Address the ds-review-bot v10 review on PR #3849: `boundJsonLine` bounded the
serialized JSON but not the newline the writer appends, so an event that
serialized to exactly 32 KiB produced a 32 KiB + 1 byte record. Reserve the
terminator byte inside the cap, document the cap as newline-inclusive, and
assert the written record length in the boundary tests.
2026-09-09 20:16:58 +08:00
lsdsjy 755b44bbcd fix(headless): require the query service for every --session-id run
Address the ds-review-bot v9 review on PR #3849:

- Require `sessionQuery` before the live fast path too: a later process has no
  live Agent and must find the id through the query service, so a live identity
  no longer bypasses the check.
- Soften the live `stat` comment to what it proves: a stored record rules out an
  in-memory registration, while write-handle ownership is not queryable.
- Complete the `parseArguments` JSDoc and fix the broken English sentence in
  README.md and the Agent Note.
2026-09-09 19:53:03 +08:00
lsdsjy 7a4a55f30b fix(headless): fail closed on malformed preset records and unroundtrippable args
Address the ds-review-bot v6 review on PR #3849:

- A persisted `agent-preset/selected` record whose `data.agentPreset` is not a
  non-empty string used to read as "no preset", letting the run continue under
  this bundle's composition. It now fails closed.
- A live identity now has to be known to `sessionPersistence` (`stat`), since
  an Agent registered only in memory has no write handle and would flush
  nothing.
- Tool arguments that JSON cannot round-trip (an overflowing number such as
  `1e400`) keep their raw text instead of the `null` JSON.stringify reports.
2026-09-09 19:39:31 +08:00
lsdsjy a5c21a69b8 fix(headless): require persistence for every --session-id path
Address the ds-review-bot v6 review on PR #3849: the guard sat before the
create branch only, so adopting an already-live identity could still run a
session whose history dies at exit. Move it to the top of resolveAgent, where
it covers both the live and the create path, and add a rejection test for the
live path alongside the existing create-path one.
2026-09-09 19:17:01 +08:00
lsdsjy 97e4565a04 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-09 19:01:51 +08:00
lsdsjy b3756a89d1 fix(headless): fail loud when --session-id would create a non-durable session
Address the ds-review-bot v6 review on PR #3849:

- Require the composed sessionPersistence service before creating an exact
  --session-id identity, so a profile that keeps sessionQuery but drops
  persistence exits 1 instead of printing an id whose history dies at exit.
- Stop exporting the now-internal boundJsonEvent and describe it in the
  present tense; its test now exercises boundJsonLine.
- Say "64 levels or deeper" in the README and Agent Note, matching the
  depth budget (an input keeps 63 nested containers, the 64th is cut).

Tests: 77 headless unit tests with per-file 100% coverage on src, 14 profile
e2e tests, constraints/typecheck/lint/doc/pairing gates.
2026-09-09 19:00:06 +08:00
lsdsjy a6fa383ba8 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-09 18:34:16 +08:00
lsdsjy d2dc505830 ci: re-trigger the pull-request run after the superseded run was dropped 2026-09-09 18:28:34 +08:00
lsdsjy 3488db77bf fix(headless): cap the bounding recursion depth and route error events through the line cap
Address the ds-review-bot v6 review on PR #3849:

- Cut a projected payload nested deeper than 64 levels instead of recursing
  until the stack overflows; the isolated session listener would otherwise
  drop the `tool_call` silently.
- Write both `error` events (startup usage errors and runner failures) through
  `boundJsonLine`, so the documented 32 KiB line cap covers JSON-escaping
  expansion as well as the 8 KiB message cap.

Tests: 76 headless unit tests with per-file 100% coverage on src, 14 profile
e2e tests, constraints/typecheck/lint/doc/pairing gates.
2026-09-09 18:06:29 +08:00
lsdsjy 0ca42f3b78 fix(headless): bound whole events, re-check adoption after resume, tighten --json scan
Address the ds-review-bot v5/v6 review on PR #3849:

- Register the shared `lib/json-stream-*.js` chunk in `packageFileExtras` and
  order `files` as the workspace-constraints gate requires, so
  `pnpm run constraints` passes.
- Re-validate the preset on the Session `agents.resume` actually attached,
  closing the TOCTOU window between `observeSession` and the write lease.
- Bound one serialized event line at 32 KiB: an over-long event keeps its
  scalar fields, drops structured ones, and at the extreme reduces to `type`.
- Normalize an empty tool-argument string to `{}`, matching the executor.
- Scan only real `--json` flags (stop at `--`, skip a `--session-id` value)
  before installing the JSON error override.

Tests: 74 headless unit tests with per-file 100% coverage on src, 14 profile
e2e tests, constraints/typecheck/lint/doc/pairing gates, tarball import smoke.
2026-09-09 17:40:47 +08:00
lsdsjy 3797127eb2 fix(headless): publish the shared chunk and read the session's current preset
Address the ds-review-bot v6 review on PR #3849:

- Publish the `lib/json-stream-*.js` chunk that both entry points import.
  Without it the installed tarball failed to load with ERR_MODULE_NOT_FOUND,
  because `files` listed only `lib/index.js` and `lib/startup.js`.
- Resolve a Session's preset from its log (`agent-preset/selected`) instead of
  only the immutable creation header, so a Session that switched preset while
  blank is rejected too. Both the persisted and the live path scan the events.
- Write the `--json` error event for Commander grammar rejections (an unknown
  option, a missing option value) as well as the action's own usage errors, and
  drop Commander's `error: ` prefix from the event message so one event type
  carries one message shape.
- Reject a whitespace-only positional instead of falling back to stdin, so an
  accidental blank argument cannot consume a pipe.
- Document the stdin task as verbatim and the widened usage-error contract.

Tests: 68 headless unit tests with per-file 100% coverage on src, 14 profile
e2e tests, plus a packed-tarball import smoke check.
2026-09-09 17:16:09 +08:00
lsdsjy 45032ea1bd fix(headless): address re-review findings on the machine-readable run surface
- Reject adopting a Session recorded under an agent preset, and one that
  recorded no cwd; align the subagent/forked diagnostic wording.
- Write the bounded JSON `error` event for a --json usage error before exit,
  since the runner never mounts to write it.
- Keep the caller's exact --session-id instead of the trimmed value.
- Bound object keys and copy a literal `__proto__` key as data rather than
  through the inherited setter.
- Reject a lone `-` mixed with other task words.
- Document the in-turn failure contract and step-commit text/thinking timing.
2026-09-09 16:58:24 +08:00
lsdsjy 94d3273c19 Merge remote-tracking branch 'origin/master' into turtle/issue-3848-headless-machine-readable-run 2026-09-09 15:54:26 +08:00
lsdsjy ba6e19809d fix(headless): project committed content and scope live adoption 2026-09-09 15:51:23 +08:00
lsdsjy 8662afb530 docs(headless): regenerate module graph for the run projection 2026-09-09 15:31:24 +08:00
lsdsjy 0e7361a489 test(headless): close per-file coverage on the run projection 2026-09-09 15:19:52 +08:00
lsdsjy d5fe1fb887 docs(headless): regenerate event producer graph and restore model-selection note 2026-09-09 15:17:01 +08:00
lsdsjy ba6a90d2f2 feat(headless): add stdin task, --session-id, and --json run events 2026-09-09 15:12:32 +08:00
lsdsjy 5b8c8b781f test(open-in-app): scope SSH snapshot to the session header 2026-09-08 12:43:55 +08:00
lsdsjy a8d960ecb6 Merge master into fix/open-in-app-ssh 2026-09-08 11:37:46 +08:00
lsdsjy 7f47954cad fix(open-in-app,directory-picker): share inherited SSH detection 2026-09-08 11:32:36 +08:00
lsdsjy 5e19460c28 docs(notes): sync the continuable-subagent Send clause and tighten the label-state enumerations
The 2026-08-06 continuable-subagent interrupt note said the child's Send
always queued; it now names the busy-Enter delivery and cross-links the
busy Send button note, which links back. The new note's and bench's
plain-Send enumerations now exclude the ordinary running empty/blocked
draft, whose seat is Stop.
2026-09-07 21:43:55 +08:00
lsdsjy 4a89178785 fix(open-in-app): hide workspace app actions over SSH 2026-09-07 21:14:19 +08:00
lsdsjy 2cb684c754 test(web): pin the failed-upload Send label and document the bench mirror scope 2026-09-07 20:56:34 +08:00
lsdsjy 8935c3d725 fix(web): keep plain Send while a file upload is pending
Review follow-up: the mode label predicate now includes !uploadsPending,
so a running draft whose file is still uploading (or failed) keeps the
plain Send label on its disabled button, matching the documented
'enabled button' condition. Test pins pending vs ready upload states;
the Agent Note and README pair name the upload gate.
2026-09-07 20:43:12 +08:00
lsdsjy 2f630626b8 fix(web): name the running Send mode only for a plain message draft
Review follow-up. The mode label predicate lacked `!empty`, so a running
continuable child with an empty draft showed a disabled "Queue message";
and a claimed slash command or a `/` line headed for adjudication executes
a command rather than delivering a message, so naming Queue/Steer there
misdescribed the click. The label now names the mode only when the click
would deliver a plain message: running, steer-capable, enabled, non-empty,
unclaimed, and not a `/` line. Tests pin the empty-draft child, the slash
line, and the claimed command; the Agent Note, README pair, and
ComposerKeyboard.submit JSDoc state the exact predicate.
2026-09-07 19:33:20 +08:00
lsdsjy 9a5ed6fb60 fix(web): make the running Send button follow the busy-Enter setting
The ui-conversation.busyEnter setting selected Queue or Steer for plain
Enter only; the running draft's Send button always submitted through the
public InputActions.submit() face, which is fixed to Queue, while labeled
"Send message". A user who chose Steer got Steer from Enter and Queue
from the button beside the same draft with nothing explaining why.

InputBar now resolves the primary click through the same `enter` gesture
and steer-availability predicate as the keyboard path (ordinary Sessions
and continuable children) and submits via ComposerKeyboard.submit(mode).
While that delivery is available the button's tooltip and accessible name
state it ("Queue message" / "Steer message"; 排队发送 / 插话发送), so the
mode is never hidden; idle sessions, one-shot children, and locked
composers keep the plain Send label. The composer bar inject face
publishes the live preference as hooks.busyEnter instead of a resolver
closure, and resolveSubmitMode is a pure function taking the preference
explicitly, so label and delivery derive from one value in one render and
the label follows live Settings changes. The Settings row is retitled
"Send behavior while busy" with a description that names both Enter and
the button; the busyEnter field, its default, and the Host schema are
unchanged.

Tests pin both preferences on the running button for ordinary sessions
and continuable children, the live relabel, the idle Queue path, and the
pure resolver; the settings-chrome ARIA goldens and the live-interactions
running-draft and queue-actions failed goldens carry the new copy. A new
Agent Note owns the decision and reverses the pointer-ignores-preference
clause of the archived 2026-08-20 running-draft note.
2026-09-07 19:14:21 +08:00
lsdsjy ef88756f13 feat(session, agent, web): support same-session message editing 2026-09-02 18:26:55 +08:00
lsdsjy af562d3649 fix(api-gateway): keep idle websocket alive 2026-08-27 14:48:13 +08:00
lsdsjy 7c7e4aada8 fix(snapshot): project headless reasoning stderr 2026-08-25 18:51:37 +08:00
lsdsjy 3a9820c8cb fix(headless): make stream chunk handling exhaustive 2026-08-25 18:51:37 +08:00
lsdsjy 2813ef2a95 fix(headless): preserve reasoning block continuity 2026-08-25 18:51:37 +08:00
lsdsjy 937d2b3513 feat(headless): stream reasoning progress to stderr 2026-08-25 18:51:37 +08:00
lsdsjy 5c98d5ece8 fix(fs): tolerate null editor placeholders 2026-08-25 18:28:09 +08:00
lsdsjy 9d25fbf218 fix(ui-workspace): keep blank new sessions outside the fold quota
Keep five non-blank rows stable while the selected blank New Session is provisional, and derive the overflow count from the rows still hidden.

Fixes #2841
2026-08-25 14:36:56 +08:00
lsdsjy 838006d960 docs(client-modules,client-hmr): align bootstrap and rebuild semantics 2026-08-24 20:49:13 +08:00
lsdsjy 47bf44a5bb fix(client-modules,webserver,webworker-runtime): preserve batched boot across transports 2026-08-24 20:49:12 +08:00
lsdsjy 445de0ab3e fix(client-modules): tolerate incomplete source maps 2026-08-24 20:48:13 +08:00
lsdsjy 9ee9a3270c test(web): hold application batch during boot theme check 2026-08-24 20:48:12 +08:00
lsdsjy 5bbaf168d9 perf(client-modules): batch startup plugin scripts 2026-08-24 20:48:12 +08:00
lsdsjy e06625d202 fix(web): switch running drafts to Send 2026-08-24 11:37:48 +08:00
lsdsjy 600f3a3110 fix(frontend-static): return 404 for a missing index 2026-08-20 20:03:18 +08:00
lsdsjy 92723cafeb fix(frontend-static): return 404 for missing paths 2026-08-20 20:02:11 +08:00
lsdsjy f938d8e1c8 fix(ci): reuse pinned bubblewrap setup in e2e 2026-08-19 16:08:56 +08:00
lsdsjy 9e97269bc5 fix(ci): reuse pinned bubblewrap setup in e2e 2026-08-19 15:42:12 +08:00
lsdsjy d66841ea3f feat(web,cli): open the ready Web UI by default 2026-08-19 15:42:12 +08:00
lsdsjy 49b48369db fix(community,llm): remove duplicate README assets 2026-08-18 16:21:54 +08:00
lsdsjy c1c955bb09 feat(community,infra): publish README assets through CDN 2026-08-18 16:21:54 +08:00
lsdsjy 4edbdd443e fix(web): repair Safari textarea soft-wrap shrink 2026-08-14 17:52:09 +08:00