* feat(liveshare): open reader capabilities the share can serve (cherry picked from commit 3c893b488900fff776a21eebee4eb2d95b878764) * feat(liveshare): let a reader run the session's slash commands (cherry picked from commit ae02bcc0f819e55ebf066de7581d4d89994930a4) * fix(liveshare): allow a reader to list the workspace file references (cherry picked from commit fffaa864b9d790a0aab30da639d5ef50ff8f303c) * fix(liveshare): bind the job endpoints to their session resource (cherry picked from commit 357d1f6efe5b161a4ce1b616e66599c4e75a6ab1) * chore: refresh the Cordis surface catalog (cherry picked from commit 88f88b225f0fcff0a5a88f09b0f555749dd62756) * test(job-controller): read the Session resources the Remote methods declare The job roster, the follow stream, and a kill each declare the request's Session as the resource they touch, and an unowned job's follow names none. Read those declarations off the mounted Controller and pin what they answer. (cherry picked from commit fa3f92427a6bd56ad2a949dc74315505cb75533b) * feat(liveshare): offer a shareable core component to viewers The terminal controller reaches the catalog from a core profile bundle, which the catalog excludes so no application plumbing is offered. Mark such a component shareable: PluginMetadata gains the mark, and the host names the packages that carry it, so a marked core component enters the catalog and every other core component stays out. The terminal namespace leaves the exclusion list for the same reason, and the marked component carries the title its dialog row shows. (cherry picked from commit b0e9e390719aab519fd82cf39c85c60e4f77b588) * fix(liveshare): classify the terminal methods as owner-selected The nine terminal methods leave owner-only for plugin-offered: the owner picks them in the share dialog, no reader role grants one, and a share that names none still refuses every terminal call. (cherry picked from commit 718c1b45a1b01320cbe9be46ece9deca37225fe2) * docs(liveshare): state that terminals open per method Terminals are no longer unconditionally owner-only: the share dialog offers the terminal controller's methods and opens none until the owner picks them. (cherry picked from commit 505c1193571b16431731f69bd5ca1b59a1059a13) * test(liveshare): cover a viewer reaching the Session's terminals The end-to-end case mounts a real terminal controller beside the share host: the catalog offers it as a shareable core component, a share that selects nothing refuses every terminal call, and a selected terminal/create through the reader's own Peer binds the shell to the Session its agentId names. (cherry picked from commit 25955a936dc5b58ebfd8e1d24f495d62d59f7b70) * fix(workspace-files): confine non-owner reads to the session workspace A non-owner Peer now reads and watches files only inside the connected Session workspace. stat, read, readBytes (including baseFile) and changes resolve the target canonically and refuse an outside one with workspace-file/outside-workspace before reporting its kind. Owner and trusted in-process callers keep the filesystem read authority. (cherry picked from commit 7ae855e12ba6c5bc99c7ae75d65d984661f3bbb5) * refactor(workspace-files): name the file access confinement Replace the contain boolean with a named FileConfinement carried by the service, and move the outside-workspace refusal into one helper shared by file reads and watches. No Remote interface or behavior changes. (cherry picked from commit 1c4dbd68220df7c559f84cf2782f9626c5b2ef4b) * refactor(workspace-files): name the path mode PathScope Replace the FileConfinement/confinement vocabulary with PathScope, and rename its module and test. The values and behavior are unchanged. # Conflicts: # packages/api/workspace-files/src/index.ts # packages/api/workspace-files/tsconfig.host.json (cherry picked from commit 5d3f7b31dc6a1dbcf44c5fdd59295402bf40cf76) * refactor(workspace-files): accept several workspace roots in the path check The confinement helper and change feed now take several resolved roots; the current scope still supplies one. WorkspaceFileScope.workspaceRoot remains the primary root, so a future multi-workspace Session can add optional roots without changing endpoint signatures, path arguments, or the client address. (cherry picked from commit 73fd59be92c421c378b7fe5606d8d7c5806b13cb) * fix(workspace-files): keep the multi-root watch check covered Pass the primary watch root separately and iterate the roots list, so the feed keeps full coverage for the multi-root preparation. Add braces to the multi-root test arrow for the lint rule. (cherry picked from commit 1286aac6a6d93e693dbb33f2feaa71e6252424e0) * test(workspace-files): assert a refusal never reports the target kind The outside-workspace failure carries only the path, so a share reader learns nothing about what it was refused. stat, read, readBytes, list, and a relative escape are each asserted not to carry a kind. (cherry picked from commit a9495de0ff63a1aac325d1cb62b8111c188ae8a5) * test(workspace-files): keep the search caps in the shared harness config Rebasing over the search endpoint left configOf() without the search limits the master harness passed inline, so every search call reached the subprocess provider with an undefined graceMs. configOf and peer() now take Caps and supply the suite defaults. (cherry picked from commit 70cecb9b352ce5c1e17482429b1539483e101d60) * docs(workspace-files): describe the read confinement against the search-era structure The master README added the search section and rewrote the file-read checks without a workspace-containment check. Those paragraphs now state which caller the check applies to, the change feed mentions the non-owner watch, and the source map lists path-scope.ts. Bilingual hashes re-recorded with verify-translation-pairing --write. (cherry picked from commit e61fdabaf2fb9b0c0bc507ef5ceea0f213f70683) * fix(liveshare): keep workspaceFiles/search in the reader session-read role The classification table is the single source for POLICY_DECIDED_ACTIONS, so the new search endpoint must also appear in the read role's actions. (cherry picked from commit 665093b07cfee87be105fdc71a7d58fe25974788) * docs(catalog): regenerate the client and config catalogs Removing the viewer share-path tab drops its client slot entry, and the workspace file import shifts the Config source line. (cherry picked from commit 7bb9295a18b011971b4338171a60d16ff82eebd1) * docs(catalog): regenerate the config catalog source line (cherry picked from commit 2d98a59afc8aa6e2a9ac268d4446bcd8cd5eeb26) * fix(liveshare): let share readers preview workspace files The served page keeps the shipped Sidebar and now reads the shared Session workspace through workspaceFiles: stat, read, readBytes, list and changes join the Session read role, while the file service confines every non-owner read to that workspace root. The viewer tab type that answered each file address with "a share hands over paths, not contents" is removed, so the shipped document preview opens the file. Refs #7901 (cherry picked from 5e0ceac3faa)(partial: liveshare files only) * fix(ui-jobs): offer the stop control only with job/kill access (cherry picked from commit 804956ece9c09b2fac6180cd78da7aa7393ae0de) * fix(ui-chat): attribute a reader's steering row while it is pending Chat declared the message-source seat on the user node registration, so an admitted steering row rendered the shared bubble without asking for it and a Host-pending steering occurrence carried no source to ask with. Move the seat to the flow: it renders user rows, admitted steering rows, and pending steering occurrences, and hands the same renderer to each. Liveshare's selector now elects a share-viewer source of either kind, so a reader's interjection states its author from the moment it is sent. (cherry picked from c802aef8392)(partial: liveshare client files only) * docs(liveshare): state when a reader's interjection shows its author A local submission echo carries no source, so the author line appears once the Host records the input in the Inbox, not when the reader sends it. (cherry picked from 42001b1294d)(partial: liveshare client files only) * docs(liveshare): describe the seat source arriving as row props (cherry picked from commit 466e25328c5c42c792bfb30bba05ff790259bf99) * fix(liveshare): refuse /permission to share readers The commands executor runs a command handler inside the owner Host with no reader-specific narrowing, so a reader line such as `/permission danger-full-access` left the shared Session unconfined with no approval. The read role's condition now parses the `commands/execute` line and refuses the owner-only command names, starting with `/permission`, with the new `command-owner-only` reason the viewer page classifies. Every other command keeps following visibility. * feat(permission-presets): add the permissionPresets/set Remote The `/permission` command switches a Session's sandbox mode and approval policy inside the owner Host's own handler, which gives a share reader that reaches `commands/execute` no endpoint decision to meet. The switch now has a Remote face: `permissionPresets/set` names the Session it writes as its `session` resource, so the Gateway decides who may call it before any preset is resolved or any knob changes. The request carries the Session id and the preset name only. An unknown preset and a Session this process does not hold live both refuse with `gateway/bad-request` before writing. The call reports the selection the Session reads back after the switch. The command reaches the same switch, keeping its ordering and its `success` and `error` text. Because a Remote parameter cannot carry an Agent, the command supplies the approval write itself so its model-visible policy notice still follows the switch. Co-Authored-By: DeepSeek Harness <[email protected]> * fix(liveshare): classify permissionPresets/set owner-only The new preset endpoint writes the source Session's sandbox mode and approval policy, so no share reader role may reach it at any tier. The viewer endpoint classification records it as owner-only, and the viewer access policy spec proves a reader is refused on the shared Session, on its own forks, and on a Session outside the share, and that no reader grant carries the action. The owner-only command whitelist stays as the second defense: the commands handler runs inside the owner Host, so a reader line must not depend on that handler continuing to route through the endpoint. Co-Authored-By: DeepSeek Harness <[email protected]> * test(liveshare): keep every permission preset endpoint owner-only The classification table's completeness gate proves a new generated endpoint has a row, but not that the row keeps a reader out. This case reads the table and fails when any `permissionPresets/*` endpoint is classified as anything other than owner-only, so an endpoint added there without its class checked turns the suite red instead of widening a reader's reach. Co-Authored-By: DeepSeek Harness <[email protected]> * docs(catalog): regenerate for the preset set Remote The new `permissionPresets/set` Remote adds its signature and its request type to the generated service and type catalogs, maps the request type to the permission presets subsystem page, and shifts the permission preset config source line. The permission presets subsystem pages describe the write path and its Remote face on both sides. Co-Authored-By: DeepSeek Harness <[email protected]> * test: construct SessionId values and keep the approval notice lock The rebased specs called SessionId as a value while importing it as a type, so every case threw ReferenceError. Construct the ids the way the packages already do, and keep the /permission case that locks the single model-visible approval notice. * test(liveshare): load the terminal controller without a built artifact The spec resolved a generated typert artifact at module load, so a clean checkout failed before any case ran. * docs(liveshare): state the reader limits the review asked about Marks the answer path's dependence on timed asks, records that @ mentions list every host session, and explains which commands stay owner-only. * feat(liveshare): let a viewer manage the goal of a visible Session The goal is Session data, not the workspace sandbox, so the same visibility rule that already covers goals/get and goals/edit applies to create, pause, resume, complete and clear. The /goal command reaches the same service, so the endpoint and the command now agree. # Conflicts: # packages/experimental/liveshare/README.i18n.yaml * fix(liveshare): keep the terminal component titles The shareable mark's localized titles were spread onto the metadata record, which put `en` and `zh` at the top level instead of in the `titles` field the catalog reads. A core bundle without display metadata therefore offered the terminal with no product name at all. * fix(workspace-files): decide the path scope before stat A non-owner read probed the path with `lstat` before it checked containment, so reading an absent path outside the workspace answered `not-found` while an existing one answered `outside-workspace`. That let a share reader probe whether any path on the owner's machine exists. Every confined read now resolves and confines its target first: `read`, `stat`, `readBytes` (including a path relative to a base file) and `list`. The final `lstat` still reports the component's own kind, and the owner keeps the filesystem's authority, including its previous answer for an absent path. * docs(liveshare): drop the queue-verb mention `session/updateQueue` is not in the viewer Session read role, and viewer queue management is not part of this change. The role's rationale now names the reach it actually carries, and the workspace file actions no longer leak whether a path outside the workspace exists. * test(liveshare): describe the terminal suite's actual coverage * chore: regenerate the catalogs the viewer capability change moves session-reference, user-questions and the permission presets all feed the Cordis, persistence and doc-graph generators, so their artifacts were stale. * fix(liveshare): keep the command refusal copy paired and cover the file paths The English notice read "/permission on", which the locale gate tokenised together while the translations kept the command alone. The workspace-file and preset paths the coverage lane flagged now have cases of their own. * test(workspace-files): accept either refusal code for a UNC base Windows resolves an unreachable UNC host through the local backend's ancestor walk, which reports an IO failure instead of the not-found POSIX reads. Both refuse the read; the code belongs to that backend, not to the path-scope decision this case covers. * refactor(liveshare): leave the command surface to its own change Running a slash command is a separate decision from what a reader may read: the executor wraps several capabilities in one opaque call, so the endpoint that admits it is not the place to decide them. This change keeps the reader capabilities and the preset endpoint, and returns the command wiring when the command surface itself is reshaped. * refactor(liveshare): leave the workspace file preview and terminal grant out Reading a Session's data and reaching into the owner's workspace or shell are different promises: the first follows visibility, the second changes what the owner's machine does. This change keeps the reader capabilities that describe Session data and returns the other two for their own discussion. * refactor(jobs): let the session resolver name the job endpoints' Session The session resource resolver already reads a top-level sessionId, so the explicit readers restated what it derives. Removing them keeps one rule for how a Session resource is named. * test(liveshare): drop the workspace preview stubs the strip left behind The viewer shell no longer opens workspace files, so the fixture route and the assertion about it no longer describe anything. * fix(jobs): bind the job endpoints to the Session they name The session resolver reads a top-level sessionId, but these methods take a request object and no lookup parameter, so the request fell through to the global resource and a reader was refused. The explicit readers state the Session the Gateway must authorise. * refactor(jobs): let the session resolver name the job endpoints' Session The session controller's resolver already reads the sessionId of the first object argument, so an explicit reader on these methods restated a rule the Gateway already applies. The tests now install the session controller and assert the resource the production composition produces. * refactor(session-controller): take the resolve input as one argument An exported function cannot destructure its parameters, because the JSDoc gate names them one by one. * docs(liveshare): describe the capabilities this change actually opens The workspace file preview, the terminal grant and the command surface moved out of this change, so the package reference and the PR description now state what remains. * docs(persistence): refresh the catalog after the preset JSDoc edit The permission-presets module doc grew a line, so the recorded source line for its persisted event moved from 60 to 61. --------- Co-authored-by: DeepSeek Harness <[email protected]>
18 KiB
用户交互
English | 中文
dsh-user-questions 的用户交互 seam。它是工具或权限插件需要人类回答后 agent(智能体)才能继续时所使用的、提供方无关的词汇。Agent-scoped waterfall listener 组合可用的 UI 界面,其中包括转发到已连接 client 的 listener。
源码:packages/interaction/user-questions/src/index.ts
问题选项
AskUserQuestionOption 包含一个可供选择的选项。label 是面向用户的选项文字,同时也是面向模型的选中值;description 是可选的 UI 帮助文本。
/** One selectable answer offered to the user. */
interface AskUserQuestionOption {
/** User-facing label. */
label: string
/** Optional extra context rendered by capable UIs. */
description?: string
}
呈现意图
AskUserQuestionIntent 改变呈现方式,保留选项标签和调用方的决策规则。plan-review 指定批准选项,并要求提供计划正文。approval 要求只有一个阻塞式问题,带有说明以及互不相同的拒绝、允许和可选的始终允许标签,完整对应已提供的选项,不支持多选或计时等待。CUA 前端通过现有 composer 呈现自己的固定审批;普通问答和计划审阅继续使用原有呈现。
/**
* A caller-declared presentation intent: the question IS this kind of
* decision, so a UI that recognises the tag may present it as such instead of as a
* generic option list. Tagged so further intents can be added; a UI that does
* not know a tag renders the generic flow, and the answer encoding is identical
* either way — an intent changes presentation only, never the protocol.
*/
type AskUserQuestionIntent = {
/** A plan submitted for review: `detail` is the plan markdown `ask()` requires, and the decision approves or declines it. */
kind: 'plan-review'
/**
* The option label that approves the plan; every other option declines it.
* Named rather than positional so no UI infers the verdict from option order.
* An `approve` naming no option of its own question is rejected at `ask()`.
*/
approve: string
/** Logged tool invocation whose arguments contain the reviewed plan. */
callId?: ToolCallId
} | {
/** A blocking permission decision with fixed actions and no free-text answer. */
kind: 'approval'
/** Option label granting the scope described by the caller. */
approve: string
/** Option label refusing the requested access. */
reject: string
/** Optional persistent grant offered only when the caller supports it. */
always?: string
/** Metadata for human recognition; the caller admits icon sources, which the UI may load as URLs. Never an authorization identity. */
subject?: { name: string; icon?: string }
/** Localized question and limited-grant label; fixed cards own reject/always wording. Option labels remain answer values. */
display?: {
question: { en: string; [locale: string]: string }
detail?: { en: string; [locale: string]: string }
approve?: { en: string; [locale: string]: string }
}
}
问题条目
AskUserQuestionItem 是请求中的一个问题。调用方提供稳定的 id,它会随答案原样返回,使批量问题仍可路由。可选的 detail 携带辅助文本;提供方会将其随问题渲染,但不会放入可选选项标签。
/** One question in a user-questions request. */
interface AskUserQuestionItem {
/** Stable caller-provided question id, echoed in the answer. */
id: string
/** The question to display. */
question: string
/** Optional supporting detail rendered with the question but kept out of option labels. */
detail?: string
/** Optional short heading/group label. */
header?: string
/** Optional choices the UI can render as a menu. */
options?: AskUserQuestionOption[]
/** Whether more than one option may be selected. Defaults to single-select. */
multiSelect?: boolean
/** Optional presentation intent for capable UIs; absent asks for the generic option list. */
intent?: AskUserQuestionIntent
}
提问请求
AskUserQuestionRequest 是跨包请求。questions 是数组,这样 UI 可以在一个流程中呈现相关提示,同时保持每个回答有稳定的 id。如提供 agent,它必须与存活调用方是同一实例;只有当当前注册表将该实例识别为运行时根时,交互 seam 才会接纳该 agent。
/** Request for a human answer. */
interface AskUserQuestionRequest extends AskUserQuestionRequestEvent {}
回答
提供方为每个问题 id 返回一个回答项。selected 包含选中的选项标签,custom 在用户输入自由文本时携带「其他」回答。对于单选题,custom 会覆盖选中的选项,且 selected 为空。对于多选题,custom 可以补充 selected 中的标签。UI 也可以使用 selected 为空且不含 custom 的回答项,在其余问题均已完成的批次中保留被跳过的问题。
/** Answer to one question. */
interface AskUserQuestionAnswerItem {
/** The answered question id. */
id: string
/** Selected option labels. May accompany custom text for a multi-select question. */
selected: string[]
/** Optional free-text "Other" answer. */
custom?: string
}
/** The human's answer. */
interface AskUserQuestionAnswer {
/** Structured answers keyed by question id. */
answers: AskUserQuestionAnswerItem[]
}
计时回答器收到 wait: { callId, timed: true }。调用 id 标识卡片及前台等待。Client 调用 attachWait 接手等待并取得剩余时长;传输层转发原事件,不检查或改写这些字段。不带 timed 的 wait 表示无限期等待的具名卡片请求;没有 wait 则表示不带卡片 key 的阻塞请求。
/** Client-safe payload declared for the user-question answerer waterfall. */
interface AskUserQuestionRequestEvent {
/** Questions to display. */
questions: AskUserQuestionItem[]
/** Agent identity projected to the corresponding Client Context in transit. */
agent?: Agent
/** Cancellation lifetime of the pending request. */
signal?: AbortSignal
/**
* Tool call the Client card is keyed by. Timed answerers attach to the
* business wait stream before starting their local countdown.
*/
wait?: {
/** Tool call the Client card is keyed by. */
callId: ToolCallId
/** True for a foreground wait that requires a Client claim; absent for indefinite waits. */
timed?: boolean
}
}
计时问题与迟到回复
计时问题在有界的前台窗口内等待,然后让 agent 继续独立工作。用户在窗口内回答,工具返回整批答案;否则 TimedUserQuestionResult 为 { pending: true, callId }。pending 表示问题仍可回答,不是空答案、拒绝、确认或授权。
/** Timed ask result returned when the foreground answer window closes. */
type TimedUserQuestionResult = AskUserQuestionAnswer | { pending: true; callId: ToolCallId }
Client 接手通过业务 Remote stream 表达,不等同于 Gateway 投递。TimedQuestionWait 保存原 Host deadline,仅在没有接手记录时运行计时器。attachWait stream 发出当前剩余时长,Client 用本地时钟倒计时。聚焦、编辑和「慢慢回答」状态仍归本地所有。stream 取消释放相应接手记录;最后一个接手方离开后,Host 恢复原 deadline。无人接手时超时中止前台 waterfall 专属的 signal 并返回 pending,不取消 Turn。Gateway 与 api-remotes 不包含问答专属计时策略。
userQuestions Session 投影把现有事件折叠成可回答的问题集合与已结算的集合;不记录任何等待状态、聚焦状态或 deadline。每个 request/header 都记录了模型看到的确切工具 schema。只有请求头声明了带 timeout 参数的 timed ask_user_question schema,投影才跟踪原生调用;阻塞式 legacy 工具从不声明它。原生 tool/call 打开一个问题。tool/result 只在两种情况下把它标为 continued:带 pending 载荷,或是 Session resume 修复补写的 TOOL_OUTCOME_UNKNOWN 合成结果;回答批次把它连同该批次移入 settled,其他结果或失败都丢弃它。run_code 的 PTC 子调用若在 tool/ptc-dispatch 结果中返回 pending,也会进入投影,尽管请求头只列出 run_code。迟到回复在消息获准成为 user/message 时,才把已继续的问题连同消息中的回答批次移入 settled:计时调用自己的结果记录的是超时,transcript 行无处可读用户最终的选择。排队的回复可在准入前取消,此时问题仍可回答。回复正文不含可读批次时,该调用以零答案结算;回复指向的调用已不在可回答集合中时不改变任何内容。
/** `open` while the tool call may still return the answer; `continued` once the answer can only arrive as a new turn. */
type UserQuestionState = 'open' | 'continued'
/** One unanswered timed `ask_user_question` call reconstructed from the Session log. */
interface PendingUserQuestion {
readonly callId: ToolCallId
readonly questions: readonly AskUserQuestionItem[]
readonly state: UserQuestionState
}
/**
* One timed `ask_user_question` call and the answers it settled with: the
* batch its own result carried when the user answered inside the window,
* otherwise the batch its late reply carried, because that call's own result
* recorded the timeout. A transcript row reads what the user finally answered
* from here, and only a call listed here was a timed one.
*/
interface SettledUserQuestion {
/** The settled call. */
readonly callId: ToolCallId
/** The recorded batch, one entry per question; empty when the late reply carried none. */
readonly answers: readonly AskUserQuestionAnswerItem[]
}
/**
* Both halves of one Session's timed `ask_user_question` state, as every
* Client reads them. A call made while the blocking legacy tool was in
* effect appears in neither half.
*/
interface UserQuestionProjectionView {
/** Calls that can still take an answer, in ask order. */
readonly active: readonly PendingUserQuestion[]
/** Calls an answer settled, in settlement order. */
readonly settled: readonly SettledUserQuestion[]
}
开放中的问题只能通过 waterfall 回答。问题变为 continued 后,answer Remote 方法向所属 agent 排入一条用户消息,并在其空闲时唤醒它。消息的 source 为 user-question-reply,outcome 为 answered,正文是 answer_to_pending_question 载荷。开放或未知调用返回 false;回复仍在排队时的第二次提交以 REPLY_QUEUED 拒绝,Host 重启后也一样;遗漏或重复问题的回答批次以 BAD_ANSWER 拒绝。
收起 Client 面板不会发送内容。前台超时只结束工具等待。已继续的问题没有期限;在回复进入会话前,问题仍可回答。
Host 重启后,Session 重开时 Remote 层会恢复根 agent。之后的迟到回复会作为新一轮进入。
错误
UserQuestionError 继承 HarnessError,因此 ctx.tools.execute() 会保留 { name, code },用于面向模型的工具失败,如 EMPTY_QUESTIONS、BAD_INTENT、NO_PROVIDER、ASK_ABORTED 或 UI 侧取消。不是 HarnessError 的应答方失败会变为 PROVIDER_ERROR,保留原 message,原错误作为 cause;其他 HarnessError 保留自身的 name 与 code。
/** Stable error taxonomy for user-questions failures. */
class UserQuestionError extends HarnessError {
constructor(message: string, code: string, options?: ErrorOptions) {
super(message, code, options)
this.name = 'UserQuestionError'
}
}
Cordis API
Generated from source by scripts/gen-cordis-catalog.ts (verified fresh by pnpm run verify-cordis-catalog in doc-sync; regenerate with pnpm run gen-cordis-catalog) — the language sides differ only in locale-specific paired document paths. Signature blocks use a ts cordis-catalog fence and keep the original source JSDoc; dispatch modes are defined in the primer, and the framework-inherited ctx API lives in cordis-api/inherited.md.
ctx.userQuestions — UserQuestionService
ctx.userQuestions: validation plus the scoped answerer waterfall.
/**
* Answer a continued question. The reply is steered into the agent as a
* user message whose source names the call; that message is also the
* record that closes the question in the projection.
*
* The only call this method can answer is one the projection lists as
* `continued` on this Session, and it steers a user message into the running
* turn, so it speaks for the person the Session runs for. A LiveShare reader
* reaches it through the Session read role, which is safe only while an
* approval question cannot become `continued`: the projection tracks only
* calls made under the timed `ask_user_question` schema, and a call becomes
* `continued` only by returning the pending result a timed wait produces (or,
* for PTC, a pending dispatch) or by resume repair recording
* `TOOL_OUTCOME_UNKNOWN` for a call the process never finished. Plan review
* (`plan-review`) and the CUA approvals (`approval`) reach `ctx.userQuestions.ask`
* without a `wait` and without a `timeout`, so their result is a settled
* answer, an abort, or a failure, never a pending result, and they stay out
* of the projection. A future approval surface must keep asking without
* `wait`/`timeout`, or it must gain its own owner-only gate; giving it a timed
* form makes an approval answerable by a share viewer.
* @param agent - Live root agent for the owning Session.
* @param callId - Continued question identity.
* @param answer - Complete structured answer batch, one item per question of the call.
* @returns Whether the question is still continued (`false` when this Session
* lists no such continued call, or its composition carries no Session
* projections); an accepted reply stays queued until the agent admits its
* user message.
* @throws {UserQuestionError} `BAD_ANSWER` when the batch does not name each
* question of the call exactly once, or `REPLY_QUEUED` when a reply is
* already waiting for admission.
*/
@Remote answer(agent: Agent, callId: ToolCallId, answer: AskUserQuestionAnswer): boolean
/**
* Let one answer UI hold a live timed wait. Closing the stream releases its claim.
* @param agent - Live root agent owning the question.
* @param callId - Foreground tool call to attach to.
* @param signal - Remote stream cancellation, including Client disconnect.
* @returns One Host-computed remaining duration, or no frames once the wait ended.
*/
@Remote({ mode: 'stream' }) async *attachWait(agent: Agent, callId: ToolCallId, signal: AbortSignal): AsyncIterable<{ remainingMs: number }>
/**
* Foreground wait whose first settlement the Client decides: the Client
* rejects with `ASK_TIMED_OUT` when its countdown ends, and this method maps
* that code to the pending result.
* @param request - Questions, live owner agent, and abort signal.
* @param callId - Tool call identity the Client card is keyed by.
* @param timeoutMs - Positive foreground wait in milliseconds.
* @returns The answer when it arrives inside the window, otherwise a pending
* result, also when no connected Client claimed the request by the deadline.
* @throws {UserQuestionError} `BAD_TIMEOUT` for a non-integer, non-positive,
* or oversized wait.
*/
async askTimed( request: AskUserQuestionRequest & { agent: Agent }, callId: ToolCallId, timeoutMs: number, ): Promise<TimedUserQuestionResult>
/**
* Ask the scoped answerer waterfall and wait for the user's answer.
*
* When a caller supplies an agent, human interaction is valid only for the
* exact live instance of an ordinary Session. Explicit subagent origin
* rejects delegated callers; historical ordinary forks may retain parent
* metadata and still ask normally.
*
* @param request Questions, owner agent, and abort signal.
* @returns The answer chosen or typed by the human.
* @throws {UserQuestionError} code `ASK_ABORTED` when the supplied signal
* is already or becomes aborted, `CALLER_NOT_LIVE` when a supplied agent
* is not the registry's exact live instance, `DELEGATED_CALLER` when
* that live agent has subagent origin, or `PROVIDER_ERROR`, keeping the
* original message, when an answerer fails with a value that is not a
* `HarnessError`; a coded `HarnessError` from an answerer keeps its `name`
* and `code`.
*/
async ask(request: AskUserQuestionRequest): Promise<AskUserQuestionAnswer>
Types: Agent · ToolCallId
Source: packages/interaction/user-questions/src/index.ts
user-questions/* events
user-questions/request — waterfall
Ask composed answerers for structured user input. Return an answer to claim the request or call next() to delegate. Scope-filtered dispatch (@deepseek-ai/dsh-scope): agent-scoped listeners receive only that agent.
/**
* Ask composed answerers for structured user input. Return an answer to
* claim the request or call `next()` to delegate. Scope-filtered dispatch
* (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that agent.
* @param request - pending user-question request.
* @mode waterfall
*/
'user-questions/request'( this: Scoped<Agent>, request: AskUserQuestionRequestEvent, next: () => Promise<AskUserQuestionAnswer>, ): Promise<AskUserQuestionAnswer>