@yadsh/dsh-qa-surface 0.8.0 → 0.10.0
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.md +142 -4
- package/compatibility.json +5 -0
- package/lib/access/capability-catalog.js +32 -3
- package/lib/access/capability-catalog.js.map +1 -1
- package/lib/access/service.js +45 -17
- package/lib/access/service.js.map +1 -1
- package/lib/accounts/errors.js.map +1 -1
- package/lib/accounts/store.js +14 -0
- package/lib/accounts/store.js.map +1 -1
- package/lib/admin/permissions.js +4 -0
- package/lib/admin/permissions.js.map +1 -1
- package/lib/admin/quality-store.js +71 -0
- package/lib/admin/quality-store.js.map +1 -1
- package/lib/admin/service.js +113 -8
- package/lib/admin/service.js.map +1 -1
- package/lib/admin/session-log.js +66 -5
- package/lib/admin/session-log.js.map +1 -1
- package/lib/client/QaSessionController.js +371 -37
- package/lib/client/QaSessionController.js.map +1 -1
- package/lib/client/QaSurface.js +48 -8
- package/lib/client/QaSurface.js.map +1 -1
- package/lib/client/QaSurfaceGuard.js +12 -5
- package/lib/client/QaSurfaceGuard.js.map +1 -1
- package/lib/client/QaTranscriptAdapter.js +36 -0
- package/lib/client/QaTranscriptAdapter.js.map +1 -1
- package/lib/client/admin/QaAdmin.js +14 -2
- package/lib/client/admin/QaAdmin.js.map +1 -1
- package/lib/client/admin/pages/Conversations.js +33 -7
- package/lib/client/admin/pages/Conversations.js.map +1 -1
- package/lib/client/admin/pages/Users.js +9 -2
- package/lib/client/admin/pages/Users.js.map +1 -1
- package/lib/client/admin/shared.js +14 -1
- package/lib/client/admin/shared.js.map +1 -1
- package/lib/client/admin/styles.js +2 -0
- package/lib/client/admin/styles.js.map +1 -1
- package/lib/client/audit/QaAuditDialog.js +74 -0
- package/lib/client/audit/QaAuditDialog.js.map +1 -0
- package/lib/client/audit/QaAuditRowBadge.js +17 -0
- package/lib/client/audit/QaAuditRowBadge.js.map +1 -0
- package/lib/client/audit/controller.js +39 -0
- package/lib/client/audit/controller.js.map +1 -0
- package/lib/client/audit/types.js +36 -0
- package/lib/client/audit/types.js.map +1 -0
- package/lib/client/audit/use-chat-audits.js +139 -0
- package/lib/client/audit/use-chat-audits.js.map +1 -0
- package/lib/client/base64.js +22 -1
- package/lib/client/base64.js.map +1 -1
- package/lib/client/components/QaAgentsDrawer.js +9 -6
- package/lib/client/components/QaAgentsDrawer.js.map +1 -1
- package/lib/client/components/QaApproval.js +1 -1
- package/lib/client/components/QaApproval.js.map +1 -1
- package/lib/client/components/QaChangelog.js +72 -0
- package/lib/client/components/QaChangelog.js.map +1 -1
- package/lib/client/components/QaComposer.js +63 -3
- package/lib/client/components/QaComposer.js.map +1 -1
- package/lib/client/components/QaFilesPanel.js +17 -11
- package/lib/client/components/QaFilesPanel.js.map +1 -1
- package/lib/client/components/QaHeader.js +3 -11
- package/lib/client/components/QaHeader.js.map +1 -1
- package/lib/client/components/QaMessage.js +16 -0
- package/lib/client/components/QaMessage.js.map +1 -1
- package/lib/client/components/QaModal.js.map +1 -1
- package/lib/client/components/QaQuestions.js +5 -5
- package/lib/client/components/QaQuestions.js.map +1 -1
- package/lib/client/components/QaSidebar.js +22 -3
- package/lib/client/components/QaSidebar.js.map +1 -1
- package/lib/client/components/QaWidthHandle.js +111 -5
- package/lib/client/components/QaWidthHandle.js.map +1 -1
- package/lib/client/components/QaWorkspaceBrowser.js +231 -0
- package/lib/client/components/QaWorkspaceBrowser.js.map +1 -0
- package/lib/client/index.js +127 -51
- package/lib/client/index.js.map +1 -1
- package/lib/client/kiosk.js +51 -0
- package/lib/client/kiosk.js.map +1 -0
- package/lib/client/markdown/blocks.js +122 -7
- package/lib/client/markdown/blocks.js.map +1 -1
- package/lib/client/markdown/inline.js +108 -12
- package/lib/client/markdown/inline.js.map +1 -1
- package/lib/client/markdown/katex-css.js +12 -0
- package/lib/client/markdown/katex-css.js.map +1 -0
- package/lib/client/markdown/math.js +84 -0
- package/lib/client/markdown/math.js.map +1 -0
- package/lib/client/markdown/render.js +74 -5
- package/lib/client/markdown/render.js.map +1 -1
- package/lib/client/project-session-state.js +15 -2
- package/lib/client/project-session-state.js.map +1 -1
- package/lib/client/prompt-content.js +26 -0
- package/lib/client/prompt-content.js.map +1 -1
- package/lib/client/settings/card.js +2 -2
- package/lib/client/settings/card.js.map +1 -1
- package/lib/client/settings/sections/lockdown.js +1 -6
- package/lib/client/settings/sections/lockdown.js.map +1 -1
- package/lib/client/settings/sections/notes.js +46 -0
- package/lib/client/settings/sections/notes.js.map +1 -0
- package/lib/client/settings/sections/slash.js +57 -0
- package/lib/client/settings/sections/slash.js.map +1 -0
- package/lib/client/settings/sections/sources.js +4 -1
- package/lib/client/settings/sections/sources.js.map +1 -1
- package/lib/client/settings/sections/status.js +9 -1
- package/lib/client/settings/sections/status.js.map +1 -1
- package/lib/client/settings/sections.js +2 -0
- package/lib/client/settings/sections.js.map +1 -1
- package/lib/client/settlement.js +1 -1
- package/lib/client/settlement.js.map +1 -1
- package/lib/client/slash/SlashPalette.js +48 -0
- package/lib/client/slash/SlashPalette.js.map +1 -0
- package/lib/client/slash/copy.js +54 -0
- package/lib/client/slash/copy.js.map +1 -0
- package/lib/client/slash/slash-router.js +49 -0
- package/lib/client/slash/slash-router.js.map +1 -0
- package/lib/client/slash/useSlashNavigation.js +95 -0
- package/lib/client/slash/useSlashNavigation.js.map +1 -0
- package/lib/client/source-preview.js +3 -0
- package/lib/client/source-preview.js.map +1 -1
- package/lib/client/styles.js +145 -16
- package/lib/client/styles.js.map +1 -1
- package/lib/client/types.js +11 -0
- package/lib/client/types.js.map +1 -1
- package/lib/client.js +33548 -1876
- package/lib/client.js.map +1 -1
- package/lib/config-resolvers/basics.js +11 -2
- package/lib/config-resolvers/basics.js.map +1 -1
- package/lib/config-resolvers/defaults.js +32 -0
- package/lib/config-resolvers/defaults.js.map +1 -1
- package/lib/config-resolvers/lockdown.js +8 -2
- package/lib/config-resolvers/lockdown.js.map +1 -1
- package/lib/config-resolvers/notes.js +24 -0
- package/lib/config-resolvers/notes.js.map +1 -0
- package/lib/config-resolvers/slash-commands.js +60 -0
- package/lib/config-resolvers/slash-commands.js.map +1 -0
- package/lib/config-resolvers/sources.js +4 -0
- package/lib/config-resolvers/sources.js.map +1 -1
- package/lib/config.js +96 -2
- package/lib/config.js.map +1 -1
- package/lib/index.js +309 -11
- package/lib/index.js.map +1 -1
- package/lib/personal-skills/service.js +16 -3
- package/lib/personal-skills/service.js.map +1 -1
- package/lib/prompt-notes.js +45 -6
- package/lib/prompt-notes.js.map +1 -1
- package/lib/provenance/document-preview.js +51 -0
- package/lib/provenance/document-preview.js.map +1 -0
- package/lib/provenance/file-preview.js +191 -19
- package/lib/provenance/file-preview.js.map +1 -1
- package/lib/provenance/host-store.js +18 -1
- package/lib/provenance/host-store.js.map +1 -1
- package/lib/qa-tools/catalog.js +7 -1
- package/lib/qa-tools/catalog.js.map +1 -1
- package/lib/qa-tools/file-delete-gate.js +60 -0
- package/lib/qa-tools/file-delete-gate.js.map +1 -0
- package/lib/qa-tools/file-delete.js +156 -0
- package/lib/qa-tools/file-delete.js.map +1 -0
- package/lib/questions.js +90 -43
- package/lib/questions.js.map +1 -1
- package/lib/resolve-config.js +7 -0
- package/lib/resolve-config.js.map +1 -1
- package/lib/secure-session.js +24 -0
- package/lib/secure-session.js.map +1 -1
- package/lib/shared/documents.js +22 -0
- package/lib/shared/documents.js.map +1 -0
- package/lib/slash/catalog.js +77 -0
- package/lib/slash/catalog.js.map +1 -0
- package/lib/slash/matcher.js +100 -0
- package/lib/slash/matcher.js.map +1 -0
- package/lib/slash/parser.js +79 -0
- package/lib/slash/parser.js.map +1 -0
- package/lib/slash/policy.js +72 -0
- package/lib/slash/policy.js.map +1 -0
- package/lib/slash/remotes.js +272 -0
- package/lib/slash/remotes.js.map +1 -0
- package/lib/typert.host.js +544 -56
- package/lib/typert.remote-client.d.ts +13 -1
- package/lib/typert.remote-client.js +435 -53
- package/lib/types/access/capability-catalog.d.ts +28 -1
- package/lib/types/access/service.d.ts +33 -4
- package/lib/types/accounts/errors.d.ts +7 -1
- package/lib/types/accounts/store.d.ts +12 -0
- package/lib/types/admin/quality-store.d.ts +18 -0
- package/lib/types/admin/service.d.ts +34 -2
- package/lib/types/admin/session-log.d.ts +65 -1
- package/lib/types/client/QaSessionController.d.ts +84 -2
- package/lib/types/client/QaSurface.d.ts +14 -1
- package/lib/types/client/admin/pages/Conversations.d.ts +4 -0
- package/lib/types/client/admin/shared.d.ts +2 -0
- package/lib/types/client/audit/QaAuditDialog.d.ts +21 -0
- package/lib/types/client/audit/QaAuditRowBadge.d.ts +18 -0
- package/lib/types/client/audit/controller.d.ts +27 -0
- package/lib/types/client/audit/types.d.ts +72 -0
- package/lib/types/client/audit/use-chat-audits.d.ts +20 -0
- package/lib/types/client/base64.d.ts +13 -1
- package/lib/types/client/components/QaAgentsDrawer.d.ts +2 -1
- package/lib/types/client/components/QaComposer.d.ts +12 -2
- package/lib/types/client/components/QaFilesPanel.d.ts +16 -4
- package/lib/types/client/components/QaHeader.d.ts +9 -3
- package/lib/types/client/components/QaModal.d.ts +4 -3
- package/lib/types/client/components/QaQuestions.d.ts +7 -0
- package/lib/types/client/components/QaSidebar.d.ts +8 -0
- package/lib/types/client/components/QaWidthHandle.d.ts +48 -2
- package/lib/types/client/components/QaWorkspaceBrowser.d.ts +15 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/kiosk.d.ts +34 -0
- package/lib/types/client/markdown/blocks.d.ts +14 -1
- package/lib/types/client/markdown/inline.d.ts +23 -7
- package/lib/types/client/markdown/katex-css.d.ts +11 -0
- package/lib/types/client/markdown/math.d.ts +23 -0
- package/lib/types/client/markdown/render.d.ts +2 -1
- package/lib/types/client/project-session-state.d.ts +3 -1
- package/lib/types/client/prompt-content.d.ts +9 -1
- package/lib/types/client/settings/sections/notes.d.ts +10 -0
- package/lib/types/client/settings/sections/slash.d.ts +16 -0
- package/lib/types/client/settings/sections.d.ts +2 -0
- package/lib/types/client/settlement.d.ts +4 -1
- package/lib/types/client/slash/SlashPalette.d.ts +24 -0
- package/lib/types/client/slash/copy.d.ts +30 -0
- package/lib/types/client/slash/slash-router.d.ts +67 -0
- package/lib/types/client/slash/useSlashNavigation.d.ts +47 -0
- package/lib/types/client/styles.d.ts +22 -0
- package/lib/types/client/types.d.ts +65 -1
- package/lib/types/config-resolvers/notes.d.ts +10 -0
- package/lib/types/config-resolvers/slash-commands.d.ts +20 -0
- package/lib/types/index.d.ts +116 -1
- package/lib/types/personal-skills/service.d.ts +5 -0
- package/lib/types/prompt-notes.d.ts +9 -0
- package/lib/types/provenance/document-preview.d.ts +24 -0
- package/lib/types/provenance/file-preview.d.ts +69 -2
- package/lib/types/provenance/host-store.d.ts +13 -0
- package/lib/types/qa-tools/catalog.d.ts +1 -1
- package/lib/types/qa-tools/file-delete-gate.d.ts +42 -0
- package/lib/types/qa-tools/file-delete.d.ts +32 -0
- package/lib/types/questions.d.ts +8 -0
- package/lib/types/shared/documents.d.ts +20 -0
- package/lib/types/slash/catalog.d.ts +56 -0
- package/lib/types/slash/matcher.d.ts +51 -0
- package/lib/types/slash/parser.d.ts +46 -0
- package/lib/types/slash/policy.d.ts +40 -0
- package/lib/types/slash/remotes.d.ts +35 -0
- package/lib/types/types.d.ts +293 -6
- package/lib/types/ui-mode.d.ts +18 -0
- package/lib/ui-mode.js +22 -0
- package/lib/ui-mode.js.map +1 -0
- package/package.json +15 -9
- package/scripts/attach-workspace-sessions.mjs +472 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { bytesToBase64 } from "./base64.js";
|
|
2
2
|
import { qaStorageNamespace } from "../shared/session-key.js";
|
|
3
|
+
import { resolveSlashRoute } from "./slash/slash-router.js";
|
|
4
|
+
import { SLASH_DISABLED_COPY, slashAttachmentsCopy, slashExecuteFailureCopy, slashHostRefusalCopy, slashRefusalCopy, slashWithheldCopy, } from "./slash/copy.js";
|
|
3
5
|
import { canOpenAsCompatibilityReadOnly, QaPolicyAttestationError, } from "./attestation.js";
|
|
4
6
|
import { QaChatIndex } from "./chat-index.js";
|
|
5
7
|
import { isDelegatedSession } from "./lineage.js";
|
|
6
8
|
import { SessionAssetRepository } from "./session-assets.js";
|
|
7
9
|
import { createQaSession } from "./create-session.js";
|
|
8
|
-
import { buildQaPromptContent, stageQaFiles } from "./prompt-content.js";
|
|
10
|
+
import { buildQaPromptContent, buildQaSlashAttachments, stageQaFiles, } from "./prompt-content.js";
|
|
9
11
|
import { attestQaPolicy } from "./session-admission.js";
|
|
10
12
|
import { QaHostSourceBridge } from "./session-sources.js";
|
|
11
13
|
import { QaHostApprovalBridge } from "./approvals.js";
|
|
@@ -18,6 +20,13 @@ import { readableSubagentName } from "./settlement.js";
|
|
|
18
20
|
import { projectBoundSessionState } from "./project-session-state.js";
|
|
19
21
|
import { projectTurnSources } from "./turn-sources.js";
|
|
20
22
|
const CONFIGURATION_ERROR = "Настройки помощника недоступны.";
|
|
23
|
+
/**
|
|
24
|
+
* How long a catalog answer stays fresh enough to skip a re-read when the
|
|
25
|
+
* palette opens. Short on purpose: the check is one round-trip and a stale
|
|
26
|
+
* palette shows a skill that was deleted or hides one that was just added.
|
|
27
|
+
* No polling loop — the palette opening is the only trigger.
|
|
28
|
+
*/
|
|
29
|
+
const SLASH_CATALOG_STALE_MS = 3_000;
|
|
21
30
|
/**
|
|
22
31
|
* Spacing of the parked-request poll. A request is answered by a person, so a
|
|
23
32
|
* second of latency is invisible; the poll only runs while a turn runs.
|
|
@@ -39,6 +48,8 @@ export class QaSessionController {
|
|
|
39
48
|
sourceApi;
|
|
40
49
|
chats;
|
|
41
50
|
accounts;
|
|
51
|
+
/** Slash half of the Host namespace; absent on an older Host build. */
|
|
52
|
+
slashApi;
|
|
42
53
|
/** Resolved per send: a page without the upload plugin has no receipts. */
|
|
43
54
|
fileUpload;
|
|
44
55
|
/** Per-chat attachment URL cache; blob URLs die with the chat binding. */
|
|
@@ -79,6 +90,25 @@ export class QaSessionController {
|
|
|
79
90
|
hostQuestions;
|
|
80
91
|
/** Set while a running turn is polled for parked requests. */
|
|
81
92
|
pendingTimer;
|
|
93
|
+
/**
|
|
94
|
+
* Slash catalog of the bound chat. Keyed by session: it depends on the
|
|
95
|
+
* chat's cwd, its agent composition and its role, so it is dropped with the
|
|
96
|
+
* binding instead of being carried across chats.
|
|
97
|
+
*/
|
|
98
|
+
slashSessionId = null;
|
|
99
|
+
slashEntries = [];
|
|
100
|
+
slashDenied = [];
|
|
101
|
+
slashSurface = "unavailable";
|
|
102
|
+
slashState = "idle";
|
|
103
|
+
slashError = null;
|
|
104
|
+
slashLoadedAt = 0;
|
|
105
|
+
slashLoading;
|
|
106
|
+
/** Last published view; its identity is the render signal. */
|
|
107
|
+
slashViewCache;
|
|
108
|
+
/** Bumped to re-open a palette the user dismissed; see `QaSlashView`. */
|
|
109
|
+
slashReopen = 0;
|
|
110
|
+
/** Chat, connection and admission state of the last one-shot probe. */
|
|
111
|
+
pendingProbeKey = "";
|
|
82
112
|
constructor(options) {
|
|
83
113
|
this.sessions = options.sessions;
|
|
84
114
|
this.createSessionRemote = options.createSession;
|
|
@@ -94,9 +124,22 @@ export class QaSessionController {
|
|
|
94
124
|
ok: false,
|
|
95
125
|
error: "unavailable",
|
|
96
126
|
}),
|
|
127
|
+
listWorkspaceFiles: async () => ({
|
|
128
|
+
ok: false,
|
|
129
|
+
error: "unavailable",
|
|
130
|
+
}),
|
|
131
|
+
readWorkspaceFile: async () => ({
|
|
132
|
+
ok: false,
|
|
133
|
+
error: "unavailable",
|
|
134
|
+
}),
|
|
135
|
+
previewWorkspaceDocument: async () => ({
|
|
136
|
+
ok: false,
|
|
137
|
+
error: "unavailable",
|
|
138
|
+
}),
|
|
97
139
|
};
|
|
98
140
|
this.chats = new QaChatIndex(options.storage, qaStorageNamespace(options.config));
|
|
99
141
|
this.accounts = options.accounts;
|
|
142
|
+
this.slashApi = options.slashApi;
|
|
100
143
|
this.selectedSubrole = options.initialSubrole ?? null;
|
|
101
144
|
this.adminPreview = options.adminPreview === true;
|
|
102
145
|
this.fileUpload = options.fileUpload ?? (() => undefined);
|
|
@@ -139,7 +182,52 @@ export class QaSessionController {
|
|
|
139
182
|
this.adminPreview = adminPreview;
|
|
140
183
|
await this.startDraft(true);
|
|
141
184
|
}
|
|
142
|
-
|
|
185
|
+
/**
|
|
186
|
+
* The attested live session a submission may ride, or `undefined` when the
|
|
187
|
+
* caller must abort. Materializing a draft chat, attesting policy and
|
|
188
|
+
* recovering from a stale proof live here, so the prompt path and the
|
|
189
|
+
* command path cannot drift apart on what "ready to send" means.
|
|
190
|
+
*/
|
|
191
|
+
async liveTarget() {
|
|
192
|
+
if (this.session === undefined) {
|
|
193
|
+
// A draft chat materializes its session only now: nothing was created
|
|
194
|
+
// when the user pressed "New chat", so the first submission pays for it.
|
|
195
|
+
if (!this.drafting || this.materializing !== undefined)
|
|
196
|
+
return undefined;
|
|
197
|
+
if (!(await this.materializeDraft()) || this.session === undefined) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const step = await this.attestPolicy();
|
|
202
|
+
if (step.kind === "stale") {
|
|
203
|
+
// The user moved to another chat while the proof was pending; that
|
|
204
|
+
// binding attests through its own flow and must not receive a submission
|
|
205
|
+
// meant for the old one.
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
let attestedId = step.kind === "ok" ? step.sessionId : null;
|
|
209
|
+
if (attestedId === null) {
|
|
210
|
+
attestedId = await this.recoverForSend();
|
|
211
|
+
if (attestedId === null)
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
// Nothing can interleave between the last await and here, so matching the
|
|
215
|
+
// attested id proves the submission rides exactly the session it proved.
|
|
216
|
+
const target = this.session;
|
|
217
|
+
if (this.disposed ||
|
|
218
|
+
target === undefined ||
|
|
219
|
+
String(target.sessionId) !== attestedId) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
return target;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Route one composer draft. Ordinary text and a skill invocation both ride
|
|
226
|
+
* the native prompt path — a skill is a gesture inside the prompt, not a
|
|
227
|
+
* call this surface makes — while a human command goes to the Host's command
|
|
228
|
+
* runtime and never becomes a model message.
|
|
229
|
+
*/
|
|
230
|
+
async send(text, attachments = [], pick = null) {
|
|
143
231
|
const prompt = text.trim();
|
|
144
232
|
// Images ride the prompt inline; files must be staged first, because the
|
|
145
233
|
// wire carries a receipt rather than bytes.
|
|
@@ -147,8 +235,37 @@ export class QaSessionController {
|
|
|
147
235
|
if ((prompt === "" && attachments.length === 0) || !this.state.canSend) {
|
|
148
236
|
return false;
|
|
149
237
|
}
|
|
150
|
-
|
|
151
|
-
|
|
238
|
+
const route = resolveSlashRoute({
|
|
239
|
+
text: prompt,
|
|
240
|
+
enabled: this.config.slashCommands.enabled,
|
|
241
|
+
catalogReady: this.slashCatalogReady(),
|
|
242
|
+
entries: this.slashEntries,
|
|
243
|
+
deniedSkills: this.slashDenied,
|
|
244
|
+
picked: pick,
|
|
245
|
+
});
|
|
246
|
+
if (route.kind === "command") {
|
|
247
|
+
return this.sendCommand(prompt, attachments, files, route.entry);
|
|
248
|
+
}
|
|
249
|
+
if (route.kind === "disabled") {
|
|
250
|
+
this.operationError = SLASH_DISABLED_COPY;
|
|
251
|
+
this.publish();
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
if (route.kind !== "prompt" && route.kind !== "skill") {
|
|
255
|
+
this.operationError = slashRefusalCopy(route);
|
|
256
|
+
if (route.kind === "unknown" || route.kind === "ambiguous") {
|
|
257
|
+
// Re-open the palette the user had to dismiss to reach this line: the
|
|
258
|
+
// refusal is only useful next to the choices it is talking about.
|
|
259
|
+
this.slashReopen += 1;
|
|
260
|
+
}
|
|
261
|
+
this.publish();
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (route.kind === "prompt" && (route.withheld?.length ?? 0) > 0) {
|
|
265
|
+
// The gesture is real and user-invocable here, and this deployment
|
|
266
|
+
// withholds it. Sending it would let the user believe it took effect —
|
|
267
|
+
// the native consumer refuses the injection, but only after the turn.
|
|
268
|
+
this.operationError = slashWithheldCopy(route.withheld ?? []);
|
|
152
269
|
this.publish();
|
|
153
270
|
return false;
|
|
154
271
|
}
|
|
@@ -160,36 +277,9 @@ export class QaSessionController {
|
|
|
160
277
|
let accepted = false;
|
|
161
278
|
let target;
|
|
162
279
|
try {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// when the user pressed "New chat", so the first prompt pays for it.
|
|
166
|
-
if (!this.drafting || this.materializing !== undefined)
|
|
167
|
-
return false;
|
|
168
|
-
if (!(await this.materializeDraft()) || this.session === undefined) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
const step = await this.attestPolicy();
|
|
173
|
-
if (step.kind === "stale") {
|
|
174
|
-
// The user moved to another chat while the proof was pending; that
|
|
175
|
-
// binding attests through its own flow and must not receive a prompt
|
|
176
|
-
// meant for the old one.
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
let attestedId = step.kind === "ok" ? step.sessionId : null;
|
|
180
|
-
if (attestedId === null) {
|
|
181
|
-
attestedId = await this.recoverForSend();
|
|
182
|
-
if (attestedId === null)
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
// Nothing can interleave between the last await and here, so matching the
|
|
186
|
-
// attested id proves the prompt rides exactly the session it proved.
|
|
187
|
-
target = this.session;
|
|
188
|
-
if (this.disposed ||
|
|
189
|
-
target === undefined ||
|
|
190
|
-
String(target.sessionId) !== attestedId) {
|
|
280
|
+
target = await this.liveTarget();
|
|
281
|
+
if (target === undefined)
|
|
191
282
|
return false;
|
|
192
|
-
}
|
|
193
283
|
if (submission !== undefined && this.pendingSubmission === submission) {
|
|
194
284
|
// Recovery may have replaced the original chat with a fresh session;
|
|
195
285
|
// reconcile against the actual prompt target, not the abandoned one.
|
|
@@ -247,6 +337,198 @@ export class QaSessionController {
|
|
|
247
337
|
}
|
|
248
338
|
}
|
|
249
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Run one admitted human command. The Host answers it and writes the
|
|
342
|
+
* lifecycle into the session log; this method only decides what the composer
|
|
343
|
+
* does next, which is why nothing here creates a pending user row.
|
|
344
|
+
*
|
|
345
|
+
* A refusal keeps the draft and the attachments: the user asked for
|
|
346
|
+
* something the deployment does not allow, and retyping the line is a worse
|
|
347
|
+
* answer than leaving it in place to be edited.
|
|
348
|
+
*/
|
|
349
|
+
async sendCommand(line, attachments, files, entry) {
|
|
350
|
+
if (this.slashApi === undefined) {
|
|
351
|
+
this.operationError = SLASH_DISABLED_COPY;
|
|
352
|
+
this.publish();
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
if (attachments.length > 0 && entry.acceptsAttachments !== true) {
|
|
356
|
+
// Checked here so nothing is staged and no Host round-trip is paid for a
|
|
357
|
+
// submission that cannot be admitted; the Host checks it again anyway.
|
|
358
|
+
this.operationError = slashAttachmentsCopy(entry);
|
|
359
|
+
this.publish();
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
let target;
|
|
363
|
+
try {
|
|
364
|
+
target = await this.liveTarget();
|
|
365
|
+
if (target === undefined)
|
|
366
|
+
return false;
|
|
367
|
+
let receipts = new Map();
|
|
368
|
+
if (files.length > 0) {
|
|
369
|
+
const outcome = await stageQaFiles(this.fileUpload(), target, files);
|
|
370
|
+
if (outcome.kind !== "ok") {
|
|
371
|
+
if (this.session === target) {
|
|
372
|
+
this.operationError =
|
|
373
|
+
outcome.kind === "unavailable"
|
|
374
|
+
? "Вложения недоступны на этом сервере."
|
|
375
|
+
: "Не удалось приложить файл.";
|
|
376
|
+
this.publish();
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
receipts = outcome.receipts;
|
|
381
|
+
}
|
|
382
|
+
const result = await this.slashApi.execute(this.accounts?.token() ?? "", String(target.sessionId), line, buildQaSlashAttachments(attachments, receipts));
|
|
383
|
+
if (this.session !== target)
|
|
384
|
+
return false;
|
|
385
|
+
if (!result.ok) {
|
|
386
|
+
this.operationError = slashExecuteFailureCopy(entry);
|
|
387
|
+
this.publish();
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (result.value.kind === "refused") {
|
|
391
|
+
this.operationError = slashHostRefusalCopy(result.value);
|
|
392
|
+
this.publish();
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
this.operationError = null;
|
|
396
|
+
this.publish();
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
console.error("dsh-qa-surface: slash command failed", error);
|
|
401
|
+
if (this.session === target) {
|
|
402
|
+
this.operationError = slashExecuteFailureCopy(entry);
|
|
403
|
+
this.publish();
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Refresh the catalog of the bound chat. Called when a chat binds, and again
|
|
410
|
+
* when the palette opens on a catalog that has had time to go stale: the
|
|
411
|
+
* skill registry has no browser-facing change event, so a skill installed
|
|
412
|
+
* while the page is open is only discovered by asking again.
|
|
413
|
+
*/
|
|
414
|
+
async refreshSlashCatalog(force = false) {
|
|
415
|
+
const session = this.session;
|
|
416
|
+
if (session === undefined || this.disposed)
|
|
417
|
+
return;
|
|
418
|
+
if (!this.config.slashCommands.enabled || this.compatibilityReadOnly) {
|
|
419
|
+
this.applySlashCatalog(String(session.sessionId), null);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (this.slashApi === undefined) {
|
|
423
|
+
this.applySlashCatalog(String(session.sessionId), undefined);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (this.slashLoading !== undefined)
|
|
427
|
+
return this.slashLoading;
|
|
428
|
+
if (!force && this.slashSessionId === String(session.sessionId)) {
|
|
429
|
+
if (Date.now() - this.slashLoadedAt < SLASH_CATALOG_STALE_MS)
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const sessionId = String(session.sessionId);
|
|
433
|
+
this.slashState = "loading";
|
|
434
|
+
this.publish();
|
|
435
|
+
const operation = (async () => {
|
|
436
|
+
try {
|
|
437
|
+
const result = await this.slashApi?.catalog(this.accounts?.token() ?? "", sessionId);
|
|
438
|
+
if (result === undefined)
|
|
439
|
+
return;
|
|
440
|
+
if (!result.ok) {
|
|
441
|
+
this.applySlashCatalog(sessionId, undefined);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
this.applySlashCatalog(sessionId, result.value);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
console.error("dsh-qa-surface: slash catalog failed", error);
|
|
448
|
+
this.applySlashCatalog(sessionId, undefined);
|
|
449
|
+
}
|
|
450
|
+
})().finally(() => {
|
|
451
|
+
if (this.slashLoading === operation)
|
|
452
|
+
this.slashLoading = undefined;
|
|
453
|
+
});
|
|
454
|
+
this.slashLoading = operation;
|
|
455
|
+
return operation;
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Install one catalog answer. `null` means the deployment runs with the
|
|
459
|
+
* slash interface off; `undefined` means the answer never arrived. The
|
|
460
|
+
* difference matters: an unreachable catalog must not turn ordinary prompts
|
|
461
|
+
* into refusals.
|
|
462
|
+
*/
|
|
463
|
+
applySlashCatalog(sessionId, catalog) {
|
|
464
|
+
if (this.session === undefined ||
|
|
465
|
+
String(this.session.sessionId) !== sessionId) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
this.slashSessionId = sessionId;
|
|
469
|
+
this.slashLoadedAt = Date.now();
|
|
470
|
+
if (catalog === null) {
|
|
471
|
+
this.slashEntries = [];
|
|
472
|
+
this.slashDenied = [];
|
|
473
|
+
this.slashSurface = "unavailable";
|
|
474
|
+
this.slashState = "idle";
|
|
475
|
+
this.slashError = null;
|
|
476
|
+
this.publish();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (catalog === undefined) {
|
|
480
|
+
this.slashEntries = [];
|
|
481
|
+
this.slashDenied = [];
|
|
482
|
+
this.slashSurface = "unavailable";
|
|
483
|
+
this.slashState = "error";
|
|
484
|
+
this.slashError = "Не удалось загрузить команды";
|
|
485
|
+
this.publish();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
this.slashEntries = catalog.entries;
|
|
489
|
+
this.slashDenied = catalog.deniedSkills;
|
|
490
|
+
this.slashSurface = catalog.commandSurface;
|
|
491
|
+
this.slashState = "ready";
|
|
492
|
+
this.slashError = null;
|
|
493
|
+
this.publish();
|
|
494
|
+
}
|
|
495
|
+
/** Whether the catalog of the bound chat was read successfully. */
|
|
496
|
+
slashCatalogReady() {
|
|
497
|
+
return this.slashState === "ready" || this.slashState === "loading";
|
|
498
|
+
}
|
|
499
|
+
/** The slash view of the current state; assembled where the state is. */
|
|
500
|
+
slashView() {
|
|
501
|
+
const enabled = this.config.slashCommands.enabled &&
|
|
502
|
+
!this.compatibilityReadOnly &&
|
|
503
|
+
this.slashSessionId !== null &&
|
|
504
|
+
this.slashApi !== undefined;
|
|
505
|
+
// Identity is the render signal: this runs on every publish, including
|
|
506
|
+
// every stream frame of a running turn, and the composer is memoized on
|
|
507
|
+
// its props. A fresh object here would re-render the composer for each
|
|
508
|
+
// frame of an answer, which is exactly what its memo exists to prevent.
|
|
509
|
+
const cached = this.slashViewCache;
|
|
510
|
+
if (cached !== undefined &&
|
|
511
|
+
cached.enabled === enabled &&
|
|
512
|
+
cached.state === this.slashState &&
|
|
513
|
+
cached.entries === this.slashEntries &&
|
|
514
|
+
cached.commandSurface === this.slashSurface &&
|
|
515
|
+
cached.deniedSkills === this.slashDenied &&
|
|
516
|
+
cached.error === this.slashError &&
|
|
517
|
+
cached.reopen === this.slashReopen) {
|
|
518
|
+
return cached;
|
|
519
|
+
}
|
|
520
|
+
const view = {
|
|
521
|
+
enabled,
|
|
522
|
+
state: this.slashState,
|
|
523
|
+
entries: this.slashEntries,
|
|
524
|
+
commandSurface: this.slashSurface,
|
|
525
|
+
deniedSkills: this.slashDenied,
|
|
526
|
+
error: this.slashError,
|
|
527
|
+
reopen: this.slashReopen,
|
|
528
|
+
};
|
|
529
|
+
this.slashViewCache = view;
|
|
530
|
+
return view;
|
|
531
|
+
}
|
|
250
532
|
/** Publish a browser-only copy before any network or Host admission awaits. */
|
|
251
533
|
beginSubmission(text, attachments) {
|
|
252
534
|
const submission = {
|
|
@@ -803,6 +1085,9 @@ export class QaSessionController {
|
|
|
803
1085
|
this.accounts?.onSessionCreated(String(this.session.sessionId));
|
|
804
1086
|
}
|
|
805
1087
|
this.publish();
|
|
1088
|
+
// Deliberately not awaited: the palette is a convenience, and a chat must
|
|
1089
|
+
// open at once whether or not the skill and command registries answer.
|
|
1090
|
+
void this.refreshSlashCatalog(true);
|
|
806
1091
|
}
|
|
807
1092
|
unbind() {
|
|
808
1093
|
this.streamPublisher.clear();
|
|
@@ -821,9 +1106,21 @@ export class QaSessionController {
|
|
|
821
1106
|
this.hostApprovals.reset();
|
|
822
1107
|
this.hostQuestions.reset();
|
|
823
1108
|
this.stopPendingPolling();
|
|
1109
|
+
// The next binding probes the Host again even for the same chat.
|
|
1110
|
+
this.pendingProbeKey = "";
|
|
824
1111
|
this.admissionPending = false;
|
|
825
1112
|
this.policyReady = false;
|
|
826
1113
|
this.compatibilityReadOnly = false;
|
|
1114
|
+
// The catalog belongs to the chat that produced it: another chat has a
|
|
1115
|
+
// different cwd, composition and role, so carrying it across would offer
|
|
1116
|
+
// actions this chat may not have.
|
|
1117
|
+
this.slashSessionId = null;
|
|
1118
|
+
this.slashEntries = [];
|
|
1119
|
+
this.slashDenied = [];
|
|
1120
|
+
this.slashSurface = "unavailable";
|
|
1121
|
+
this.slashState = "idle";
|
|
1122
|
+
this.slashError = null;
|
|
1123
|
+
this.slashLoadedAt = 0;
|
|
827
1124
|
}
|
|
828
1125
|
waitForConnection() {
|
|
829
1126
|
return waitFor(this.connection, (description) => description !== undefined, this.timeoutMs);
|
|
@@ -874,6 +1171,7 @@ export class QaSessionController {
|
|
|
874
1171
|
if (!snapshot.running) {
|
|
875
1172
|
void this.hostSources.refresh(sessionId, () => this.publish());
|
|
876
1173
|
}
|
|
1174
|
+
this.probePending(sessionId, connected);
|
|
877
1175
|
this.syncPendingPolling(snapshot.running === true && !this.compatibilityReadOnly);
|
|
878
1176
|
const projectionInput = {
|
|
879
1177
|
connected,
|
|
@@ -892,6 +1190,7 @@ export class QaSessionController {
|
|
|
892
1190
|
admissionPending: this.admissionPending || this.pendingSubmission !== undefined,
|
|
893
1191
|
chatsRevision: this.chatsRevision,
|
|
894
1192
|
viewingSubagent: this.viewingSubagent,
|
|
1193
|
+
slash: this.slashView(),
|
|
895
1194
|
config: this.config,
|
|
896
1195
|
subagentNames: this.subagentNames(),
|
|
897
1196
|
};
|
|
@@ -1041,6 +1340,12 @@ export class QaSessionController {
|
|
|
1041
1340
|
* inside an open turn, and it is Host state: polling is how the page learns
|
|
1042
1341
|
* about it, and how it reappears after a reload. One timer serves both seams,
|
|
1043
1342
|
* and each is polled only where the deployment answers it.
|
|
1343
|
+
*
|
|
1344
|
+
* A request that is already on screen keeps the timer alive past the end of
|
|
1345
|
+
* its turn: the Host settles what the turn can no longer answer — an aborted
|
|
1346
|
+
* tool call, an agent that went idle — and this keeps reading until that
|
|
1347
|
+
* settlement reaches the page, so the form goes away instead of sitting
|
|
1348
|
+
* there answerable but dead.
|
|
1044
1349
|
*/
|
|
1045
1350
|
syncPendingPolling(running) {
|
|
1046
1351
|
const approvals = this.hostApprovals.available
|
|
@@ -1049,8 +1354,9 @@ export class QaSessionController {
|
|
|
1049
1354
|
const questions = this.hostQuestions.available
|
|
1050
1355
|
? this.config.interaction.questions === "interactive"
|
|
1051
1356
|
: false;
|
|
1052
|
-
const
|
|
1053
|
-
(
|
|
1357
|
+
const pending = this.hostApprovals.list().length > 0 ||
|
|
1358
|
+
this.hostQuestions.list().length > 0;
|
|
1359
|
+
const wanted = ((running && (approvals || questions)) || pending) &&
|
|
1054
1360
|
// A subagent watched from the panel is a read-only view of a session the
|
|
1055
1361
|
// chat owns: its own requests belong to the chat, not to this binding.
|
|
1056
1362
|
this.viewingSubagent === null &&
|
|
@@ -1064,16 +1370,44 @@ export class QaSessionController {
|
|
|
1064
1370
|
const sessionId = String(this.session.sessionId);
|
|
1065
1371
|
const token = this.hostToken();
|
|
1066
1372
|
const tick = () => {
|
|
1067
|
-
|
|
1373
|
+
// A seam still on screen is re-read even where its config gate has since
|
|
1374
|
+
// closed: the Host is the authority on what it holds, and an empty answer
|
|
1375
|
+
// is what takes a settled request off the screen.
|
|
1376
|
+
if (approvals || this.hostApprovals.list().length > 0) {
|
|
1068
1377
|
void this.hostApprovals.refresh(sessionId, token, () => this.publish());
|
|
1069
1378
|
}
|
|
1070
|
-
if (questions) {
|
|
1379
|
+
if (questions || this.hostQuestions.list().length > 0) {
|
|
1071
1380
|
void this.hostQuestions.refresh(sessionId, token, () => this.publish());
|
|
1072
1381
|
}
|
|
1073
1382
|
};
|
|
1074
1383
|
this.pendingTimer = setInterval(tick, PENDING_POLL_MS);
|
|
1075
1384
|
tick();
|
|
1076
1385
|
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Read what the Host parks once per chat and connection, whether or not a
|
|
1388
|
+
* turn is running. A reload binds the chat before any turn reports itself
|
|
1389
|
+
* over the fresh stream, and a turn that is already waiting on a question
|
|
1390
|
+
* would otherwise sit behind an empty composer until the operator happened
|
|
1391
|
+
* to send something.
|
|
1392
|
+
*/
|
|
1393
|
+
probePending(sessionId, connected) {
|
|
1394
|
+
const key = `${sessionId}:${connected ? "up" : "down"}:${String(this.policyReady)}`;
|
|
1395
|
+
// Attestation is what lets the Host answer about this chat at all, so the
|
|
1396
|
+
// read waits for it: the publish that follows a successful attestation
|
|
1397
|
+
// carries a new key and probes then.
|
|
1398
|
+
if (!connected || !this.policyReady || key === this.pendingProbeKey)
|
|
1399
|
+
return;
|
|
1400
|
+
this.pendingProbeKey = key;
|
|
1401
|
+
const token = this.hostToken();
|
|
1402
|
+
if (this.hostApprovals.available &&
|
|
1403
|
+
this.config.interaction.approvals === "interactive") {
|
|
1404
|
+
void this.hostApprovals.refresh(sessionId, token, () => this.publish());
|
|
1405
|
+
}
|
|
1406
|
+
if (this.hostQuestions.available &&
|
|
1407
|
+
this.config.interaction.questions === "interactive") {
|
|
1408
|
+
void this.hostQuestions.refresh(sessionId, token, () => this.publish());
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1077
1411
|
stopPendingPolling() {
|
|
1078
1412
|
if (this.pendingTimer === undefined)
|
|
1079
1413
|
return;
|