@yadsh/dsh-qa-surface 0.9.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 +29 -1
- package/lib/admin/service.js +7 -7
- package/lib/admin/service.js.map +1 -1
- package/lib/client/QaSessionController.js +12 -0
- package/lib/client/QaSessionController.js.map +1 -1
- package/lib/client/QaSurface.js +23 -5
- 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/admin/QaAdmin.js +5 -1
- package/lib/client/admin/QaAdmin.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 +5 -1
- package/lib/client/admin/shared.js.map +1 -1
- 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 +29 -0
- package/lib/client/components/QaChangelog.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/QaModal.js.map +1 -1
- package/lib/client/components/QaQuestions.js +4 -4
- package/lib/client/components/QaQuestions.js.map +1 -1
- package/lib/client/components/QaSidebar.js +10 -2
- 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 +109 -53
- 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/settings/card.js +2 -2
- package/lib/client/settings/card.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/sources.js +4 -1
- package/lib/client/settings/sections/sources.js.map +1 -1
- package/lib/client/settings/sections.js +1 -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/source-preview.js +3 -0
- package/lib/client/source-preview.js.map +1 -1
- package/lib/client/styles.js +97 -18
- package/lib/client/styles.js.map +1 -1
- package/lib/client/types.js.map +1 -1
- package/lib/client.js +28587 -595
- package/lib/client.js.map +1 -1
- package/lib/config-resolvers/defaults.js +10 -0
- package/lib/config-resolvers/defaults.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/sources.js +4 -0
- package/lib/config-resolvers/sources.js.map +1 -1
- package/lib/config.js +35 -0
- package/lib/config.js.map +1 -1
- package/lib/index.js +151 -10
- package/lib/index.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/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/resolve-config.js +2 -0
- package/lib/resolve-config.js.map +1 -1
- package/lib/shared/documents.js +22 -0
- package/lib/shared/documents.js.map +1 -0
- package/lib/typert.host.js +278 -55
- package/lib/typert.remote-client.d.ts +7 -1
- package/lib/typert.remote-client.js +239 -53
- package/lib/types/client/admin/shared.d.ts +2 -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/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/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/settings/sections/notes.d.ts +10 -0
- package/lib/types/client/settings/sections.d.ts +1 -0
- package/lib/types/client/settlement.d.ts +4 -1
- package/lib/types/client/styles.d.ts +15 -2
- package/lib/types/client/types.d.ts +50 -1
- package/lib/types/config-resolvers/notes.d.ts +10 -0
- package/lib/types/index.d.ts +39 -1
- 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/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/shared/documents.d.ts +20 -0
- package/lib/types/types.d.ts +93 -1
- 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 +10 -8
package/lib/qa-tools/catalog.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
2
|
+
import { createFileDeleteTool } from "./file-delete.js";
|
|
2
3
|
/**
|
|
3
4
|
* Deterministic catalog identity. The durable activation marker is derived from
|
|
4
5
|
* the session log rather than stored, so this version is not compared against a
|
|
@@ -7,7 +8,7 @@ import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
|
7
8
|
*
|
|
8
9
|
* Bump it whenever the catalog's tool set or their schemas change.
|
|
9
10
|
*/
|
|
10
|
-
export const QA_TOOL_CATALOG_VERSION = "
|
|
11
|
+
export const QA_TOOL_CATALOG_VERSION = "2";
|
|
11
12
|
function createSelfcheckTool(deps) {
|
|
12
13
|
return defineTool({
|
|
13
14
|
name: "qa_tools_selfcheck",
|
|
@@ -79,6 +80,11 @@ export function createQaToolCatalog(deps) {
|
|
|
79
80
|
group: "diagnostics",
|
|
80
81
|
tags: ["activation", "diagnostics"],
|
|
81
82
|
},
|
|
83
|
+
{
|
|
84
|
+
definition: createFileDeleteTool(),
|
|
85
|
+
group: "workspace",
|
|
86
|
+
tags: ["files", "destructive"],
|
|
87
|
+
},
|
|
82
88
|
];
|
|
83
89
|
}
|
|
84
90
|
/** QA tool names, in catalog order; the admission gate treats them as dynamic. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/qa-tools/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/qa-tools/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO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
export const QA_FILE_DELETE_TOOL = "file_delete";
|
|
3
|
+
/** Why the gate answers `ask` before the chain can decide alone. */
|
|
4
|
+
export const QA_FILE_DELETE_ASK_REASON = "deleting a workspace file requires operator confirmation";
|
|
5
|
+
/**
|
|
6
|
+
* The inner half of `file_delete`'s safety: the decision that composes the
|
|
7
|
+
* approval flow around one destructive tool.
|
|
8
|
+
*
|
|
9
|
+
* Installed WITHOUT `prepend`, deliberately. The approval gate sits outside
|
|
10
|
+
* every other `tools/pre-execute` listener and resolves the decision the rest
|
|
11
|
+
* of the chain produced — an `ask` from an inner gate is what it parks for
|
|
12
|
+
* the operator. This listener is that inner gate: for a `file_delete` call
|
|
13
|
+
* from an attested QA session it answers `ask` on its own, without asking
|
|
14
|
+
* the chain, so the interactive approval card appears for every deletion,
|
|
15
|
+
* whatever the deployment's other policies would have said. The operator's
|
|
16
|
+
* answer becomes the decision, and on a deployment with
|
|
17
|
+
* `interaction.approvals: blocked` the approval gate keeps its fail-closed
|
|
18
|
+
* behavior and refuses the call — nothing is ever deleted without a person.
|
|
19
|
+
*
|
|
20
|
+
* Any other tool, and any caller this deployment did not attest, is handed
|
|
21
|
+
* back to the chain untouched.
|
|
22
|
+
*/
|
|
23
|
+
export class QaFileDeleteGate {
|
|
24
|
+
ctx;
|
|
25
|
+
ownership;
|
|
26
|
+
disposers = [];
|
|
27
|
+
constructor(ctx, ownership) {
|
|
28
|
+
this.ctx = ctx;
|
|
29
|
+
this.ownership = ownership;
|
|
30
|
+
}
|
|
31
|
+
/** Sit inside the approval gate; registration order is the composition. */
|
|
32
|
+
install() {
|
|
33
|
+
this.ownership.install(this.ctx);
|
|
34
|
+
this.disposers.push(this.ctx.on("tools/pre-execute", (execution, next) => this.handle(execution, next)));
|
|
35
|
+
}
|
|
36
|
+
/** Detach the listener. Wired as an effect, like every other gate. */
|
|
37
|
+
dispose() {
|
|
38
|
+
for (const dispose of this.disposers.splice(0))
|
|
39
|
+
dispose();
|
|
40
|
+
}
|
|
41
|
+
async handle(execution, next) {
|
|
42
|
+
if (execution.name !== QA_FILE_DELETE_TOOL)
|
|
43
|
+
return next();
|
|
44
|
+
if (!this.attested(execution))
|
|
45
|
+
return next();
|
|
46
|
+
return { kind: "ask", reason: QA_FILE_DELETE_ASK_REASON };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether this deployment attested the chat the call belongs to, delegated
|
|
50
|
+
* children included. The same ownership service the approval gate reads,
|
|
51
|
+
* so one chat is parked under exactly one surface.
|
|
52
|
+
*/
|
|
53
|
+
attested(execution) {
|
|
54
|
+
const session = execution.agent?.session;
|
|
55
|
+
if (session === undefined)
|
|
56
|
+
return false;
|
|
57
|
+
return this.ownership.rootOf(String(session.id)) !== undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=file-delete-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-delete-gate.js","sourceRoot":"","sources":["../../src/qa-tools/file-delete-gate.ts"],"names":[],"mappings":"AAKA,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAEjD,oEAAoE;AACpE,MAAM,CAAC,MAAM,yBAAyB,GACpC,0DAA0D,CAAC;AAE7D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,gBAAgB;IAIR,GAAG;IACH,SAAS;IAJX,SAAS,GAAmB,EAAE,CAAC;IAEhD,YACmB,GAAY,EACZ,SAA6B;mBAD7B,GAAG;yBACH,SAAS;IACzB,CAAC;IAEJ,2EAA2E;IAC3E,OAAO;QACL,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CACjB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CACnD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAC7B,CACF,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,OAAO;QACL,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;IAC5D,CAAC;IAEO,KAAK,CAAC,MAAM,CAClB,SAA8B,EAC9B,IAAoC;QAEpC,IAAI,SAAS,CAAC,IAAI,KAAK,mBAAmB;YAAE,OAAO,IAAI,EAAE,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QAC7C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,SAA8B;QAC7C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QACzC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACxC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { realpath, stat, unlink } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep, } from "node:path";
|
|
3
|
+
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
|
+
/**
|
|
5
|
+
* A typed refusal of one `file_delete` call.
|
|
6
|
+
*
|
|
7
|
+
* The message is what the model reads; it names the reason in words and
|
|
8
|
+
* deliberately never echoes the requested absolute host path, so a refusal
|
|
9
|
+
* cannot leak the deployment's layout into the conversation.
|
|
10
|
+
*/
|
|
11
|
+
export class QaFileDeleteError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message, options = {}) {
|
|
14
|
+
super(message, options);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.name = "QaFileDeleteError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const OUTSIDE_WORKSPACE = "file_delete refused this path: it resolves outside the calling session's workspace. Only files inside the workspace can be deleted; pass a path relative to the workspace root.";
|
|
20
|
+
const SYMLINK_ESCAPE = "file_delete refused this path: it escapes the workspace through a symbolic link, and links may not be followed out of the workspace.";
|
|
21
|
+
const NOT_FOUND = "file_delete refused this path: no file exists there. Check the spelling relative to the workspace root, or create the file first.";
|
|
22
|
+
const NOT_A_FILE = "file_delete refused this path: it is a directory, and only a regular file can be deleted.";
|
|
23
|
+
/**
|
|
24
|
+
* The calling agent's workspace root, resolved on disk.
|
|
25
|
+
*
|
|
26
|
+
* A session without a cwd gets a refusal rather than the host process's cwd:
|
|
27
|
+
* guessing a root would point the fence at whatever directory the Host was
|
|
28
|
+
* started from, which is exactly where an untrusted chat must not delete.
|
|
29
|
+
*/
|
|
30
|
+
async function workspaceRootOf(exec) {
|
|
31
|
+
const cwd = exec.agent?.session.header.cwd;
|
|
32
|
+
if (typeof cwd !== "string" || cwd.trim() === "") {
|
|
33
|
+
throw new QaFileDeleteError("workspace-unavailable", "file_delete needs the calling session's workspace root, which this execution does not carry, so nothing is deleted.");
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return await realpath(cwd);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new QaFileDeleteError("workspace-unavailable", "file_delete could not resolve the calling session's workspace root on disk, so nothing is deleted.");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether `target` sits inside `root` once both are canonical. The root
|
|
44
|
+
* itself counts as inside: it is a directory, and the regular-file check is
|
|
45
|
+
* what refuses it, with a reason that matches what is actually there.
|
|
46
|
+
*/
|
|
47
|
+
function insideRoot(root, target) {
|
|
48
|
+
const fromRoot = relative(root, target);
|
|
49
|
+
return (fromRoot === "" ||
|
|
50
|
+
(!fromRoot.startsWith(`..${sep}`) &&
|
|
51
|
+
fromRoot !== ".." &&
|
|
52
|
+
!isAbsolute(fromRoot)));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Canonical form of `input`: the deepest existing ancestor resolved with
|
|
56
|
+
* `fs.realpath`, the missing suffix re-attached. A final entry that does not
|
|
57
|
+
* exist is still checked against the boundary its existing ancestors really
|
|
58
|
+
* live behind, so a symlinked directory cannot carry a request out of the
|
|
59
|
+
* workspace even when the target file is absent.
|
|
60
|
+
*/
|
|
61
|
+
async function canonicalCandidate(input) {
|
|
62
|
+
const resolved = resolve(input);
|
|
63
|
+
const suffix = [];
|
|
64
|
+
let cursor = resolved;
|
|
65
|
+
for (;;) {
|
|
66
|
+
try {
|
|
67
|
+
return resolve(await realpath(cursor), ...suffix);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error.code !== "ENOENT")
|
|
71
|
+
throw error;
|
|
72
|
+
const parent = dirname(cursor);
|
|
73
|
+
if (parent === cursor)
|
|
74
|
+
throw error;
|
|
75
|
+
suffix.unshift(basename(cursor));
|
|
76
|
+
cursor = parent;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export function createFileDeleteTool() {
|
|
81
|
+
return defineTool({
|
|
82
|
+
name: "file_delete",
|
|
83
|
+
description: "Delete one regular file inside this session's workspace. Use it to remove scratch files a task produced and no longer needs. Directories, missing paths and anything outside the workspace — including paths that escape through a symbolic link — are refused. Every deletion is confirmed by the operator before it runs.",
|
|
84
|
+
parameters: {
|
|
85
|
+
path: {
|
|
86
|
+
type: "string",
|
|
87
|
+
required: true,
|
|
88
|
+
description: "The file to delete. Relative paths start at the workspace root; an absolute path must stay inside it.",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
output: {
|
|
92
|
+
schema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
additionalProperties: false,
|
|
95
|
+
properties: {
|
|
96
|
+
deleted: { type: "boolean", required: true },
|
|
97
|
+
path: { type: "string", required: true },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
render: (_args, value) => {
|
|
101
|
+
const record = value;
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: `Deleted ${String(record.path)} from the workspace.`,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
execute: async (args, exec) => {
|
|
111
|
+
const root = await workspaceRootOf(exec);
|
|
112
|
+
// Refuse the spelling first: a path that already leaves the root
|
|
113
|
+
// without any symlink has no reason to touch the filesystem further.
|
|
114
|
+
const absolute = isAbsolute(args.path)
|
|
115
|
+
? resolve(args.path)
|
|
116
|
+
: resolve(root, args.path);
|
|
117
|
+
if (!insideRoot(root, absolute)) {
|
|
118
|
+
throw new QaFileDeleteError("outside-workspace", OUTSIDE_WORKSPACE);
|
|
119
|
+
}
|
|
120
|
+
let canonical;
|
|
121
|
+
try {
|
|
122
|
+
canonical = await canonicalCandidate(absolute);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new QaFileDeleteError("workspace-unavailable", "file_delete could not verify the requested path against the workspace boundary, so nothing is deleted.");
|
|
126
|
+
}
|
|
127
|
+
if (!insideRoot(root, canonical)) {
|
|
128
|
+
// The spelling stayed inside but a symbolic link moved the request
|
|
129
|
+
// out: the honest reason names the link, not the workspace.
|
|
130
|
+
throw new QaFileDeleteError("symlink-escape", SYMLINK_ESCAPE);
|
|
131
|
+
}
|
|
132
|
+
const info = await stat(canonical).catch((error) => error);
|
|
133
|
+
if (info instanceof Error) {
|
|
134
|
+
if (info.code === "ENOENT") {
|
|
135
|
+
throw new QaFileDeleteError("not-found", NOT_FOUND);
|
|
136
|
+
}
|
|
137
|
+
throw new QaFileDeleteError("workspace-unavailable", "file_delete could not inspect the requested entry, so nothing is deleted.");
|
|
138
|
+
}
|
|
139
|
+
if (!info.isFile()) {
|
|
140
|
+
throw new QaFileDeleteError("not-a-file", NOT_A_FILE);
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
await unlink(absolute);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
const code = error.code ?? "unknown";
|
|
147
|
+
throw new QaFileDeleteError("workspace-unavailable", `file_delete could not delete the file (${String(code)}).`, { cause: error });
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
deleted: true,
|
|
151
|
+
path: relative(root, absolute).split(sep).join("/"),
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=file-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-delete.js","sourceRoot":"","sources":["../../src/qa-tools/file-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,QAAQ,EACR,OAAO,EACP,GAAG,GACJ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4BpD;;;;;;GAMG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAE/B,IAAI;IADf,YACW,IAAyB,EAClC,OAAe,EACf,OAAO,GAAiB,EAAE;QAE1B,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAJf,IAAI;QAKb,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAaD,MAAM,iBAAiB,GACrB,iLAAiL,CAAC;AACpL,MAAM,cAAc,GAClB,sIAAsI,CAAC;AACzI,MAAM,SAAS,GACb,mIAAmI,CAAC;AACtI,MAAM,UAAU,GACd,2FAA2F,CAAC;AAE9F;;;;;;GAMG;AACH,KAAK,UAAU,eAAe,CAAC,IAA2B;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,KA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BAAuB,EACvB,0CAA0C,MAAM,CAAC,IAAI,CAAC,IAAI,EAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;aACpD,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/lib/resolve-config.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolveAttachments } from "./config-resolvers/attachments.js";
|
|
|
3
3
|
import { normalizeRoutePath, resolveBasics, } from "./config-resolvers/basics.js";
|
|
4
4
|
import { DEFAULT_QA_SURFACE_CONFIG } from "./config-resolvers/defaults.js";
|
|
5
5
|
import { resolveLockdown } from "./config-resolvers/lockdown.js";
|
|
6
|
+
import { resolveNotes } from "./config-resolvers/notes.js";
|
|
6
7
|
import { resolveSession } from "./config-resolvers/session.js";
|
|
7
8
|
import { resolveSlashCommands } from "./config-resolvers/slash-commands.js";
|
|
8
9
|
import { resolveSources } from "./config-resolvers/sources.js";
|
|
@@ -44,6 +45,7 @@ export function resolveConfig(input = {}) {
|
|
|
44
45
|
sources,
|
|
45
46
|
attachments,
|
|
46
47
|
tools,
|
|
48
|
+
notes: resolveNotes(input.notes),
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
//# sourceMappingURL=resolve-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-config.js","sourceRoot":"","sources":["../src/resolve-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,aAAa,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAA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 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats the files panel previews by conversion instead of by bytes.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the Host half (which owns the conversion) and the browser card
|
|
5
|
+
* (which decides whether opening a file should ask for one), so the two cannot
|
|
6
|
+
* drift on what "we can render this" means. Dependency-free on purpose: the
|
|
7
|
+
* card bundle inlines it.
|
|
8
|
+
*/
|
|
9
|
+
/** OOXML word-processing documents, as the deployment detects them. */
|
|
10
|
+
export const QA_WORD_MEDIA_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
11
|
+
/** The media type of the PDF a converted document arrives as. */
|
|
12
|
+
export const QA_PDF_MEDIA_TYPE = "application/pdf";
|
|
13
|
+
/**
|
|
14
|
+
* Whether the panel asks the Host for a converted PDF rather than rendering the
|
|
15
|
+
* bytes it already holds. Word documents are the whole set: the document
|
|
16
|
+
* pipeline reads them and renders PDF, while its other inputs are already
|
|
17
|
+
* previewable (Markdown as text, PDF through the browser's own viewer).
|
|
18
|
+
*/
|
|
19
|
+
export function isConvertibleDocument(mediaType) {
|
|
20
|
+
return mediaType === QA_WORD_MEDIA_TYPE;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/shared/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,yEAAyE,CAAC;AAE5E,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAiB;IACrD,OAAO,SAAS,KAAK,kBAAkB,CAAC;AAC1C,CAAC"}
|