@f5-sales-demo/xcsh 21.29.0 → 21.29.2

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 (57) hide show
  1. package/README.md +7 -0
  2. package/package.json +8 -8
  3. package/src/commands/remote-control.ts +11 -4
  4. package/src/config/model-catalog.ts +56 -0
  5. package/src/internal-urls/build-info.generated.ts +8 -8
  6. package/src/internal-urls/docs-index.generated.ts +3 -2
  7. package/src/modes/components/model-selector.ts +4 -59
  8. package/src/modes/controllers/input-controller.ts +9 -17
  9. package/src/modes/interactive-mode.ts +19 -0
  10. package/src/person-profile/HISTORICAL-AUDIT.md +1 -1
  11. package/src/prompts/system/remote-voice-identity.md +2 -0
  12. package/src/prompts/system/remote-voice-live.md +31 -0
  13. package/src/prompts/system/system-prompt.md +4 -0
  14. package/src/prompts/system/title-system.md +8 -2
  15. package/src/prompts/tools/xcsh-api.md +5 -0
  16. package/src/prompts/tools/xcsh-context.md +11 -0
  17. package/src/remote-control/ACCEPTANCE.md +52 -0
  18. package/src/remote-control/CONTEXT-WORKFLOW.md +154 -0
  19. package/src/remote-control/IMPLEMENTATION.md +113 -0
  20. package/src/remote-control/LIVE-GUIDANCE.md +116 -0
  21. package/src/remote-control/NOTICE.md +3 -1
  22. package/src/remote-control/PARITY.md +77 -0
  23. package/src/remote-control/bridge.ts +2 -0
  24. package/src/remote-control/context-evaluation.ts +43 -0
  25. package/src/remote-control/control.ts +453 -67
  26. package/src/remote-control/discovery.ts +4 -9
  27. package/src/remote-control/host.ts +199 -25
  28. package/src/remote-control/ipc.ts +2 -2
  29. package/src/remote-control/lifecycle-state.ts +327 -0
  30. package/src/remote-control/managed-sessions.ts +782 -0
  31. package/src/remote-control/managed-worker.ts +206 -0
  32. package/src/remote-control/metadata.ts +40 -4
  33. package/src/remote-control/relay-lifecycle.ts +136 -0
  34. package/src/remote-control/relay.ts +20 -2
  35. package/src/remote-control/router.ts +421 -21
  36. package/src/remote-control/session.ts +270 -28
  37. package/src/remote-control/startup-manager.ts +85 -0
  38. package/src/remote-control/supervisor.ts +197 -0
  39. package/src/remote-control/thread-identity.ts +22 -0
  40. package/src/remote-control/trace-assembler.ts +182 -0
  41. package/src/remote-control/trace-report.ts +147 -0
  42. package/src/remote-control/trace-runtime.ts +18 -6
  43. package/src/remote-control/trace.ts +1 -0
  44. package/src/remote-control/voice-first-replay.ts +116 -0
  45. package/src/remote-control/voice-persona.ts +45 -0
  46. package/src/remote-control/voice.ts +7 -0
  47. package/src/sdk.ts +13 -1
  48. package/src/services/xcsh-context.ts +37 -2
  49. package/src/session/agent-session.ts +19 -2
  50. package/src/session/agent-storage.ts +4 -1
  51. package/src/session/context-selection-intent.ts +28 -0
  52. package/src/session/session-manager.ts +29 -0
  53. package/src/slash-commands/builtin-registry.ts +51 -5
  54. package/src/tools/index.ts +3 -0
  55. package/src/tools/xcsh-api.ts +107 -14
  56. package/src/tools/xcsh-context.ts +94 -0
  57. package/src/utils/title-generator.ts +193 -75
@@ -0,0 +1,154 @@
1
+ # Context selection and resource conversations
2
+
3
+ The objective is a reliable conversation, rather than a hardcoded answer to one
4
+ inventory question. A user can select a tenant and ask a resource question in one
5
+ utterance or across several turns. Native conversational input and delegated voice
6
+ execute through the same attached agent session.
7
+
8
+ ## Execution contract
9
+
10
+ 1. Resolve the current request's target. An explicit saved-context name takes
11
+ precedence over a name in earlier conversation. List saved names when necessary.
12
+ Missing or ambiguous names require a concise clarification; do not substitute a
13
+ remembered context.
14
+ 2. Select through `xcsh_context` using the same `ContextService.activate` operation
15
+ as `/context <name>`. The terminal slash command remains available. Selection
16
+ changes the process's context environment overlay, not the saved credential file.
17
+ Exact named-tool requests are buffered until the requested call is complete. If
18
+ the provider reaches its output limit before emitting that call, the backend
19
+ retries once with the same tool choice and a transient call-only reminder. A
20
+ second incomplete response or a substituted tool becomes a sanitized failure;
21
+ neither partial text nor an unrequested call reaches history or execution.
22
+ 3. Wait for selection and connectivity validation. Ask approvals belong to the
23
+ attached session. Declines, cancellation, changed configuration during review,
24
+ and Plan mode prevent a pending selection from committing. Late authentication
25
+ results cannot overwrite a newer context's status.
26
+ 4. Bind subsequent `xcsh_api` calls with `contextName`. The tool rejects a mismatched
27
+ context before executing the request. Explicit `XCSH_*` environment overrides
28
+ retain their existing precedence; the context result reports effective state.
29
+ 5. Resolve resource type, namespace coverage, and any identity filter from current
30
+ evidence. An explicitly supplied creator ID is usable in its stated tenant.
31
+ A credential principal, person-profile email, or accessible inventory alone does
32
+ not establish the human's creator ID. Request only missing information.
33
+ 6. Retrieve the evidence needed for the question. For a scoped single-type query,
34
+ use `expandDiscovery: false` to retain the endpoint's full response without
35
+ automatically retrieving other resource types. Broad inventory continues to use
36
+ explicit namespace discovery. Read creator metadata, follow documented pagination,
37
+ and distinguish missing attribution from a nonmatching creator. Batched detail
38
+ responses retain their metadata; failed and partial batches retain per-request
39
+ status and are not cached as successful empty inventories.
40
+ 7. Respond with the result and relevant scope, briefly confirming a requested
41
+ context change. Explain material access or coverage gaps. Stop when the evidence
42
+ answers the question instead of repeating detail reads or narrating every tool.
43
+
44
+ The voice component passes the combined intent to its attached session and relays
45
+ the result. It does not independently select credentials, maintain a second tenant
46
+ state, or announce success before delegation completes. The existing delegation,
47
+ cancellation, session history, and approval ownership mechanisms remain in use.
48
+
49
+ ## Observe, analyze, improve, repeat
50
+
51
+ `scripts/voice-context-evaluation.ts` runs an executing model against synthetic
52
+ tenant transport while using the real session, context service, tool registry,
53
+ API tool, and voice delegation envelope. Scenarios cover combined and separate
54
+ turns, missing contexts, authentication failure, and identity supplied in the conversation, held in the person profile, or unresolved.
55
+ Additional variations cover creator metadata available only in detail responses
56
+ and denied inventory requests. A separate
57
+ source checkout can provide the baseline:
58
+
59
+ ```sh
60
+ XCSH_CONTEXT_EVAL_SOURCE=/path/to/baseline-checkout \
61
+ XCSH_CONTEXT_EVAL_OUTPUT=/private/evidence/baseline \
62
+ bun packages/coding-agent/scripts/voice-context-evaluation.ts --baseline
63
+
64
+ XCSH_CONTEXT_EVAL_OUTPUT=/private/evidence/candidate \
65
+ bun packages/coding-agent/scripts/voice-context-evaluation.ts
66
+ ```
67
+
68
+ Optional `--scenario=<id>` and `--surface=tui|voice-delegated-agent` select a bounded
69
+ rerun. `XCSH_CONTEXT_EVAL_MODEL` selects a model from the existing subscription OAuth
70
+ catalog. The harness never contacts a real tenant, changes a real context file, or
71
+ reads real personal profiles. It uses a distinct synthetic credential per fixture to
72
+ isolate the API cache, permits only catalog and isolated synthetic profile reads, and stores evidence outside the
73
+ repository with private permissions.
74
+
75
+ Evaluate four dimensions separately:
76
+
77
+ | Dimension | Evidence | Failure examples |
78
+ | --- | --- | --- |
79
+ | Intent and state | Requested target, completed selection, later requests | Substituted context; old tenant queried; follow-up loses selection |
80
+ | Execution | Ordered tool/transport events and connection outcomes | Query before selection completes; request after authentication failure |
81
+ | Efficiency | Assistant turns, tool calls, tenant requests, repeated reads | Namespace-wide discovery for a scoped question; redundant detail retrieval |
82
+ | Response quality | Review the synthetic answer against returned evidence | Invented attribution; unnecessary clarification; unqualified complete-inventory claim |
83
+
84
+ `scoreContextFlow` evaluates causal execution, independently of response wording.
85
+ The harness also reports response length and simple answer checks. Those checks
86
+ are screening signals; they do not prove semantic correctness or natural speech.
87
+ Review the synthetic turns and answer before accepting a run. Record the model,
88
+ source revision, fixture version, failures, repair, and the subsequent rerun.
89
+ The result receipt includes revision and tracked-change state; failing scenarios
90
+ produce a nonzero exit. Provider-request traces record tool counts and whether the
91
+ context schema was present, without storing the provider payload. This distinguishes
92
+ a missing capability from an agent incorrectly claiming that an available tool is
93
+ missing. Review all cases together; retain failed runs instead of selecting only
94
+ successful samples.
95
+
96
+ Fixture paths use opaque names so directory names cannot reveal expected outcomes.
97
+ Read restrictions describe only the unavailable read path, without implying that
98
+ other tools are prohibited. These controls prevent evaluation setup from supplying
99
+ unintended hints or artificial blockers.
100
+
101
+ Initial observations motivating this implementation were a plausible answer from
102
+ the previous tenant, substitution of a remembered context after a missing-name
103
+ request, and automatic broad discovery that discarded creator metadata and led to
104
+ repeated detail reads. Keep those failure modes as regression cases rather than
105
+ tuning only for a successful example.
106
+
107
+ ## Physical interaction evaluation
108
+
109
+ Executing-agent delegation tests do not exercise microphone recognition, realtime
110
+ speech, phone approval presentation, or interruptions. Evaluate those separately
111
+ on the attached phone session with ordinary phrasing, pauses, a combined request,
112
+ a follow-up, a corrected context name, and a cancelled selection. Observe whether
113
+ the assistant preserves intent, asks only useful questions, waits for execution,
114
+ and speaks a concise evidence-grounded response.
115
+
116
+ Keep real prompts, transcripts, audio, profile values, tenant data, and credentials
117
+ out of committed evidence. Session titles are user-visible operational identifiers:
118
+ retain their exact text in runtime diagnostics and UAT evidence so title generation
119
+ and catalog synchronization remain directly observable. Record other live activity
120
+ as tool names, outcome categories, counts, and booleans. Only generated synthetic
121
+ fixtures and their algorithms belong in source.
122
+
123
+ ## Diagnostic comparisons
124
+
125
+ `--compact-diagnostic` removes the normal backend instructions to investigate prompt
126
+ interference. `--force-context-diagnostic` requests one named context-tool call to
127
+ investigate provider tool-choice handling. `--sse-diagnostic` disables backend
128
+ WebSockets to compare transport behavior. Receipts mark these variants as ineligible for
129
+ qualification. They are diagnostic comparisons, not alternative acceptance runs.
130
+ WebSocket observations retain only tool counts and capability/choice booleans.
131
+ Accepted synthetic assistant text is retained per turn, so an incorrect answer
132
+ cannot be concealed by a later successful answer. A rejected forced-tool attempt is
133
+ instead represented by aggregate request and outcome metadata: its partial prose and
134
+ arguments are deliberately not exposed or persisted. Separate-turn selection must
135
+ complete before the follow-up begins.
136
+
137
+ See [GPT-Live guidance review](LIVE-GUIDANCE.md) for the voice/backend prompt
138
+ boundary, interruption semantics, transport differences, and remaining gates.
139
+
140
+ ## Lifecycle qualification boundary
141
+
142
+ Context-selection acceptance must survive a supervised host replacement, not only
143
+ an uninterrupted evaluator run. The four attached sessions retain their original
144
+ tenant isolation and approval owners while the host process is replaced. Once they
145
+ re-register, a stable `clientUserMessageId` must resolve to the already accepted
146
+ turn; it must not repeat context activation, a tenant request, or an approval.
147
+
148
+ Run the clean 16-case evaluator only from the exact candidate revision, under Bun
149
+ 1.4.2, after bounded missing-context checks. Reject a run with tracked-source drift,
150
+ wrong-tenant requests, provider errors, timeouts, follow-up queries that precede
151
+ selection completion, or an answer that fails private rubric review. Keep prompts,
152
+ answers, tenant/profile values, credentials, transcripts, audio, and review notes
153
+ outside Git. The immutable artifact and later live crash-recovery observation must
154
+ refer to the same full source SHA.
@@ -192,6 +192,7 @@ From the feature worktree:
192
192
 
193
193
  ```sh
194
194
  bun packages/coding-agent/src/cli.ts remote-control enable --json
195
+ bun packages/coding-agent/src/cli.ts remote-control restart --json
195
196
  bun packages/coding-agent/src/cli.ts remote-control status --json
196
197
  bun packages/coding-agent/src/cli.ts remote-control pair
197
198
  bun packages/coding-agent/src/cli.ts remote-control disable
@@ -2747,3 +2748,115 @@ same current scope before freezing its snapshot. The regression creates
2747
2748
  distinct project-A and project-B summaries, moves the session, and asserts that
2748
2749
  the rebuilt prompt and memory reader contain B but not A. Memory remains
2749
2750
  project-scoped; no summaries are copied or aggregated across roots.
2751
+
2752
+ ## Shared mobile model selection
2753
+
2754
+ The remote model catalog is now registered by each attached AgentSession and
2755
+ validated by the private host. It uses the same current-model filter as the TUI
2756
+ and publishes user-facing names, input modalities, supported effort values, and
2757
+ defaults through the pinned `model/list` schema.
2758
+
2759
+ The iPhone's existing `thread/settings/update` control can change model and
2760
+ effort as one operation. The adapter resolves only a currently available model,
2761
+ validates effort against the destination model before mutation, and invokes the
2762
+ TUI's conversation-scoped model transaction. That transaction handles credential
2763
+ validation, provider-session reset, manual routing pinning, session history,
2764
+ rollback, and synchronous persistence. Effort-only changes are flushed before
2765
+ acknowledgement. A settings notification immediately refreshes the host's thread
2766
+ snapshot and the app's selected controls.
2767
+ The app also sends its advertised `multiAgentMode` value with settings changes;
2768
+ xcsh accepts the canonical `explicitRequestOnly` value and rejects other modes.
2769
+ After a successful resume response, the host replays the active settings
2770
+ snapshot to that subscribed client. This compensates for the iPhone control
2771
+ rehydrating from the catalog default while preserving the model catalog's
2772
+ global default and the thread's actual effort, collaboration mode, and
2773
+ permission state.
2774
+ Settings updates and turn starts share an admission queue, so sending immediately
2775
+ after a tap waits for credential validation and persistence instead of racing the
2776
+ old model. Once any owner publishes a validated catalog, the compatibility
2777
+ fallback cannot reintroduce a historical active model.
2778
+
2779
+ ## Durable remote-control lifecycle — issue 3873
2780
+
2781
+ The 2026-09-14 lifecycle implementation replaces the one-shot host with an
2782
+ owner-only supervisor. `enable`, `restart`, and `disable` serialize through one
2783
+ lifecycle lock and are idempotent. On Linux, `enable` atomically reconciles and
2784
+ enables `xcsh-remote-control.service` in the user systemd manager. The unit has
2785
+ no credentials, starts only the supervisor, restarts it on failure, and uses
2786
+ `KillMode=mixed` so graceful shutdown reaches the supervisor before its host.
2787
+ Other platforms use the same supervisor as a detached process.
2788
+
2789
+ The supervisor owns one host generation. Its PID records contain the PID,
2790
+ process start time, resolved executable path, executable SHA-256, and generation.
2791
+ Signals and stale-record removal require an exact identity match. A replacement
2792
+ supervisor may adopt a surviving host only when that record is still live and
2793
+ belongs to the current generation. Private state, sockets, and logs use owner-only
2794
+ permissions. A competing supervisor must win the socket bind before publishing
2795
+ its PID, so a failed contender cannot overwrite the live owner.
2796
+
2797
+ The host is probed every two seconds with a one-second deadline and receives ten
2798
+ seconds to start. An exit or three failed probes triggers a full-jitter restart
2799
+ delay beginning at 500 ms and capped at 30 seconds. Five failures in five minutes
2800
+ persist a non-spawning degraded state across supervisor restarts. Only an explicit
2801
+ `enable` or `restart` creates a new generation and resets that breaker. Startup
2802
+ transitions restore the preceding lifecycle snapshot and enabled flag if service
2803
+ startup fails.
2804
+
2805
+ Shutdown stops admission and waits up to 60 seconds for in-flight routing and
2806
+ unacknowledged outbound relay work. It then signals only an identity-verified
2807
+ process, escalating from TERM to KILL within a bounded service stop window. An
2808
+ intentional `disable` writes the disabled state before stopping the service, so
2809
+ systemd cannot restart either process at login or after a failure.
2810
+
2811
+ Relay clients are keyed by `(clientId, streamId)`. Same-stream initialization
2812
+ replaces and completely clears the old logical owner, while sibling streams remain
2813
+ independent. Unknown non-initialize traffic is discarded without retaining codec
2814
+ state. Clients expire after ten idle minutes on a 30-second sweep; client closure,
2815
+ outbound termination, shutdown, and replacement all release subscriptions,
2816
+ interaction delivery ownership, process ownership, codec state, and bounded
2817
+ queues. Ingress and outbound queues are capped at 128. Saturated requests receive
2818
+ `-32001` with `Server overloaded; retry later.` without closing healthy streams.
2819
+ Cursor and unacknowledged output survive relay reconnects; heartbeat and reconnect
2820
+ timing use 10-second pings, a 60-second pong deadline, and capped full jitter.
2821
+
2822
+ Deterministic coverage includes process-identity mismatch, stale/corrupt state and
2823
+ locks, socket collision, concurrent supervisor startup, persisted degradation,
2824
+ host crash replacement, intentional disable, bounded drain, relay replacement and
2825
+ expiry, overload isolation, reconnect replay, one current-session registration,
2826
+ and model/effort selection persistence. The iPhone host label is exactly
2827
+ `xcsh - <workstation>`: `xcsh` is always lowercase. The live Ubuntu runtime is not
2828
+ changed until a new full-SHA immutable package passes every offline gate.
2829
+
2830
+ ## Phone-created session lifecycle — issue 3873 supersession
2831
+
2832
+ The 2026-09-14 session-lifecycle work supersedes earlier dated statements that
2833
+ `thread/start`, `thread/fork`, or phone-created sessions are unsupported. The host
2834
+ still exposes exactly one selected terminal initially. A phone may additionally
2835
+ create durable or ephemeral sessions, and those managed sessions then remain
2836
+ visible alongside the selected terminal.
2837
+
2838
+ Managed sessions use ordinary `AgentSession` construction, extension and tool
2839
+ discovery, approval handling, history, model selection, and context bootstrap.
2840
+ Their cwd is selected in this order: an explicit normalized phone cwd, the exposed
2841
+ terminal cwd, then the cwd saved by `/remote enable`. Durable metadata is written
2842
+ to an owner-only catalog. Cold read does not load a worker; concurrent resume is
2843
+ single-flight; idle unsubscribed workers unload after 30 minutes; and archived
2844
+ history remains cold-readable and restorable.
2845
+
2846
+ Each loaded phone session is owned by a separate worker process and owner-only
2847
+ Unix socket. Host replacement detaches rather than cancels durable workers, so an
2848
+ active turn continues and its bounded event queue replays once to the replacement.
2849
+ Worker PID records use the same PID, start-time, executable-path, executable-hash,
2850
+ and generation checks as host lifecycle records. Delete, archive, idle unload, and
2851
+ intentional disable wait for session disposal and terminate only the exact worker;
2852
+ ordinary host replacement does not. Catalog paths are constrained to the session,
2853
+ archive, and worker roots before they can be opened, moved, or deleted.
2854
+
2855
+ The implemented Codex 0.153.4 lifecycle surface is `thread/start`, `thread/fork`,
2856
+ `thread/archive`, `thread/unarchive`, `thread/delete`, `thread/compact/start`, and
2857
+ `thread/revert`. Stable and experimental thread projections, pagination, ephemeral
2858
+ fork history, response-before-notification ordering, and explicit protocol errors
2859
+ are covered by pinned schemas. Voice on a managed session uses the same WebRTC v3,
2860
+ persona, delegation, approval, cancellation, and replay implementation as the
2861
+ terminal session. Context changes remain tool-owned through `xcsh_context`; the
2862
+ voice model does not parse the TUI-only `/context` command.
@@ -0,0 +1,116 @@
1
+ # GPT-Live guidance review
2
+
3
+ Reviewed against the official documentation on 2026-09-13. This review covers
4
+ architecture and conversational behavior; it does not certify phone acceptance.
5
+
6
+ ## Architecture and transport
7
+
8
+ The [Live overview](https://developers.openai.com/api/docs/guides/live) supports
9
+ client delegation when an application owns an existing backend. xcsh attaches the
10
+ voice surface to its existing `AgentSession`; that session owns the tool registry,
11
+ context selection, permissions, and task history. Voice does not create another
12
+ credential or tenant-selection authority.
13
+
14
+ The public API examples use project API credentials. The paired phone path here
15
+ uses the separately pinned Codex subscription OAuth protocol and
16
+ `gpt-live-1-codex`. Public `/v1/live/sessions` examples are not proof of subscription
17
+ access or a reason to replace that transport. Protocol changes need separate
18
+ source-contract and integration qualification.
19
+
20
+ ## Prompt boundary
21
+
22
+ [Live prompting](https://developers.openai.com/api/docs/guides/live-prompting)
23
+ recommends a compact speaking/delegation policy and backend-owned procedures.
24
+ The v3 persona now uses `remote-voice-live.md`, with registered tool names and bounded
25
+ speaking preferences and recent context. It omits the terminal system prompt and
26
+ full tool descriptions. The complete envelope stays within 8 KiB. This is a local
27
+ engineering budget, not an OpenAI token-limit claim. Legacy fixtures retain their
28
+ existing contract.
29
+
30
+ The listening policy intentionally disables backchannels to honor the user's
31
+ preference. Prompt tests check this boundary; actual pauses and interruptions still
32
+ require listening to phone conversations.
33
+
34
+ ## Execution, interruptions, and results
35
+
36
+ [Delegation guidance](https://developers.openai.com/api/docs/guides/live-delegation)
37
+ keeps application authorization and task state authoritative. In xcsh, delegation
38
+ IDs are preserved, repeated submissions are suppressed, and active-session
39
+ corrections use the existing steering path. Closing voice leaves backend work
40
+ running. An interrupted backend turn now reports interruption without implying
41
+ that completed actions were undone.
42
+
43
+ Context activation checks approval, cancellation, configuration revision, and
44
+ connection status before dependent queries. API target checks reject requests
45
+ against a different selected context. Structured response phase metadata routes
46
+ progress and final output; private reasoning is excluded. Native result chunks
47
+ remain bounded by the pinned transport contract.
48
+
49
+ When the backend explicitly requires `xcsh_context`, it treats that named choice as
50
+ an execution boundary. The response stays private until the matching call is
51
+ complete. A pre-invocation output-limit stop receives one retry with the same named
52
+ choice; cancellation is not retried, and substituted tools are never dispatched.
53
+ This preserves backend ownership without asking the voice model to select credentials.
54
+
55
+ At-most-once submission is not exactly-once execution: crash-gap reconciliation
56
+ remains an acceptance limitation. Do not retry an uncertain mutation merely
57
+ because its spoken result was lost.
58
+
59
+ ## Evaluation and remaining gates
60
+
61
+ The [voice evaluation guide](https://developers.openai.com/cookbook/examples/audio/voice_agent_evaluation)
62
+ separates spoken experience from backend task results. `CONTEXT-WORKFLOW.md` describes
63
+ our synthetic execution checks and manual response review. A passing text-agent
64
+ trace does not establish microphone recognition, natural timing, or whether the
65
+ user heard a useful answer. Physical evaluation must include combined requests,
66
+ follow-ups, corrections, pauses, cancellation, and access failures.
67
+
68
+ The broader executing-agent run exposed false claims that a registered context
69
+ tool was unavailable. Provider-request observations confirmed its schema was
70
+ present, and a bounded SSE comparison ruled out transport as the cause. The backend
71
+ now guards the exact named-tool request as described above. Deterministic length,
72
+ repeat-failure, cancellation, and substituted-tool cases plus bounded live TUI and
73
+ delegated-voice checks cover the repair. A clean full evaluator run and physical
74
+ phone interaction remain separate release gates.
75
+
76
+ ## Durable transport lifecycle
77
+
78
+ Voice transport recovery now sits behind a persistent remote-control supervisor.
79
+ The supervisor, not the phone or the voice model, owns host replacement. It probes
80
+ the host every two seconds, restarts after exit or three failed one-second probes,
81
+ and opens a persistent degraded breaker after five failures in five minutes.
82
+ `remote-control enable` or `restart` is the only breaker reset; `disable` remains
83
+ stopped across service failure, logout, and reboot.
84
+
85
+ Logical relay clients are scoped by both client and stream identity. Replacing one
86
+ stream clears its subscriptions, approval-delivery ownership, remote process
87
+ ownership, codec fragments, and queues without cancelling work in the attached
88
+ terminal or affecting sibling streams. Unknown traffic is dropped. Idle clients
89
+ expire after ten minutes, ingress and outbound queues are capped at 128, and an
90
+ overloaded request receives the retryable `-32001` response. Cursor and unacknowledged
91
+ output survive transport reconnect; WebSocket heartbeat and reconnect use 10-second
92
+ pings, a 60-second pong timeout, and full-jitter exponential delay capped at 30
93
+ seconds.
94
+
95
+ Shutdown first stops admission, then drains routing and unacknowledged outbound work
96
+ for up to 60 seconds. Forced termination is limited to an exact PID, start-time,
97
+ executable-path, executable-hash, and generation match. These mechanics preserve
98
+ backend task ownership during voice closure and host replacement; they do not prove
99
+ microphone, speech, or iPhone presentation quality. Those remain physical-device
100
+ acceptance gates after the immutable candidate passes offline qualification.
101
+
102
+ ## Managed voice sessions
103
+
104
+ Phone-created sessions are no longer an unsupported boundary in the issue #3873
105
+ candidate. They use the same server-owned persona snapshot, WebRTC v3 transport,
106
+ delegation, approval broker, cancellation, context tool, and durable history as an
107
+ attached terminal. The phone may request a cwd only when it is normalized,
108
+ absolute, and already exists; otherwise the host selects the exposed terminal cwd
109
+ and then the saved `/remote enable` cwd.
110
+
111
+ The voice model must invoke `xcsh_context` for context changes. `/context` remains
112
+ a TUI command and is not reimplemented in voice prose. A host disconnect leaves
113
+ the worker and active turn running; a replacement host reconnects to that exact
114
+ worker and replays only its bounded unacknowledged events. Intentional disable is
115
+ different: it disposes managed sessions and exact-identity terminates every durable
116
+ worker, including workers not yet cold-loaded by the replacement host.
@@ -39,7 +39,9 @@ Source files under `codex-rs/app-server-transport/src/transport/remote_control/`
39
39
  terminal answer broker, tool-call binding and host routing are native xcsh code.
40
40
  - `codex-rs/app-server/src/request_processors/thread_lifecycle.rs` and
41
41
  `app-server-protocol/src/protocol/v2/thread.rs`: pending-request retirement before
42
- unload and the `thread/closed` notification. Its schema fixture is unchanged.
42
+ unload and the `thread/closed` notification. The start, fork, archive,
43
+ unarchive, delete, compact, and revert request/response/notification schema
44
+ fixtures are unchanged copies of the pinned source.
43
45
  - `codex-rs/app-server-protocol/src/protocol/item_builders.rs`: file-change
44
46
  conversion, raw add/delete contents, rename suffix and UTF-8 path ordering.
45
47
  The fixture generator executes the original converter functions with local
@@ -1161,3 +1161,80 @@ prompt, `memory://root`, and a new WebRTC or standalone voice snapshot. After a
1161
1161
  reviewed `/move`, xcsh rebuilds the effective TUI prompt before accepting the
1162
1162
  next turn. A two-project regression rejects stale project-A memory and requires
1163
1163
  project-B memory on both surfaces.
1164
+
1165
+ ## iPhone model and effort controls
1166
+
1167
+ The ChatGPT model and effort buttons now operate on the attached xcsh session.
1168
+ Both interfaces use the same current-model catalog filter, so OpenAI subscription
1169
+ OAuth presents Luna, Terra, Sol, and Astra instead of historical and internal
1170
+ registry entries. Each catalog row carries the model's display name, input
1171
+ modalities, exact supported effort ladder, and default effort.
1172
+
1173
+ `thread/settings/update` resolves the selected model against the live session's
1174
+ available catalog, validates effort against that target model, and applies the
1175
+ pair through the same conversation-scoped model-selection transaction as the
1176
+ TUI. The transaction records manual routing pin and persists the session before
1177
+ acknowledging the tap. Effort-only changes are also flushed before the response.
1178
+ The validator accepts the app's canonical
1179
+ `multiAgentMode: "explicitRequestOnly"` setting and rejects unsupported values.
1180
+ After every successful `thread/resume` response, the host sends that client the
1181
+ current settings notification. This restores the effort control from the live
1182
+ thread instead of the model catalog's default when the iPhone reopens the
1183
+ conversation.
1184
+ Unavailable models, hidden historical models, unsupported efforts, service
1185
+ tiers, and changes during an active turn fail without switching models. The
1186
+ resulting settings notification updates host discovery immediately instead of
1187
+ waiting for the registration heartbeat.
1188
+
1189
+ A prompt sent immediately after a model tap waits for that settings transaction
1190
+ to finish. Historical active models are excluded once the shared catalog is
1191
+ available, including from the legacy thread-metadata fallback.
1192
+
1193
+ Synthetic phone-shaped bridge tests cover catalog rendering, a model-and-effort
1194
+ tap, immediate thread state, invalid choices, active-turn exclusion, persistence
1195
+ before shutdown, and full restart restoration. Physical iPhone rendering and
1196
+ tap acceptance remain a separate human checkpoint.
1197
+
1198
+ ## Durable relay and process lifecycle parity
1199
+
1200
+ The 2026-09-14 lifecycle port keeps the existing v3 wire fields and adds no
1201
+ client-visible replacement protocol. Logical relay state now follows pinned Codex
1202
+ behavior by keying clients on `(clientId, streamId)`, replacing only the same
1203
+ stream, dropping unknown non-initialize traffic, expiring idle owners, bounding
1204
+ both queue directions at 128, returning retryable `-32001` overload errors, and
1205
+ retaining cursor plus unacknowledged output across reconnects. Cleanup retires
1206
+ subscriptions, delivered approval ownership, remote processes, codec state, and
1207
+ queues without cancelling the attached terminal's work.
1208
+
1209
+ The additive `status` fields report supervisor and host state, startup manager,
1210
+ generation, restart count, and a sanitized degraded reason while retaining
1211
+ `enabled`, `relay`, `liveSessions`, and `sessions`. `restart` joins the existing
1212
+ management actions without changing pairing or client-management contracts.
1213
+
1214
+ Linux startup parity is implemented as an owner-only systemd user unit with no
1215
+ credentials. Exact process identity includes PID, process start time, resolved
1216
+ executable path and SHA-256, plus lifecycle generation. The supervisor uses the
1217
+ specified health cadence, startup allowance, jittered retry, persistent breaker,
1218
+ and graceful drain. Automated four-session recovery proves stable identity,
1219
+ metadata, history, approval replay, and tenant-call deduplication. A source-matched
1220
+ packaged harness and one controlled Ubuntu crash/cutover remain required before
1221
+ this section can claim live lifecycle acceptance; iPhone behavior remains a
1222
+ separate human observation.
1223
+
1224
+ ## Managed iPhone session parity supersession
1225
+
1226
+ As of the 2026-09-14 issue #3873 candidate, the historical unsupported-fork and
1227
+ excluded-phone-session observations above are retained only as evidence for older
1228
+ artifacts. The current source supports the pinned Codex 0.153.4 start, fork,
1229
+ archive, unarchive, delete, compact, and revert contracts. It projects one chosen
1230
+ terminal plus phone-created sessions, keeps cold durable history discoverable, and
1231
+ uses response-before-notification ordering for lifecycle broadcasts.
1232
+
1233
+ Phone-created sessions run full `AgentSession` workers with the same dynamic model
1234
+ catalog, tools, extensions, approvals, context bootstrap, WebRTC v3 voice, and
1235
+ history paths as a terminal. A worker survives host replacement, replays bounded
1236
+ unacknowledged events once, unloads when idle and unsubscribed, and is terminated
1237
+ on archive, delete, or intentional disable. Exact process identity and catalog-root
1238
+ validation prevent stale PID or corrupt-path cleanup from targeting another
1239
+ process or file. Automated protocol parity is not physical iPhone acceptance;
1240
+ the device flow remains an explicit release gate.
@@ -50,9 +50,11 @@ export function startSessionBridge(
50
50
  const catalog = remote.skills();
51
51
  await peer.call("register", {
52
52
  thread: remote.thread(),
53
+ collaborationMode: controls.getCollaborationMode?.() ?? "default",
53
54
  requests: remote.pendingRequests(),
54
55
  skills: catalog.skills,
55
56
  skillErrors: catalog.errors,
57
+ models: remote.models(),
56
58
  });
57
59
  } catch {
58
60
  peer?.close();
@@ -0,0 +1,43 @@
1
+ /** Value-free workflow events derived from executed tools and the tenant transport. */
2
+ export type ContextFlowEvent =
3
+ | { kind: "selection"; context: string; outcome: "connected" | "auth_error" | "failed" }
4
+ | { kind: "query"; context: string; credentialMatches: boolean };
5
+
6
+ /** Score causal execution, independently of whether the final prose sounds convincing. */
7
+ export function scoreContextFlow(
8
+ events: readonly ContextFlowEvent[],
9
+ requestedContext: string,
10
+ expectation: "query" | "blocked" | "clarification",
11
+ ) {
12
+ let connected = false;
13
+ let selectionAttempted = false;
14
+ let prematureQueries = 0;
15
+ let wrongTargetQueries = 0;
16
+ let substitutedSelections = 0;
17
+ let queries = 0;
18
+ for (const event of events) {
19
+ if (event.kind === "selection") {
20
+ selectionAttempted = true;
21
+ if (event.context !== requestedContext) substitutedSelections++;
22
+ connected = event.context === requestedContext && event.outcome === "connected";
23
+ } else {
24
+ queries++;
25
+ if (!connected) prematureQueries++;
26
+ if (event.context !== requestedContext || !event.credentialMatches) wrongTargetQueries++;
27
+ }
28
+ }
29
+ return {
30
+ passed:
31
+ substitutedSelections === 0 &&
32
+ prematureQueries === 0 &&
33
+ wrongTargetQueries === 0 &&
34
+ (expectation === "blocked"
35
+ ? selectionAttempted && !connected && queries === 0
36
+ : connected && (expectation === "clarification" || queries > 0)),
37
+ selectionAttempted,
38
+ queries,
39
+ prematureQueries,
40
+ wrongTargetQueries,
41
+ substitutedSelections,
42
+ };
43
+ }