@deepseek-ai/dsh-user-questions 0.2.1-rc.3 → 0.2.2-alpha.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.
- package/README.i18n.yaml +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/lib/index.js +35 -7
- package/lib/typert.host.js +17 -9
- package/lib/typert.remote-client.js +2 -2
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.js +43 -17
- package/lib/types/projection.d.ts +0 -5
- package/lib/types/types.d.ts +29 -0
- package/locale/de.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/package.json +18 -18
package/README.i18n.yaml
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
en: 382a21c0ea17b2e4
|
|
16
16
|
zh: 1a4335e571de92dd
|
|
17
17
|
/deepseek-ai-dsh-user-questions/ask-a-question:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: 2563276cd9689955
|
|
19
|
+
zh: 561c750ceb799b9f
|
|
20
20
|
/deepseek-ai-dsh-user-questions/role:
|
|
21
21
|
en: 1a321b5a204dc4dd
|
|
22
22
|
zh: 5e30055a3774e606
|
package/README.md
CHANGED
|
@@ -26,9 +26,9 @@ Use `ctx.userQuestions` when a tool or permission flow needs a structured answer
|
|
|
26
26
|
|
|
27
27
|
Call `ask()` when work cannot continue without the answer. Call `askTimed()` when the agent may continue independent work after a foreground wait. An answer UI claims that wait through `attachWait`, receives the Host-computed remaining duration, and counts down on its own clock. Without a claim, including after the last Client disconnects, the service releases the model at the original deadline. The `userQuestions` projection derives durable questions from the tool call, its result, and the eventual reply; Client claims are not persisted.
|
|
28
28
|
|
|
29
|
-
For a single-select question, `custom` overrides the selected choice and `selected` is empty. For a multi-select question, `custom` may supplement the labels in `selected`. A UI may preserve a skipped item as `{ id, selected: [] }`, keeping the existing answer shape while retaining other answers in the batch.
|
|
29
|
+
For a single-select question, `custom` overrides the selected choice and `selected` is empty. For a multi-select question, `custom` may supplement the labels in `selected`. A UI may preserve a skipped item as `{ id, selected: [] }`, keeping the existing answer shape while retaining other answers in the batch. The `ask_user_question` tool tells the model that an item with empty `selected` and no `custom` is a user skip, so an answerer must not use that form for any other answer.
|
|
30
30
|
|
|
31
|
-
A question may carry a presentation `intent
|
|
31
|
+
A question may carry a presentation `intent`. `plan-review` names the approve option and uses `detail` as the plan. `approval` presents one blocking question as fixed reject, allow and optional always-allow actions; it may include subject metadata and localized copy. Its action labels must be distinct and cover exactly the offered options, with no multi-select or timed wait. `ask()` rejects invalid intents with `BAD_INTENT`. Both presentations return the original option labels, and an older UI can render the same options generically. The caller continues to own authorization and persistence.
|
|
32
32
|
|
|
33
33
|
When a request carries an agent, `ask()` authenticates its exact identity through the live `AgentRegistry` and admits only a runtime root. A live child cannot open a human interaction. An agentless programmatic request remains available to unscoped local waterfall listeners and fails with `NO_PROVIDER` when none accepts it.
|
|
34
34
|
|
package/README.zh.md
CHANGED
|
@@ -26,9 +26,9 @@ kind: "package-reference"
|
|
|
26
26
|
|
|
27
27
|
当工作无法在没有答案的情况下继续时调用 `ask()`。当 agent 可以在一段前台等待后继续独立工作时调用 `askTimed()`。回答 UI 通过 `attachWait` 接手等待,取得 Host 计算的剩余时长,并用本地时钟倒计时。没有接手方时,包括最后一个 Client 断开之后,服务在原 deadline 放行模型。`userQuestions` projection 从工具调用、其结果和最终回复派生持久问题;Client 接手状态不落盘。
|
|
28
28
|
|
|
29
|
-
对于单选题,`custom` 会覆盖选中的选项,且 `selected` 为空。对于多选题,`custom` 可以补充 `selected` 中的标签。UI 可以把跳过的条目保留为 `{ id, selected: [] }
|
|
29
|
+
对于单选题,`custom` 会覆盖选中的选项,且 `selected` 为空。对于多选题,`custom` 可以补充 `selected` 中的标签。UI 可以把跳过的条目保留为 `{ id, selected: [] }`,既维持现有回答形态,也保留该批次中的其他回答。`ask_user_question` 工具告诉模型,`selected` 为空且没有 `custom` 的条目表示用户跳过,因此回答方不能用这种形式表示其他回答。
|
|
30
30
|
|
|
31
|
-
问题可以携带呈现意图 `intent
|
|
31
|
+
问题可以携带呈现意图 `intent`。`plan-review` 指定批准选项,并将 `detail` 作为待审阅计划。`approval` 将一个阻塞式问题显示为拒绝、允许和可选的始终允许操作,可附带对象信息和本地化文案。操作标签必须互不相同,并完整对应已提供的选项,不支持多选或计时等待。`ask()` 以 `BAD_INTENT` 拒绝无效意图。两种呈现都返回原始选项标签,旧界面仍可显示通用选项列表。授权与持久化仍由调用方负责。
|
|
32
32
|
|
|
33
33
|
请求包含 agent 时,`ask()` 会通过当前 `AgentRegistry` 验证该 agent 与注册表中的存活实例是同一对象,并且只允许运行时根调用。存活子级不能发起人机交互。不含 agent 的程序化请求仍会交给本地未限定 scope 的 waterfall listener,若无人接受则以 `NO_PROVIDER` 失败。
|
|
34
34
|
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
1
2
|
import { HarnessError, ToolCallId, createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
2
3
|
import { scopeTarget } from "@deepseek-ai/dsh-scope";
|
|
3
4
|
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
@@ -484,13 +485,11 @@ let UserQuestionService = (() => {
|
|
|
484
485
|
});
|
|
485
486
|
}
|
|
486
487
|
static Config = z.object({});
|
|
487
|
-
|
|
488
|
+
userQuestionProjectionHandle = __runInitializers(this, _instanceExtraInitializers);
|
|
489
|
+
waits = /* @__PURE__ */ new Map();
|
|
488
490
|
queuedReplies = /* @__PURE__ */ new WeakMap();
|
|
489
491
|
constructor(ctx) {
|
|
490
492
|
super(ctx, "userQuestions");
|
|
491
|
-
ctx.inject(["sessionProjections"], (projectionCtx) => {
|
|
492
|
-
projectionCtx.sessionProjections.register(userQuestionProjectionDefinition);
|
|
493
|
-
});
|
|
494
493
|
ctx.effect(() => () => {
|
|
495
494
|
for (const calls of this.waits.values()) for (const wait of calls.values()) wait.close(abortedQuestion());
|
|
496
495
|
this.waits.clear();
|
|
@@ -528,13 +527,22 @@ let UserQuestionService = (() => {
|
|
|
528
527
|
if (calls?.get(callId)?.messageId !== messageId) return;
|
|
529
528
|
calls.delete(callId);
|
|
530
529
|
}
|
|
530
|
+
async [Service.init]() {
|
|
531
|
+
const binding = this.ctx.inject(["sessionProjections"], async (ctx) => {
|
|
532
|
+
this.userQuestionProjectionHandle = await ctx.sessionProjections.register(userQuestionProjectionDefinition);
|
|
533
|
+
return () => {
|
|
534
|
+
this.userQuestionProjectionHandle = void 0;
|
|
535
|
+
};
|
|
536
|
+
});
|
|
537
|
+
if (this.ctx.get("sessionProjections") !== void 0) await binding;
|
|
538
|
+
}
|
|
531
539
|
assertLiveRoot(agent) {
|
|
532
540
|
const agents = this.ctx.get("agents");
|
|
533
541
|
if (agents === void 0 || agents.get(agent.id) !== agent) throw new UserQuestionError("human interaction requires the exact live calling agent when an agent is supplied", "CALLER_NOT_LIVE");
|
|
534
542
|
if (!agents.roots().includes(agent)) throw new UserQuestionError("human interaction is unavailable while the calling agent is owned by another live agent; include the unresolved question or decision in the child agent's final result", "DELEGATED_CALLER");
|
|
535
543
|
}
|
|
536
544
|
continued(agent) {
|
|
537
|
-
return
|
|
545
|
+
return this.userQuestionProjectionHandle?.stateOf(agent.session).questions.active.filter((question) => question.state === "continued") ?? [];
|
|
538
546
|
}
|
|
539
547
|
/**
|
|
540
548
|
* Answer a continued question. The reply is steered into the agent as a
|
|
@@ -673,8 +681,28 @@ let UserQuestionService = (() => {
|
|
|
673
681
|
for (const question of request.questions) {
|
|
674
682
|
const intent = question.intent;
|
|
675
683
|
if (intent === void 0) continue;
|
|
676
|
-
|
|
677
|
-
|
|
684
|
+
const labels = intent.kind === "approval" ? [
|
|
685
|
+
intent.approve,
|
|
686
|
+
intent.reject,
|
|
687
|
+
...intent.always === void 0 ? [] : [intent.always]
|
|
688
|
+
] : [intent.approve];
|
|
689
|
+
const options = question.options ?? [];
|
|
690
|
+
const unoffered = labels.find((label) => !options.some((option) => option.label === label));
|
|
691
|
+
if (unoffered !== void 0) {
|
|
692
|
+
if (intent.kind === "plan-review") throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} whose approve label ${JSON.stringify(intent.approve)} names none of its options`, "BAD_INTENT");
|
|
693
|
+
throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} whose action label ${JSON.stringify(unoffered)} names none of its options`, "BAD_INTENT");
|
|
694
|
+
}
|
|
695
|
+
if (question.detail === void 0) {
|
|
696
|
+
const detail = intent.kind === "approval" ? "scope detail it requires" : "detail it reviews";
|
|
697
|
+
throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} without the ${detail}`, "BAD_INTENT");
|
|
698
|
+
}
|
|
699
|
+
if (intent.kind === "approval") {
|
|
700
|
+
if (request.questions.length !== 1) throw new UserQuestionError(`approval presentation requires one question; received ${request.questions.length}`, "BAD_INTENT");
|
|
701
|
+
if (question.multiSelect === true) throw new UserQuestionError(`approval question ${question.id} does not support multiSelect`, "BAD_INTENT");
|
|
702
|
+
if (request.wait !== void 0) throw new UserQuestionError(`approval question ${question.id} requires a blocking request without wait`, "BAD_INTENT");
|
|
703
|
+
if (new Set(labels).size !== labels.length) throw new UserQuestionError(`approval question ${question.id} requires distinct action labels; received ${JSON.stringify(labels)}`, "BAD_INTENT");
|
|
704
|
+
if (options.length !== labels.length) throw new UserQuestionError(`approval question ${question.id} requires ${labels.length} options matching its actions; received ${options.length}`, "BAD_INTENT");
|
|
705
|
+
}
|
|
678
706
|
}
|
|
679
707
|
const noAnswerer = () => Promise.reject(new UserQuestionError("no user-questions answerer accepted the request", "NO_PROVIDER"));
|
|
680
708
|
try {
|
package/lib/typert.host.js
CHANGED
|
@@ -115,7 +115,7 @@ const $remote = createTypertRemoteInfo({
|
|
|
115
115
|
description: 'Whether the question is still continued; an accepted reply stays queued until the agent admits its user message.',
|
|
116
116
|
jsonSchema: {"type":"boolean"},
|
|
117
117
|
},
|
|
118
|
-
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":
|
|
118
|
+
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":170,"column":3},
|
|
119
119
|
},
|
|
120
120
|
'userQuestions/attachWait': {
|
|
121
121
|
service: 'userQuestions',
|
|
@@ -172,7 +172,7 @@ const $remote = createTypertRemoteInfo({
|
|
|
172
172
|
description: 'One Host-computed remaining duration, or no frames once the wait ended.',
|
|
173
173
|
jsonSchema: {"type":"object","properties":{"remainingMs":{"type":"number"}},"required":["remainingMs"],"additionalProperties":true},
|
|
174
174
|
},
|
|
175
|
-
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":
|
|
175
|
+
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":221,"column":10},
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
}, z)
|
|
@@ -229,7 +229,7 @@ export const TYPERT = {
|
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
"name": "Agent",
|
|
232
|
-
"declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
|
|
232
|
+
"declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly model: Model;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
"name": "AgentCancelCause",
|
|
@@ -241,7 +241,7 @@ export const TYPERT = {
|
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
243
|
"name": "AgentOptions",
|
|
244
|
-
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId;\n maxTokens?: number;\n subagentDepth?: number;\n}"
|
|
244
|
+
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId | undefined;\n maxTokens?: number;\n subagentDepth?: number;\n}"
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
"name": "AgentStatus",
|
|
@@ -273,7 +273,7 @@ export const TYPERT = {
|
|
|
273
273
|
},
|
|
274
274
|
{
|
|
275
275
|
"name": "AskUserQuestionIntent",
|
|
276
|
-
"declaration": "export type AskUserQuestionIntent = { kind: 'plan-review'; approve: string; callId?: ToolCallId; };"
|
|
276
|
+
"declaration": "export type AskUserQuestionIntent = { kind: 'plan-review'; approve: string; callId?: ToolCallId; } | { kind: 'approval'; approve: string; reject: string; always?: string; subject?: { name: string; icon?: string; }; display?: { question: { en: string; [locale: string]: string; }; detail?: { en: string; [locale: string]: string; }; approve?: { en: string; [locale: string]: string; }; }; };"
|
|
277
277
|
},
|
|
278
278
|
{
|
|
279
279
|
"name": "AskUserQuestionItem",
|
|
@@ -585,7 +585,11 @@ export const TYPERT = {
|
|
|
585
585
|
},
|
|
586
586
|
{
|
|
587
587
|
"name": "MessageSourceMap",
|
|
588
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n '
|
|
588
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'tool-registry': { kind: 'tool-registry'; };\n 'action-cards': { kind: 'action-cards'; through: SessionSeq; } & ContextFormed;\n 'runtime-context': { kind: 'runtime-context'; } & ContextFormed;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'working-directory': { kind: 'working-directory'; };\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'compact-checkpoint': CompactionCheckpointSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n 'user-question-reply': { kind: 'user-question-reply'; callId: ToolCallId; outcome: 'answered'; };\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'plan-mode': { kind: 'plan-mode'; } & ContextFormed;\n schedule: { kind: 'schedule'; } & ContextFormed;\n 'session-reference': SessionReferenceSource;\n webhook: { readonly kind: 'webhook'; readonly provider: string; readonly source: WebhookSourceId; readonly deliveryId: WebhookDeliveryId; readonly ruleId: WebhookRuleId; readonly form: 'notice'; readonly summary: string; };\n}"
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"name": "Model",
|
|
592
|
+
"declaration": "export interface Model {\n current(): Readonly<ModelSelection> | undefined;\n select(selection: Readonly<ModelSelection>): void;\n}"
|
|
589
593
|
},
|
|
590
594
|
{
|
|
591
595
|
"name": "ModelMessageSource",
|
|
@@ -593,7 +597,7 @@ export const TYPERT = {
|
|
|
593
597
|
},
|
|
594
598
|
{
|
|
595
599
|
"name": "ModelSelection",
|
|
596
|
-
"declaration": "export interface ModelSelection {\n
|
|
600
|
+
"declaration": "export interface ModelSelection {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n}"
|
|
597
601
|
},
|
|
598
602
|
{
|
|
599
603
|
"name": "OneShotScheduleDispatchChange",
|
|
@@ -613,7 +617,7 @@ export const TYPERT = {
|
|
|
613
617
|
},
|
|
614
618
|
{
|
|
615
619
|
"name": "PrincipalMap",
|
|
616
|
-
"declaration": "export interface PrincipalMap {\n owner: { readonly kind: 'owner'; };\n}"
|
|
620
|
+
"declaration": "export interface PrincipalMap {\n owner: { readonly kind: 'owner'; };\n 'share-viewer': ShareViewerPrincipal;\n}"
|
|
617
621
|
},
|
|
618
622
|
{
|
|
619
623
|
"name": "ProviderRequestId",
|
|
@@ -685,7 +689,7 @@ export const TYPERT = {
|
|
|
685
689
|
},
|
|
686
690
|
{
|
|
687
691
|
"name": "SessionEventMap",
|
|
688
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n '
|
|
692
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'model/selection': ModelSelection;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'agent-preset/selected': { agentPreset: string; };\n 'job/registered': JobRegisteredData;\n 'job/settled': JobSettledData;\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'working-directory/change': { cwd: string; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'permission/preset': { preset: string; };\n 'subagent/descriptor': SubagentDescriptorData;\n 'subagent/catalog': SubagentCatalogEvent;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'feedback/record': FeedbackRecord;\n 'llm/retry': LlmRetryEventData;\n 'llm/retry-started': LlmRetryStartedEventData;\n 'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 2; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'plan/mode': { active: boolean; };\n 'schedule/change': ScheduleChange;\n 'subagent/model-selection-policy': { allowedModels: AllowedModelRoute[]; };\n 'workspace/changes': { turn: number; };\n}"
|
|
689
693
|
},
|
|
690
694
|
{
|
|
691
695
|
"name": "SessionEventType",
|
|
@@ -735,6 +739,10 @@ export const TYPERT = {
|
|
|
735
739
|
"name": "SessionTitleSource",
|
|
736
740
|
"declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?: SessionTitleModelIdentity; } | { readonly kind: 'user'; };"
|
|
737
741
|
},
|
|
742
|
+
{
|
|
743
|
+
"name": "ShareViewerPrincipal",
|
|
744
|
+
"declaration": "export interface ShareViewerPrincipal {\n readonly kind: 'share-viewer';\n readonly shareId: string;\n readonly actor: { readonly providerId: string; readonly tenantId: string; readonly subjectId: string; readonly displayName?: string; };\n}"
|
|
745
|
+
},
|
|
738
746
|
{
|
|
739
747
|
"name": "SkillInvocationSource",
|
|
740
748
|
"declaration": "export interface SkillInvocationSource {\n readonly kind: 'skill-invocation';\n readonly name: string;\n readonly form: 'instructions';\n}"
|
|
@@ -115,7 +115,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
|
|
|
115
115
|
description: 'Whether the question is still continued; an accepted reply stays queued until the agent admits its user message.',
|
|
116
116
|
jsonSchema: {"type":"boolean"},
|
|
117
117
|
},
|
|
118
|
-
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":
|
|
118
|
+
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":170,"column":3},
|
|
119
119
|
},
|
|
120
120
|
'userQuestions/attachWait': {
|
|
121
121
|
service: 'userQuestions',
|
|
@@ -172,7 +172,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
|
|
|
172
172
|
description: 'One Host-computed remaining duration, or no frames once the wait ended.',
|
|
173
173
|
jsonSchema: {"type":"object","properties":{"remainingMs":{"type":"number"}},"required":["remainingMs"],"additionalProperties":true},
|
|
174
174
|
},
|
|
175
|
-
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":
|
|
175
|
+
sourceLocation: {"file":"packages/interaction/user-questions/src/index.ts","line":221,"column":10},
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
}, z)
|
package/lib/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module @deepseek-ai/dsh-user-questions
|
|
8
8
|
*/
|
|
9
|
-
import { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
10
10
|
import { HarnessError, type ToolCallId } from '@deepseek-ai/dsh-llm';
|
|
11
11
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
12
12
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
@@ -34,10 +34,12 @@ export declare class UserQuestionError extends HarnessError {
|
|
|
34
34
|
/** `ctx.userQuestions`: validation plus the scoped answerer waterfall. */
|
|
35
35
|
export declare class UserQuestionService extends TypertRemoteService {
|
|
36
36
|
static Config: z<Schemastery.ObjectS<{}>, Schemastery.ObjectT<{}>, "plain">;
|
|
37
|
+
private userQuestionProjectionHandle;
|
|
37
38
|
private readonly waits;
|
|
38
39
|
private readonly queuedReplies;
|
|
39
40
|
constructor(ctx: Context);
|
|
40
41
|
private releaseReply;
|
|
42
|
+
protected [Service.init](): Promise<void>;
|
|
41
43
|
private assertLiveRoot;
|
|
42
44
|
private continued;
|
|
43
45
|
/**
|
package/lib/types/index.js
CHANGED
|
@@ -40,6 +40,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
40
40
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
41
41
|
done = true;
|
|
42
42
|
};
|
|
43
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
43
44
|
import { createUserMessage, HarnessError } from '@deepseek-ai/dsh-llm';
|
|
44
45
|
import { scopeTarget } from '@deepseek-ai/dsh-scope';
|
|
45
46
|
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
@@ -87,13 +88,11 @@ let UserQuestionService = (() => {
|
|
|
87
88
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
88
89
|
}
|
|
89
90
|
static Config = z.object({});
|
|
90
|
-
|
|
91
|
+
userQuestionProjectionHandle = __runInitializers(this, _instanceExtraInitializers);
|
|
92
|
+
waits = new Map();
|
|
91
93
|
queuedReplies = new WeakMap();
|
|
92
94
|
constructor(ctx) {
|
|
93
95
|
super(ctx, 'userQuestions');
|
|
94
|
-
ctx.inject(['sessionProjections'], (projectionCtx) => {
|
|
95
|
-
projectionCtx.sessionProjections.register(userQuestionProjectionDefinition);
|
|
96
|
-
});
|
|
97
96
|
ctx.effect(() => () => {
|
|
98
97
|
for (const calls of this.waits.values()) {
|
|
99
98
|
for (const wait of calls.values())
|
|
@@ -143,6 +142,14 @@ let UserQuestionService = (() => {
|
|
|
143
142
|
return;
|
|
144
143
|
calls.delete(callId);
|
|
145
144
|
}
|
|
145
|
+
async [Service.init]() {
|
|
146
|
+
const binding = this.ctx.inject(['sessionProjections'], async (ctx) => {
|
|
147
|
+
this.userQuestionProjectionHandle = await ctx.sessionProjections.register(userQuestionProjectionDefinition);
|
|
148
|
+
return () => { this.userQuestionProjectionHandle = undefined; };
|
|
149
|
+
});
|
|
150
|
+
if (this.ctx.get('sessionProjections') !== undefined)
|
|
151
|
+
await binding;
|
|
152
|
+
}
|
|
146
153
|
assertLiveRoot(agent) {
|
|
147
154
|
const agents = this.ctx.get('agents');
|
|
148
155
|
if (agents === undefined || agents.get(agent.id) !== agent) {
|
|
@@ -154,8 +161,7 @@ let UserQuestionService = (() => {
|
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
continued(agent) {
|
|
157
|
-
|
|
158
|
-
return (state?.questions.active ?? []).filter(question => question.state === 'continued');
|
|
164
|
+
return this.userQuestionProjectionHandle?.stateOf(agent.session).questions.active.filter(question => question.state === 'continued') ?? [];
|
|
159
165
|
}
|
|
160
166
|
/**
|
|
161
167
|
* Answer a continued question. The reply is steered into the agent as a
|
|
@@ -301,23 +307,43 @@ let UserQuestionService = (() => {
|
|
|
301
307
|
const agent = request.agent;
|
|
302
308
|
if (agent !== undefined)
|
|
303
309
|
this.assertLiveRoot(agent);
|
|
304
|
-
// A presentation intent asserts two things the types cannot: that the
|
|
305
|
-
// named approve label is one of this question's own options, and that a
|
|
306
|
-
// plan-review carries the plan it is a review of. A UI honouring the
|
|
307
|
-
// intent answers with that label, and shows that detail as the plan, so
|
|
308
|
-
// either gap would put a choice the asker never offered — or an approval of
|
|
309
|
-
// something invisible — in front of the user. Caught at the asker, where
|
|
310
|
-
// the mistake is, rather than in each UI.
|
|
311
310
|
for (const question of request.questions) {
|
|
312
311
|
const intent = question.intent;
|
|
313
312
|
if (intent === undefined)
|
|
314
313
|
continue;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
314
|
+
const labels = intent.kind === 'approval'
|
|
315
|
+
? [intent.approve, intent.reject, ...intent.always === undefined ? [] : [intent.always]]
|
|
316
|
+
: [intent.approve];
|
|
317
|
+
const options = question.options ?? [];
|
|
318
|
+
const unoffered = labels.find(label => !options.some(option => option.label === label));
|
|
319
|
+
if (unoffered !== undefined) {
|
|
320
|
+
if (intent.kind === 'plan-review') {
|
|
321
|
+
throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} whose approve label `
|
|
322
|
+
+ `${JSON.stringify(intent.approve)} names none of its options`, 'BAD_INTENT');
|
|
323
|
+
}
|
|
324
|
+
throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} whose action label `
|
|
325
|
+
+ `${JSON.stringify(unoffered)} names none of its options`, 'BAD_INTENT');
|
|
318
326
|
}
|
|
319
327
|
if (question.detail === undefined) {
|
|
320
|
-
|
|
328
|
+
const detail = intent.kind === 'approval' ? 'scope detail it requires' : 'detail it reviews';
|
|
329
|
+
throw new UserQuestionError(`question ${question.id} declares intent ${intent.kind} without the ${detail}`, 'BAD_INTENT');
|
|
330
|
+
}
|
|
331
|
+
if (intent.kind === 'approval') {
|
|
332
|
+
if (request.questions.length !== 1) {
|
|
333
|
+
throw new UserQuestionError(`approval presentation requires one question; received ${request.questions.length}`, 'BAD_INTENT');
|
|
334
|
+
}
|
|
335
|
+
if (question.multiSelect === true) {
|
|
336
|
+
throw new UserQuestionError(`approval question ${question.id} does not support multiSelect`, 'BAD_INTENT');
|
|
337
|
+
}
|
|
338
|
+
if (request.wait !== undefined) {
|
|
339
|
+
throw new UserQuestionError(`approval question ${question.id} requires a blocking request without wait`, 'BAD_INTENT');
|
|
340
|
+
}
|
|
341
|
+
if (new Set(labels).size !== labels.length) {
|
|
342
|
+
throw new UserQuestionError(`approval question ${question.id} requires distinct action labels; received ${JSON.stringify(labels)}`, 'BAD_INTENT');
|
|
343
|
+
}
|
|
344
|
+
if (options.length !== labels.length) {
|
|
345
|
+
throw new UserQuestionError(`approval question ${question.id} requires ${labels.length} options matching its actions; received ${options.length}`, 'BAD_INTENT');
|
|
346
|
+
}
|
|
321
347
|
}
|
|
322
348
|
}
|
|
323
349
|
const noAnswerer = () => Promise.reject(new UserQuestionError('no user-questions answerer accepted the request', 'NO_PROVIDER'));
|
|
@@ -82,9 +82,4 @@ export declare const userQuestionProjectionDefinition: {
|
|
|
82
82
|
};
|
|
83
83
|
stateVersion: number;
|
|
84
84
|
};
|
|
85
|
-
declare module '@deepseek-ai/dsh-session-projection/types' {
|
|
86
|
-
interface SessionProjectionStateMap {
|
|
87
|
-
userQuestions: UserQuestionProjectionState;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
85
|
//# sourceMappingURL=projection.d.ts.map
|
package/lib/types/types.d.ts
CHANGED
|
@@ -27,6 +27,35 @@ export type AskUserQuestionIntent = {
|
|
|
27
27
|
approve: string;
|
|
28
28
|
/** Logged tool invocation whose arguments contain the reviewed plan. */
|
|
29
29
|
callId?: ToolCallId;
|
|
30
|
+
} | {
|
|
31
|
+
/** A blocking permission decision with fixed actions and no free-text answer. */
|
|
32
|
+
kind: 'approval';
|
|
33
|
+
/** Option label granting the scope described by the caller. */
|
|
34
|
+
approve: string;
|
|
35
|
+
/** Option label refusing the requested access. */
|
|
36
|
+
reject: string;
|
|
37
|
+
/** Optional persistent grant offered only when the caller supports it. */
|
|
38
|
+
always?: string;
|
|
39
|
+
/** Metadata for human recognition; the caller admits icon sources, which the UI may load as URLs. Never an authorization identity. */
|
|
40
|
+
subject?: {
|
|
41
|
+
name: string;
|
|
42
|
+
icon?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Localized question and limited-grant label; fixed cards own reject/always wording. Option labels remain answer values. */
|
|
45
|
+
display?: {
|
|
46
|
+
question: {
|
|
47
|
+
en: string;
|
|
48
|
+
[locale: string]: string;
|
|
49
|
+
};
|
|
50
|
+
detail?: {
|
|
51
|
+
en: string;
|
|
52
|
+
[locale: string]: string;
|
|
53
|
+
};
|
|
54
|
+
approve?: {
|
|
55
|
+
en: string;
|
|
56
|
+
[locale: string]: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
30
59
|
};
|
|
31
60
|
/** One question in a user-questions request. */
|
|
32
61
|
export interface AskUserQuestionItem {
|
package/locale/de.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-user-questions",
|
|
3
3
|
"description": "Abstract user-questions seam (ctx.userQuestions) for asking the human during agent runs",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -46,27 +46,27 @@
|
|
|
46
46
|
],
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
50
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
51
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
52
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
53
|
-
"@deepseek-ai/dsh-typert-protocol": "0.2.
|
|
54
|
-
"@deepseek-ai/dsh-session": "0.2.
|
|
55
|
-
"@deepseek-ai/dsh-session-projection": "0.2.
|
|
49
|
+
"@deepseek-ai/dsh-agent": "0.2.2-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-scope": "0.2.2-alpha.2",
|
|
52
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.1",
|
|
53
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.2-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-session": "0.2.2-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-alpha.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
59
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
60
|
-
"@deepseek-ai/dsh-scope": "0.2.
|
|
61
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-session
|
|
65
|
-
"@deepseek-ai/dsh-session-
|
|
66
|
-
"@deepseek-ai/dsh-
|
|
58
|
+
"@deepseek-ai/dsh-agent": "0.2.2-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-scope": "0.2.2-alpha.2",
|
|
61
|
+
"@deepseek-ai/cordis": "~4.0.6-alpha.1",
|
|
62
|
+
"@deepseek-ai/dsh-tool-executor-ptc": "0.2.2-alpha.2",
|
|
63
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.2-alpha.2",
|
|
64
|
+
"@deepseek-ai/dsh-session": "0.2.2-alpha.2",
|
|
65
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.2-alpha.2"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"zod": "4.4.3",
|
|
70
|
-
"@deepseek-ai/schemastery": "~3.18.
|
|
70
|
+
"@deepseek-ai/schemastery": "~3.18.6-alpha.1"
|
|
71
71
|
}
|
|
72
72
|
}
|