@x-otto/plugin-feedback 0.1.0-alpha.0 → 0.3.0-beta.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/dist/build-revision.json +4 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +2069 -0
- package/dist/ports-ogYiAn-s.d.ts +157 -0
- package/dist/position-bXErrER1.js +1182 -0
- package/dist/ui-entry.d.ts +17 -0
- package/dist/ui-entry.js +76 -0
- package/otto-plugin.json +9 -20
- package/package.json +28 -28
- package/README.md +0 -32
- package/panels/feedback.tsx +0 -348
- package/panels/panel-host-globals.d.ts +0 -67
- package/panels-dist/feedback.mjs +0 -257
- package/plugin-dist/meta.json +0 -1
- package/plugin-dist/plugin.cjs +0 -11304
- package/plugin.ts +0 -198
- package/src/coding-adapter.ts +0 -183
- package/src/coding-lister.ts +0 -26
- package/src/github-lister.ts +0 -230
- package/src/issue-aggregator.ts +0 -109
- package/src/issue-submitter.ts +0 -241
- package/src/platform-resolver.ts +0 -76
- package/src/pulse-survey-sink.ts +0 -114
- package/src/resolved-sink.ts +0 -163
package/dist/index.js
ADDED
|
@@ -0,0 +1,2069 @@
|
|
|
1
|
+
import { C as PUBLISHER_SERVICE, D as SURFACE_BYTES_LIMIT, E as STAGING_DIRECTORY, O as SURFACE_TEXT_LIMIT, S as PUBLISHER_OUTBOX, T as SETTING_KEYS, _ as LEGACY_PUBLISHER_CODING, a as messagesOf, b as OUTBOX_DIRECTORY, c as DEFAULT_AUTH_PROVIDER, f as FEEDBACK_PANEL_PATH, g as FEEDBACK_SERVICE_HOSTS_ENV, h as FEEDBACK_SERVICE_ALLOW_HTTP_ENV, i as linesOf, l as DIAGNOSTICS_BYTES_LIMIT, m as FEEDBACK_PLUGIN_VERSION, n as feedbackPositionKey, o as textOf, p as FEEDBACK_PLUGIN_ID, r as feedbackLocales, s as includesSessionExcerpt, t as feedbackPosition, u as FEEDBACK_HOME_DIRECTORY, v as MAX_BUNDLE_BYTES, w as SETTING_ENV, x as PUBLIC_URL_HOSTS, y as MERGE_WINDOW_MS } from "./position-bXErrER1.js";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { SLOTS, TIMINGS, adoptedPermissionModeOfSettings, commandContributionKey, resolveOttoHome, spaceSettingKey } from "@x-otto/kernel";
|
|
4
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
5
|
+
import { copyFile, mkdir, open, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
|
+
import { basename, join, relative, sep } from "node:path";
|
|
7
|
+
import { deflateRawSync } from "node:zlib";
|
|
8
|
+
import { BUNDLE_PART_NAME, FEEDBACK_PROTOCOL_HEADER, FEEDBACK_PROTOCOL_VERSION, FEEDBACK_SERVICE_PATH, META_PART_NAME, normalizeTitle, parseSubmissionResponse } from "@x-otto/feedback-protocol";
|
|
9
|
+
|
|
10
|
+
//#region src/collect/diagnostics.ts
|
|
11
|
+
function rotationOf(name, runId) {
|
|
12
|
+
if (name === `${runId}.jsonl`) return Number.MAX_SAFE_INTEGER;
|
|
13
|
+
if (!name.startsWith(`${runId}.`)) return void 0;
|
|
14
|
+
const suffix = name.slice(runId.length + 1, -6);
|
|
15
|
+
if (!/^\d+$/.test(suffix)) return void 0;
|
|
16
|
+
return Number.parseInt(suffix, 10);
|
|
17
|
+
}
|
|
18
|
+
async function readTail(path, maxBytes) {
|
|
19
|
+
const handle = await open(path, "r");
|
|
20
|
+
try {
|
|
21
|
+
const info = await handle.stat();
|
|
22
|
+
const size = Math.max(0, Math.min(info.size, maxBytes));
|
|
23
|
+
if (size === 0) return {
|
|
24
|
+
text: "",
|
|
25
|
+
cut: info.size > 0
|
|
26
|
+
};
|
|
27
|
+
const buffer = Buffer.alloc(size);
|
|
28
|
+
await handle.read(buffer, 0, size, info.size - size);
|
|
29
|
+
return {
|
|
30
|
+
text: buffer.toString("utf8"),
|
|
31
|
+
cut: info.size > size
|
|
32
|
+
};
|
|
33
|
+
} finally {
|
|
34
|
+
await handle.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function dropPartialFirstLine(text, cut) {
|
|
38
|
+
if (!cut) return text;
|
|
39
|
+
const newline = text.indexOf("\n");
|
|
40
|
+
return newline === -1 ? "" : text.slice(newline + 1);
|
|
41
|
+
}
|
|
42
|
+
function trimToLimit(text, limit) {
|
|
43
|
+
const buffer = Buffer.from(text, "utf8");
|
|
44
|
+
if (buffer.length <= limit) return text;
|
|
45
|
+
const tail = buffer.subarray(buffer.length - limit);
|
|
46
|
+
const newline = tail.indexOf(10);
|
|
47
|
+
return (newline === -1 ? tail : tail.subarray(newline + 1)).toString("utf8");
|
|
48
|
+
}
|
|
49
|
+
async function collectDiagnostics(input) {
|
|
50
|
+
const limit = input.limitBytes ?? 524288;
|
|
51
|
+
if (input.runId === void 0) return {
|
|
52
|
+
state: "absent",
|
|
53
|
+
reason: "no-run-id",
|
|
54
|
+
files: [],
|
|
55
|
+
text: "",
|
|
56
|
+
bytes: 0,
|
|
57
|
+
badLines: 0
|
|
58
|
+
};
|
|
59
|
+
let names;
|
|
60
|
+
try {
|
|
61
|
+
names = await readdir(input.directory);
|
|
62
|
+
} catch {
|
|
63
|
+
return {
|
|
64
|
+
state: "absent",
|
|
65
|
+
reason: "unreadable",
|
|
66
|
+
files: [],
|
|
67
|
+
text: "",
|
|
68
|
+
bytes: 0,
|
|
69
|
+
badLines: 0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const matched = names.map((name) => ({
|
|
73
|
+
name,
|
|
74
|
+
rotation: rotationOf(name, input.runId)
|
|
75
|
+
})).filter((entry) => entry.rotation !== void 0).sort((left, right) => left.rotation - right.rotation);
|
|
76
|
+
if (matched.length === 0) return {
|
|
77
|
+
state: "absent",
|
|
78
|
+
reason: "missing",
|
|
79
|
+
files: [],
|
|
80
|
+
text: "",
|
|
81
|
+
bytes: 0,
|
|
82
|
+
badLines: 0
|
|
83
|
+
};
|
|
84
|
+
const chunks = [];
|
|
85
|
+
let remaining = limit;
|
|
86
|
+
let headCut = false;
|
|
87
|
+
for (const entry of [...matched].reverse()) {
|
|
88
|
+
if (remaining <= 0) break;
|
|
89
|
+
try {
|
|
90
|
+
const tail = await readTail(join(input.directory, entry.name), Math.max(remaining, limit));
|
|
91
|
+
if (tail.text === "") {
|
|
92
|
+
headCut = headCut || tail.cut;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
chunks.unshift(tail.text);
|
|
96
|
+
headCut = tail.cut;
|
|
97
|
+
remaining -= Buffer.byteLength(tail.text, "utf8");
|
|
98
|
+
} catch {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const joined = dropPartialFirstLine(chunks.join(""), headCut);
|
|
103
|
+
const redactedText = input.redactor.redact(joined).text;
|
|
104
|
+
const trimmed = trimToLimit(redactedText, limit);
|
|
105
|
+
const redacted = dropPartialFirstLine(trimmed, trimmed !== redactedText);
|
|
106
|
+
let badLines = 0;
|
|
107
|
+
for (const line of redacted.split("\n")) {
|
|
108
|
+
if (line.trim() === "") continue;
|
|
109
|
+
try {
|
|
110
|
+
JSON.parse(line);
|
|
111
|
+
} catch {
|
|
112
|
+
badLines += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
state: "present",
|
|
117
|
+
files: matched.map((entry) => entry.name),
|
|
118
|
+
text: redacted,
|
|
119
|
+
bytes: Buffer.byteLength(redacted, "utf8"),
|
|
120
|
+
badLines
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/collect/environment.ts
|
|
126
|
+
function collectEnvironment(input) {
|
|
127
|
+
const missing = [];
|
|
128
|
+
const host = {};
|
|
129
|
+
const record = (key, value) => {
|
|
130
|
+
if (value === void 0 || value === "") {
|
|
131
|
+
missing.push(key);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
host[key] = value;
|
|
135
|
+
};
|
|
136
|
+
const info = input.hostInfo;
|
|
137
|
+
record("cliVersion", info?.cliVersion);
|
|
138
|
+
record("uiVersion", info?.uiVersion);
|
|
139
|
+
record("bundleMarker", info?.bundleMarker);
|
|
140
|
+
record("runId", info?.runId);
|
|
141
|
+
record("startedAt", info?.startedAt);
|
|
142
|
+
record("platform", info?.platform);
|
|
143
|
+
record("arch", info?.arch);
|
|
144
|
+
record("node", info?.node);
|
|
145
|
+
if (input.model === void 0) missing.push("model");
|
|
146
|
+
if (input.provider === void 0) missing.push("provider");
|
|
147
|
+
if (input.permissionMode === void 0) missing.push("permissionMode");
|
|
148
|
+
return {
|
|
149
|
+
plugin: {
|
|
150
|
+
id: "feedback",
|
|
151
|
+
version: input.pluginVersion
|
|
152
|
+
},
|
|
153
|
+
host,
|
|
154
|
+
...input.model === void 0 ? {} : { model: input.model },
|
|
155
|
+
...input.provider === void 0 ? {} : { provider: input.provider },
|
|
156
|
+
...input.permissionMode === void 0 ? {} : { permissionMode: input.permissionMode },
|
|
157
|
+
...input.includeWorkspaceName && input.workspaceName !== void 0 ? { workspace: { name: input.workspaceName } } : {},
|
|
158
|
+
missing
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/collect/session.ts
|
|
164
|
+
const KEY_PATTERN = /^[A-Za-z0-9_.-]{1,40}$/;
|
|
165
|
+
function textParts(content) {
|
|
166
|
+
if (typeof content === "string") return [content];
|
|
167
|
+
if (!Array.isArray(content)) return [];
|
|
168
|
+
const parts = [];
|
|
169
|
+
for (const block of content) {
|
|
170
|
+
if (typeof block !== "object" || block === null) continue;
|
|
171
|
+
const record = block;
|
|
172
|
+
if (record["type"] === "text" && typeof record["text"] === "string") parts.push(record["text"]);
|
|
173
|
+
}
|
|
174
|
+
return parts;
|
|
175
|
+
}
|
|
176
|
+
function byteLength(value) {
|
|
177
|
+
return Buffer.byteLength(value, "utf8");
|
|
178
|
+
}
|
|
179
|
+
const META_TEXT_LIMIT = 200;
|
|
180
|
+
function metaView(meta, redactor) {
|
|
181
|
+
const config = meta.config;
|
|
182
|
+
return {
|
|
183
|
+
id: meta.id,
|
|
184
|
+
createdAt: meta.createdAt,
|
|
185
|
+
lastActiveAt: meta.lastActiveAt,
|
|
186
|
+
messageCount: meta.messageCount,
|
|
187
|
+
compactionCount: meta.compactionCount,
|
|
188
|
+
...config?.modelId === void 0 ? {} : { modelId: redactor.redact(config.modelId).text.slice(0, META_TEXT_LIMIT) },
|
|
189
|
+
...config?.effort === void 0 ? {} : { effort: redactor.redact(config.effort).text.slice(0, META_TEXT_LIMIT) }
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
async function collectSession(input) {
|
|
193
|
+
const limits = input.limits ?? {
|
|
194
|
+
entryLimit: 40,
|
|
195
|
+
bytesLimit: 65536,
|
|
196
|
+
textLimit: 2e3
|
|
197
|
+
};
|
|
198
|
+
if (input.sessionId === void 0) return {
|
|
199
|
+
state: "absent",
|
|
200
|
+
reason: "no-session",
|
|
201
|
+
entries: [],
|
|
202
|
+
skipped: 0
|
|
203
|
+
};
|
|
204
|
+
const meta = await input.sessions.get(input.sessionId);
|
|
205
|
+
if (meta === null) return {
|
|
206
|
+
state: "absent",
|
|
207
|
+
reason: "not-found",
|
|
208
|
+
entries: [],
|
|
209
|
+
skipped: 0
|
|
210
|
+
};
|
|
211
|
+
let messages;
|
|
212
|
+
try {
|
|
213
|
+
messages = input.sessions.surface(input.sessionId);
|
|
214
|
+
} catch {
|
|
215
|
+
return {
|
|
216
|
+
state: "absent",
|
|
217
|
+
reason: "not-live",
|
|
218
|
+
meta: metaView(meta, input.redactor),
|
|
219
|
+
entries: [],
|
|
220
|
+
skipped: 0
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
let skipped = 0;
|
|
224
|
+
const projected = [];
|
|
225
|
+
for (const [index, message] of messages.entries()) {
|
|
226
|
+
if (message.role === "system_notification") {
|
|
227
|
+
skipped += 1;
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (message.role === "user") {
|
|
231
|
+
if (message.internal === true || message.origin !== void 0) {
|
|
232
|
+
skipped += 1;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const text = textParts(message.content).join("\n");
|
|
236
|
+
if (text.trim() === "") {
|
|
237
|
+
skipped += 1;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
const redacted = input.redactor.redact(text).text;
|
|
241
|
+
projected.push({
|
|
242
|
+
kind: "user",
|
|
243
|
+
ordinal: index,
|
|
244
|
+
at: message.timestamp,
|
|
245
|
+
text: redacted.slice(0, limits.textLimit)
|
|
246
|
+
});
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (message.role === "assistant") {
|
|
250
|
+
const text = textParts(message.content).join("\n");
|
|
251
|
+
if (text.trim() !== "") {
|
|
252
|
+
const redacted = input.redactor.redact(text).text;
|
|
253
|
+
projected.push({
|
|
254
|
+
kind: "assistant",
|
|
255
|
+
ordinal: index,
|
|
256
|
+
text: redacted.slice(0, limits.textLimit)
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
for (const block of message.content) {
|
|
260
|
+
if (typeof block !== "object" || block === null) continue;
|
|
261
|
+
const record = block;
|
|
262
|
+
if (record["type"] !== "tool_call") continue;
|
|
263
|
+
const tool = typeof record["name"] === "string" ? record["name"] : "unknown";
|
|
264
|
+
const argumentList = record["arguments"];
|
|
265
|
+
const argumentKeys = (typeof argumentList === "object" && argumentList !== null ? Object.keys(argumentList) : []).slice(0, 20).map((key) => {
|
|
266
|
+
const redacted = input.redactor.redact(key).text;
|
|
267
|
+
return KEY_PATTERN.test(redacted) ? redacted : "«key»";
|
|
268
|
+
});
|
|
269
|
+
projected.push({
|
|
270
|
+
kind: "tool-call",
|
|
271
|
+
ordinal: index,
|
|
272
|
+
tool: input.redactor.redact(tool).text.slice(0, 80),
|
|
273
|
+
argumentKeys
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (message.role === "tool_result") {
|
|
279
|
+
const text = textParts(message.content).join("\n");
|
|
280
|
+
const images = message.content.filter((block) => typeof block === "object" && block !== null && block.type === "image").length;
|
|
281
|
+
projected.push({
|
|
282
|
+
kind: "tool-result",
|
|
283
|
+
ordinal: index,
|
|
284
|
+
at: message.timestamp,
|
|
285
|
+
tool: input.redactor.redact(message.toolName).text.slice(0, 80),
|
|
286
|
+
isError: message.isError === true,
|
|
287
|
+
bytes: byteLength(text),
|
|
288
|
+
...images === 0 ? {} : { imageBytes: images }
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const sessionId = input.sessionId;
|
|
293
|
+
const window = typeof input.sessions.surfaceWindowOf === "function" ? input.sessions.surfaceWindowOf(sessionId) : void 0;
|
|
294
|
+
const factsOf = (entries) => ({
|
|
295
|
+
state: "present",
|
|
296
|
+
meta: metaView(meta, input.redactor),
|
|
297
|
+
...window === void 0 ? {} : { window },
|
|
298
|
+
entries,
|
|
299
|
+
skipped
|
|
300
|
+
});
|
|
301
|
+
let selected = projected.slice(-limits.entryLimit);
|
|
302
|
+
let bytes = byteLength(sessionArtifactText(factsOf(selected)));
|
|
303
|
+
while (bytes > limits.bytesLimit && selected.length > 1) {
|
|
304
|
+
selected = selected.slice(1);
|
|
305
|
+
bytes = byteLength(sessionArtifactText(factsOf(selected)));
|
|
306
|
+
}
|
|
307
|
+
return factsOf(selected);
|
|
308
|
+
}
|
|
309
|
+
function sessionArtifactText(facts) {
|
|
310
|
+
return `${JSON.stringify({
|
|
311
|
+
state: facts.state,
|
|
312
|
+
...facts.reason === void 0 ? {} : { reason: facts.reason },
|
|
313
|
+
...facts.meta === void 0 ? {} : { meta: facts.meta },
|
|
314
|
+
...facts.window === void 0 ? {} : { window: facts.window },
|
|
315
|
+
skipped: facts.skipped,
|
|
316
|
+
entries: facts.entries
|
|
317
|
+
}, null, 2)}\n`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/redact/redact.ts
|
|
322
|
+
const REDACTED = "«redacted»";
|
|
323
|
+
const TOKEN_PATTERN = /\b(?:sk-[A-Za-z0-9_-]{8,}|gh[opsu]_[A-Za-z0-9]{16,}|glpat-[A-Za-z0-9_-]{8,}|npm_[A-Za-z0-9]{8,}|AIza[A-Za-z0-9_-]{10,}|AKIA[0-9A-Z]{16}|xox[baprs]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})\b/g;
|
|
324
|
+
const BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._-]{8,}/gi;
|
|
325
|
+
const PEM_COMPLETE = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g;
|
|
326
|
+
const PEM_DANGLING = /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*$/g;
|
|
327
|
+
const KEY_VALUE = /(\b[A-Za-z0-9_.-]*(?:token|secret|password|passwd|pass|pwd|key|credential|cookie|auth)[A-Za-z0-9_.-]*["']?\s*[:=]\s*)(["']?)([^\s"',;]+)\2/gi;
|
|
328
|
+
const URL_USERINFO = /(\b[a-z][a-z0-9+.-]*:\/\/)([^/\s@]+)@/gi;
|
|
329
|
+
const URL_HOST = /(\b[a-z][a-z0-9+.-]*):\/\/((?:[^/\s@]*@)*)([^/\s?#@]+)/gi;
|
|
330
|
+
const GIT_REMOTE = /\bgit@([A-Za-z0-9_.-]+):([^\s"'`]+)/g;
|
|
331
|
+
const EMAIL = /\b(?!git@)[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
|
|
332
|
+
const HOME_USER = /\/(?:Users|home)\/[A-Za-z0-9._-]+/g;
|
|
333
|
+
const WINDOWS_HOME = /\b[A-Za-z]:\\{1,2}Users\\{1,2}[^\\\s"'<>|]+/gi;
|
|
334
|
+
const WINDOWS_UNC_HOME = /\\{2,4}[A-Za-z0-9._$-]+(?:\\{1,2}[A-Za-z0-9._$-]+)*\\{1,2}Users\\{1,2}[^\\\s"'<>|]+/gi;
|
|
335
|
+
const TEMPORARY = /\/(?:var\/folders|private\/tmp|tmp)\/[^\s"']*/g;
|
|
336
|
+
function escapeRegExp(value) {
|
|
337
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
338
|
+
}
|
|
339
|
+
function boundaryPattern(value) {
|
|
340
|
+
return new RegExp(`(?<![A-Za-z0-9._-])${escapeRegExp(value)}(?![A-Za-z0-9._-])`, "g");
|
|
341
|
+
}
|
|
342
|
+
function countOf(text, pattern) {
|
|
343
|
+
const found = text.match(pattern);
|
|
344
|
+
return found === null ? 0 : found.length;
|
|
345
|
+
}
|
|
346
|
+
function createRedactor(context) {
|
|
347
|
+
const publicHosts = new Set((context.publicHosts ?? PUBLIC_URL_HOSTS).map((host) => host.toLowerCase()));
|
|
348
|
+
const totals = {};
|
|
349
|
+
const homeRelative = relative(context.home, context.cwd);
|
|
350
|
+
const pathVariants = [];
|
|
351
|
+
const addVariant = (variant, replacement, rule) => {
|
|
352
|
+
if (variant === "" || variant === sep || variant === "/") return;
|
|
353
|
+
if (pathVariants.some((entry) => entry.variant === variant)) return;
|
|
354
|
+
pathVariants.push({
|
|
355
|
+
variant,
|
|
356
|
+
replacement,
|
|
357
|
+
rule
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
addVariant(context.ottoHome, "~", "path");
|
|
361
|
+
addVariant(context.cwd, "<workspace>", "path");
|
|
362
|
+
if (!homeRelative.startsWith("..") && homeRelative !== "") addVariant(`~/${homeRelative.split(sep).join("/")}`, "<workspace>", "path");
|
|
363
|
+
addVariant(context.home, "~", "path");
|
|
364
|
+
const workspaceName = context.workspaceName ?? "";
|
|
365
|
+
if (workspaceName.length >= 3) addVariant(workspaceName, "<workspace>", "workspace-name");
|
|
366
|
+
pathVariants.sort((left, right) => right.variant.length - left.variant.length);
|
|
367
|
+
const bump = (rule, count) => {
|
|
368
|
+
if (count === 0) return;
|
|
369
|
+
totals[rule] = (totals[rule] ?? 0) + count;
|
|
370
|
+
};
|
|
371
|
+
const apply = (text) => {
|
|
372
|
+
const hits = {};
|
|
373
|
+
let next = text;
|
|
374
|
+
const note = (rule, count) => {
|
|
375
|
+
if (count === 0) return;
|
|
376
|
+
hits[rule] = (hits[rule] ?? 0) + count;
|
|
377
|
+
};
|
|
378
|
+
for (const entry of pathVariants) {
|
|
379
|
+
const pattern = boundaryPattern(entry.variant);
|
|
380
|
+
const count = countOf(next, pattern);
|
|
381
|
+
if (count === 0) continue;
|
|
382
|
+
next = next.replace(pattern, entry.replacement);
|
|
383
|
+
note(entry.rule, count);
|
|
384
|
+
}
|
|
385
|
+
let count = countOf(next, HOME_USER);
|
|
386
|
+
if (count > 0) {
|
|
387
|
+
next = next.replace(HOME_USER, "~");
|
|
388
|
+
note("path", count);
|
|
389
|
+
}
|
|
390
|
+
count = countOf(next, WINDOWS_UNC_HOME);
|
|
391
|
+
if (count > 0) {
|
|
392
|
+
next = next.replace(WINDOWS_UNC_HOME, "~");
|
|
393
|
+
note("path", count);
|
|
394
|
+
}
|
|
395
|
+
count = countOf(next, WINDOWS_HOME);
|
|
396
|
+
if (count > 0) {
|
|
397
|
+
next = next.replace(WINDOWS_HOME, "~");
|
|
398
|
+
note("path", count);
|
|
399
|
+
}
|
|
400
|
+
count = countOf(next, TEMPORARY);
|
|
401
|
+
if (count > 0) {
|
|
402
|
+
next = next.replace(TEMPORARY, "<tmp>");
|
|
403
|
+
note("path", count);
|
|
404
|
+
}
|
|
405
|
+
count = countOf(next, PEM_COMPLETE);
|
|
406
|
+
if (count > 0) {
|
|
407
|
+
next = next.replace(PEM_COMPLETE, REDACTED);
|
|
408
|
+
note("pem", count);
|
|
409
|
+
}
|
|
410
|
+
count = countOf(next, PEM_DANGLING);
|
|
411
|
+
if (count > 0) {
|
|
412
|
+
next = next.replace(PEM_DANGLING, REDACTED);
|
|
413
|
+
note("pem", count);
|
|
414
|
+
}
|
|
415
|
+
count = countOf(next, TOKEN_PATTERN);
|
|
416
|
+
if (count > 0) {
|
|
417
|
+
next = next.replace(TOKEN_PATTERN, REDACTED);
|
|
418
|
+
note("token", count);
|
|
419
|
+
}
|
|
420
|
+
count = countOf(next, BEARER_PATTERN);
|
|
421
|
+
if (count > 0) {
|
|
422
|
+
next = next.replace(BEARER_PATTERN, `Bearer ${REDACTED}`);
|
|
423
|
+
note("token", count);
|
|
424
|
+
}
|
|
425
|
+
count = countOf(next, KEY_VALUE);
|
|
426
|
+
if (count > 0) {
|
|
427
|
+
next = next.replace(KEY_VALUE, `$1$2${REDACTED}$2`);
|
|
428
|
+
note("key-value", count);
|
|
429
|
+
}
|
|
430
|
+
count = countOf(next, URL_USERINFO);
|
|
431
|
+
if (count > 0) {
|
|
432
|
+
next = next.replace(URL_USERINFO, `$1«userinfo»@`);
|
|
433
|
+
note("url-userinfo", count);
|
|
434
|
+
}
|
|
435
|
+
count = countOf(next, URL_HOST);
|
|
436
|
+
if (count > 0) {
|
|
437
|
+
next = next.replace(URL_HOST, (match, scheme, userInfo, host) => {
|
|
438
|
+
const bare = host.toLowerCase().replace(/:\d+$/, "");
|
|
439
|
+
if (publicHosts.has(bare)) return match;
|
|
440
|
+
return `${scheme}://${userInfo === "" ? "" : "«userinfo»@"}<host>`;
|
|
441
|
+
});
|
|
442
|
+
note("url-host", count);
|
|
443
|
+
}
|
|
444
|
+
count = countOf(next, GIT_REMOTE);
|
|
445
|
+
if (count > 0) {
|
|
446
|
+
next = next.replace(GIT_REMOTE, (_match, host) => {
|
|
447
|
+
const bare = String(host).toLowerCase();
|
|
448
|
+
return `git@${publicHosts.has(bare) ? host : "<git-host>"}:«repo»`;
|
|
449
|
+
});
|
|
450
|
+
note("git-remote", count);
|
|
451
|
+
}
|
|
452
|
+
count = countOf(next, EMAIL);
|
|
453
|
+
if (count > 0) {
|
|
454
|
+
next = next.replace(EMAIL, "«email»");
|
|
455
|
+
note("email", count);
|
|
456
|
+
}
|
|
457
|
+
for (const [rule, value] of Object.entries(hits)) bump(rule, value);
|
|
458
|
+
return {
|
|
459
|
+
text: next,
|
|
460
|
+
hits
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
return {
|
|
464
|
+
redact(text) {
|
|
465
|
+
return apply(text);
|
|
466
|
+
},
|
|
467
|
+
totals() {
|
|
468
|
+
return { ...totals };
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/bundle/manifest.ts
|
|
475
|
+
function buildManifest(input) {
|
|
476
|
+
const files = input.files.map((file) => ({
|
|
477
|
+
path: file.path,
|
|
478
|
+
bytes: file.bytes,
|
|
479
|
+
sha256: file.sha256
|
|
480
|
+
}));
|
|
481
|
+
const redactions = {};
|
|
482
|
+
for (const key of Object.keys(input.redactions).sort()) redactions[key] = input.redactions[key] ?? 0;
|
|
483
|
+
return {
|
|
484
|
+
schema: 1,
|
|
485
|
+
id: input.bundleId,
|
|
486
|
+
createdAt: new Date(input.createdAt).toISOString(),
|
|
487
|
+
plugin: {
|
|
488
|
+
id: "feedback",
|
|
489
|
+
version: "0.1.0"
|
|
490
|
+
},
|
|
491
|
+
consent: input.draft.consent,
|
|
492
|
+
category: input.draft.category,
|
|
493
|
+
descriptionBytes: Buffer.byteLength(input.draft.description, "utf8"),
|
|
494
|
+
source: {
|
|
495
|
+
processId: input.processId,
|
|
496
|
+
...input.sessionId === void 0 ? {} : { sessionId: input.sessionId },
|
|
497
|
+
...input.runId === void 0 ? {} : { runId: input.runId }
|
|
498
|
+
},
|
|
499
|
+
host: input.host,
|
|
500
|
+
diagnostics: {
|
|
501
|
+
state: input.diagnostics.state,
|
|
502
|
+
...input.diagnostics.reason === void 0 ? {} : { reason: input.diagnostics.reason },
|
|
503
|
+
files: input.diagnostics.files,
|
|
504
|
+
bytes: input.diagnostics.bytes,
|
|
505
|
+
badLines: input.diagnostics.badLines
|
|
506
|
+
},
|
|
507
|
+
counts: input.counts,
|
|
508
|
+
redactions,
|
|
509
|
+
missing: input.missing,
|
|
510
|
+
files
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/bundle/report.ts
|
|
516
|
+
function iso(at) {
|
|
517
|
+
return new Date(at).toISOString();
|
|
518
|
+
}
|
|
519
|
+
function entriesOfEnvironment(environment) {
|
|
520
|
+
const lines = [];
|
|
521
|
+
for (const [key, value] of Object.entries(environment.host)) lines.push(`- ${key}: ${String(value)}`);
|
|
522
|
+
if (environment.model !== void 0) lines.push(`- model: ${environment.model}`);
|
|
523
|
+
if (environment.provider !== void 0) lines.push(`- provider: ${environment.provider}`);
|
|
524
|
+
if (environment.permissionMode !== void 0) lines.push(`- permissionMode: ${environment.permissionMode}`);
|
|
525
|
+
if (environment.workspace !== void 0) lines.push(`- workspace: ${environment.workspace.name}`);
|
|
526
|
+
lines.push(`- plugin: ${environment.plugin.id}@${environment.plugin.version}`);
|
|
527
|
+
if (environment.missing.length > 0) lines.push(`- missing: ${environment.missing.join(", ")}`);
|
|
528
|
+
return lines;
|
|
529
|
+
}
|
|
530
|
+
function operationLine(entry) {
|
|
531
|
+
const parts = [
|
|
532
|
+
`- ${iso(entry.at)}`,
|
|
533
|
+
entry.kind,
|
|
534
|
+
entry.name
|
|
535
|
+
];
|
|
536
|
+
if (entry.status !== void 0) parts.push(`[${entry.status}]`);
|
|
537
|
+
if (entry.count !== void 0) parts.push(`x${entry.count}`);
|
|
538
|
+
if (entry.characters !== void 0) parts.push(`${entry.characters} chars`);
|
|
539
|
+
if (entry.durationMs !== void 0) parts.push(`${entry.durationMs} ms`);
|
|
540
|
+
if (entry.code !== void 0) parts.push(`code=${entry.code}`);
|
|
541
|
+
if (entry.reason !== void 0) parts.push(`reason=${entry.reason}`);
|
|
542
|
+
if (entry.sessionId !== void 0) parts.push(`session=${entry.sessionId}`);
|
|
543
|
+
return parts.join(" ");
|
|
544
|
+
}
|
|
545
|
+
function sessionLines(session) {
|
|
546
|
+
if (session.state === "absent") return [`Session content was not included (${session.reason ?? "unavailable"}).`];
|
|
547
|
+
const lines = [];
|
|
548
|
+
if (session.window !== void 0) lines.push(`- surface window: ${session.window.loaded}/${session.window.total}`);
|
|
549
|
+
if (session.skipped > 0) lines.push(`- skipped entries: ${session.skipped}`);
|
|
550
|
+
for (const entry of session.entries) {
|
|
551
|
+
const head = `- #${entry.ordinal} ${entry.kind}`;
|
|
552
|
+
if (entry.kind === "tool-call") {
|
|
553
|
+
lines.push(`${head} ${entry.tool ?? "unknown"} (${(entry.argumentKeys ?? []).join(", ")})`);
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (entry.kind === "tool-result") {
|
|
557
|
+
const status = entry.isError === true ? "error" : "ok";
|
|
558
|
+
lines.push(`${head} ${entry.tool ?? "unknown"} ${status} ${entry.bytes ?? 0} bytes`);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
lines.push(`${head}: ${entry.text ?? ""}`);
|
|
562
|
+
}
|
|
563
|
+
return lines;
|
|
564
|
+
}
|
|
565
|
+
function renderReport(input) {
|
|
566
|
+
const lines = [];
|
|
567
|
+
lines.push("# Feedback report");
|
|
568
|
+
lines.push("");
|
|
569
|
+
lines.push("Generated from the otto feedback dialog (template v1).");
|
|
570
|
+
lines.push("");
|
|
571
|
+
lines.push("## Summary");
|
|
572
|
+
lines.push("");
|
|
573
|
+
lines.push(`- bundle: ${input.bundleId}`);
|
|
574
|
+
lines.push(`- created: ${iso(input.generatedAt)}`);
|
|
575
|
+
lines.push(`- category: ${input.draft.category}`);
|
|
576
|
+
lines.push(`- title: ${input.draft.title}`);
|
|
577
|
+
lines.push("");
|
|
578
|
+
lines.push("## What happened");
|
|
579
|
+
lines.push("");
|
|
580
|
+
lines.push(input.draft.description.trim() === "" ? "(no notes provided)" : input.draft.description);
|
|
581
|
+
lines.push("");
|
|
582
|
+
lines.push("## Environment");
|
|
583
|
+
lines.push("");
|
|
584
|
+
lines.push(...entriesOfEnvironment(input.environment));
|
|
585
|
+
lines.push("");
|
|
586
|
+
lines.push(`## Operations (last ${input.operations.entries.length})`);
|
|
587
|
+
lines.push("");
|
|
588
|
+
if (input.operations.entries.length === 0) lines.push("(no operations recorded)");
|
|
589
|
+
else for (const entry of input.operations.entries) lines.push(operationLine(entry));
|
|
590
|
+
if (input.operations.dropped > 0) lines.push(`- dropped from the ring: ${input.operations.dropped}`);
|
|
591
|
+
if (input.operations.skipped > 0) lines.push(`- malformed observations skipped: ${input.operations.skipped}`);
|
|
592
|
+
lines.push("");
|
|
593
|
+
lines.push("## Last errors");
|
|
594
|
+
lines.push("");
|
|
595
|
+
const errors = input.operations.entries.filter((entry) => entry.kind === "error").slice(-10);
|
|
596
|
+
if (errors.length === 0) lines.push("(none in the retained window)");
|
|
597
|
+
else for (const entry of errors) lines.push(operationLine(entry));
|
|
598
|
+
lines.push("");
|
|
599
|
+
lines.push("## Session excerpt");
|
|
600
|
+
lines.push("");
|
|
601
|
+
lines.push(...sessionLines(input.session));
|
|
602
|
+
lines.push("");
|
|
603
|
+
lines.push("## Diagnostics");
|
|
604
|
+
lines.push("");
|
|
605
|
+
if (input.diagnostics.state === "absent") lines.push(`- not included: ${input.diagnostics.reason ?? "unavailable"}`);
|
|
606
|
+
else {
|
|
607
|
+
lines.push(`- files: ${input.diagnostics.files.join(", ")}`);
|
|
608
|
+
lines.push(`- bytes: ${input.diagnostics.bytes}`);
|
|
609
|
+
lines.push(`- unparsable lines: ${input.diagnostics.badLines}`);
|
|
610
|
+
}
|
|
611
|
+
lines.push("");
|
|
612
|
+
lines.push("## Attachments");
|
|
613
|
+
lines.push("");
|
|
614
|
+
for (const file of input.files) lines.push(`- ${file.path} (${file.bytes} bytes)`);
|
|
615
|
+
lines.push("");
|
|
616
|
+
lines.push(`Source: otto feedback ${input.environment.plugin.version} · bundle ${input.bundleId} · template v1`);
|
|
617
|
+
lines.push("");
|
|
618
|
+
return lines.join("\n");
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/bundle/crc32.ts
|
|
623
|
+
const TABLE = (() => {
|
|
624
|
+
const table = new Uint32Array(256);
|
|
625
|
+
for (let index = 0; index < 256; index += 1) {
|
|
626
|
+
let value = index;
|
|
627
|
+
for (let bit = 0; bit < 8; bit += 1) value = (value & 1) === 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
|
|
628
|
+
table[index] = value >>> 0;
|
|
629
|
+
}
|
|
630
|
+
return table;
|
|
631
|
+
})();
|
|
632
|
+
function crc32(data) {
|
|
633
|
+
let crc = 4294967295;
|
|
634
|
+
for (const byte of data) crc = (TABLE[(crc ^ byte) & 255] ?? 0) ^ crc >>> 8;
|
|
635
|
+
return (crc ^ 4294967295) >>> 0;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/bundle/zip.ts
|
|
640
|
+
const UTF8_FLAG = 2048;
|
|
641
|
+
const VERSION = 20;
|
|
642
|
+
const DOS_TIME = 0;
|
|
643
|
+
const DOS_DATE = 33;
|
|
644
|
+
const MAX_ENTRIES = 4096;
|
|
645
|
+
function normalizePath(path) {
|
|
646
|
+
if (path === "" || path.startsWith("/") || path.includes("\\") || path.includes("\0")) throw new Error(`feedback zip: unsafe entry path "${path}"`);
|
|
647
|
+
if (path.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) throw new Error(`feedback zip: unsafe entry path "${path}"`);
|
|
648
|
+
return path;
|
|
649
|
+
}
|
|
650
|
+
function writeZip(entries) {
|
|
651
|
+
if (entries.length === 0 || entries.length > MAX_ENTRIES) throw new Error(`feedback zip: entry count ${entries.length} is out of range`);
|
|
652
|
+
const seen = /* @__PURE__ */ new Set();
|
|
653
|
+
const sorted = [...entries].map((entry) => ({
|
|
654
|
+
path: normalizePath(entry.path),
|
|
655
|
+
data: entry.data
|
|
656
|
+
})).sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
657
|
+
for (const entry of sorted) {
|
|
658
|
+
if (seen.has(entry.path)) throw new Error(`feedback zip: duplicate entry "${entry.path}"`);
|
|
659
|
+
seen.add(entry.path);
|
|
660
|
+
}
|
|
661
|
+
const locals = [];
|
|
662
|
+
const centrals = [];
|
|
663
|
+
let offset = 0;
|
|
664
|
+
for (const entry of sorted) {
|
|
665
|
+
const name = Buffer.from(entry.path, "utf8");
|
|
666
|
+
const crc = crc32(entry.data);
|
|
667
|
+
const deflated = deflateRawSync(entry.data, { level: 9 });
|
|
668
|
+
const useDeflate = deflated.length < entry.data.length;
|
|
669
|
+
const payload = useDeflate ? deflated : entry.data;
|
|
670
|
+
const method = useDeflate ? 8 : 0;
|
|
671
|
+
const local = Buffer.alloc(30);
|
|
672
|
+
local.writeUInt32LE(67324752, 0);
|
|
673
|
+
local.writeUInt16LE(VERSION, 4);
|
|
674
|
+
local.writeUInt16LE(UTF8_FLAG, 6);
|
|
675
|
+
local.writeUInt16LE(method, 8);
|
|
676
|
+
local.writeUInt16LE(DOS_TIME, 10);
|
|
677
|
+
local.writeUInt16LE(DOS_DATE, 12);
|
|
678
|
+
local.writeUInt32LE(crc, 14);
|
|
679
|
+
local.writeUInt32LE(payload.length, 18);
|
|
680
|
+
local.writeUInt32LE(entry.data.length, 22);
|
|
681
|
+
local.writeUInt16LE(name.length, 26);
|
|
682
|
+
local.writeUInt16LE(0, 28);
|
|
683
|
+
locals.push(local, name, payload);
|
|
684
|
+
const central = Buffer.alloc(46);
|
|
685
|
+
central.writeUInt32LE(33639248, 0);
|
|
686
|
+
central.writeUInt16LE(VERSION, 4);
|
|
687
|
+
central.writeUInt16LE(VERSION, 6);
|
|
688
|
+
central.writeUInt16LE(UTF8_FLAG, 8);
|
|
689
|
+
central.writeUInt16LE(method, 10);
|
|
690
|
+
central.writeUInt16LE(DOS_TIME, 12);
|
|
691
|
+
central.writeUInt16LE(DOS_DATE, 14);
|
|
692
|
+
central.writeUInt32LE(crc, 16);
|
|
693
|
+
central.writeUInt32LE(payload.length, 20);
|
|
694
|
+
central.writeUInt32LE(entry.data.length, 24);
|
|
695
|
+
central.writeUInt16LE(name.length, 28);
|
|
696
|
+
central.writeUInt16LE(0, 30);
|
|
697
|
+
central.writeUInt16LE(0, 32);
|
|
698
|
+
central.writeUInt16LE(0, 34);
|
|
699
|
+
central.writeUInt16LE(0, 36);
|
|
700
|
+
central.writeUInt32LE(0, 38);
|
|
701
|
+
central.writeUInt32LE(offset, 42);
|
|
702
|
+
centrals.push(central, name);
|
|
703
|
+
offset += local.length + name.length + payload.length;
|
|
704
|
+
}
|
|
705
|
+
const centralBuffer = Buffer.concat(centrals);
|
|
706
|
+
const end = Buffer.alloc(22);
|
|
707
|
+
end.writeUInt32LE(101010256, 0);
|
|
708
|
+
end.writeUInt16LE(0, 4);
|
|
709
|
+
end.writeUInt16LE(0, 6);
|
|
710
|
+
end.writeUInt16LE(sorted.length, 8);
|
|
711
|
+
end.writeUInt16LE(sorted.length, 10);
|
|
712
|
+
end.writeUInt32LE(centralBuffer.length, 12);
|
|
713
|
+
end.writeUInt32LE(offset, 16);
|
|
714
|
+
end.writeUInt16LE(0, 20);
|
|
715
|
+
return Buffer.concat([
|
|
716
|
+
...locals,
|
|
717
|
+
centralBuffer,
|
|
718
|
+
end
|
|
719
|
+
]);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/bundle/bundle.ts
|
|
724
|
+
function pad(value, width) {
|
|
725
|
+
return String(value).padStart(width, "0");
|
|
726
|
+
}
|
|
727
|
+
function defaultBundleId(at, random = () => randomBytes(4).toString("hex")) {
|
|
728
|
+
const date = new Date(at);
|
|
729
|
+
return `feedback-${`${date.getUTCFullYear()}${pad(date.getUTCMonth() + 1, 2)}${pad(date.getUTCDate(), 2)}-${pad(date.getUTCHours(), 2)}${pad(date.getUTCMinutes(), 2)}${pad(date.getUTCSeconds(), 2)}`}-${random()}`;
|
|
730
|
+
}
|
|
731
|
+
function sha256(text) {
|
|
732
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
733
|
+
}
|
|
734
|
+
function ensureActive(signal) {
|
|
735
|
+
if (signal.aborted) throw new Error("FEEDBACK_BUILD_CANCELLED");
|
|
736
|
+
}
|
|
737
|
+
function createBundler(deps) {
|
|
738
|
+
const now = deps.now ?? Date.now;
|
|
739
|
+
const newId = deps.newId ?? (() => defaultBundleId(now()));
|
|
740
|
+
const processId = deps.processId ?? process.pid;
|
|
741
|
+
const maxBytes = deps.maxBundleBytes ?? (() => 4194304);
|
|
742
|
+
return {
|
|
743
|
+
async build(draft, signal) {
|
|
744
|
+
const createdAt = now();
|
|
745
|
+
const bundleId = newId();
|
|
746
|
+
const workspaceName = basename(deps.cwd);
|
|
747
|
+
const redactor = createRedactor({
|
|
748
|
+
ottoHome: deps.home,
|
|
749
|
+
cwd: deps.cwd,
|
|
750
|
+
home: homedir(),
|
|
751
|
+
...workspaceName === "" ? {} : { workspaceName }
|
|
752
|
+
});
|
|
753
|
+
const hostInfo = deps.hostInfo();
|
|
754
|
+
const environment = collectEnvironment({
|
|
755
|
+
hostInfo,
|
|
756
|
+
pluginVersion: deps.pluginVersion,
|
|
757
|
+
...deps.model() === void 0 ? {} : { model: deps.model() },
|
|
758
|
+
...deps.provider() === void 0 ? {} : { provider: deps.provider() },
|
|
759
|
+
...deps.permissionMode() === void 0 ? {} : { permissionMode: deps.permissionMode() },
|
|
760
|
+
...workspaceName === "" ? {} : { workspaceName },
|
|
761
|
+
includeWorkspaceName: draft.includeWorkspaceName
|
|
762
|
+
});
|
|
763
|
+
ensureActive(signal);
|
|
764
|
+
const redactedEnvironment = {
|
|
765
|
+
...environment,
|
|
766
|
+
...environment.model === void 0 ? {} : { model: redactor.redact(environment.model).text },
|
|
767
|
+
...environment.provider === void 0 ? {} : { provider: redactor.redact(environment.provider).text },
|
|
768
|
+
...environment.permissionMode === void 0 ? {} : { permissionMode: redactor.redact(environment.permissionMode).text }
|
|
769
|
+
};
|
|
770
|
+
const withSession = includesSessionExcerpt(draft.category);
|
|
771
|
+
const requiredScope = [
|
|
772
|
+
...withSession && draft.sessionId !== void 0 ? ["session"] : [],
|
|
773
|
+
"operations",
|
|
774
|
+
"environment",
|
|
775
|
+
...deps.includeDiagnostics() ? ["diagnostics"] : [],
|
|
776
|
+
...draft.includeWorkspaceName ? ["workspace-name"] : []
|
|
777
|
+
];
|
|
778
|
+
const consented = new Set(draft.consent.accepted === true ? draft.consent.scope : []);
|
|
779
|
+
if (requiredScope.filter((scope) => !consented.has(scope)).length > 0) throw new Error("FEEDBACK_CONSENT_SCOPE_MISMATCH");
|
|
780
|
+
const session = withSession ? await collectSession({
|
|
781
|
+
sessions: deps.sessions,
|
|
782
|
+
sessionId: draft.sessionId,
|
|
783
|
+
redactor
|
|
784
|
+
}) : {
|
|
785
|
+
state: "absent",
|
|
786
|
+
reason: "idea-category",
|
|
787
|
+
entries: [],
|
|
788
|
+
skipped: 0
|
|
789
|
+
};
|
|
790
|
+
ensureActive(signal);
|
|
791
|
+
const diagnostics = deps.includeDiagnostics() ? await collectDiagnostics({
|
|
792
|
+
directory: join(deps.home, "diagnostics"),
|
|
793
|
+
runId: hostInfo?.runId,
|
|
794
|
+
redactor
|
|
795
|
+
}) : {
|
|
796
|
+
state: "absent",
|
|
797
|
+
reason: "disabled",
|
|
798
|
+
files: [],
|
|
799
|
+
text: "",
|
|
800
|
+
bytes: 0,
|
|
801
|
+
badLines: 0
|
|
802
|
+
};
|
|
803
|
+
ensureActive(signal);
|
|
804
|
+
const operations = deps.operations();
|
|
805
|
+
const title = redactor.redact(draft.title).text.slice(0, 200);
|
|
806
|
+
const description = redactor.redact(draft.description).text;
|
|
807
|
+
const redactedEntries = operations.entries.map((entry) => ({
|
|
808
|
+
...entry,
|
|
809
|
+
name: redactor.redact(entry.name).text,
|
|
810
|
+
...entry.code === void 0 ? {} : { code: redactor.redact(entry.code).text }
|
|
811
|
+
}));
|
|
812
|
+
const redactedOperations = {
|
|
813
|
+
...operations,
|
|
814
|
+
entries: redactedEntries
|
|
815
|
+
};
|
|
816
|
+
const operational = redactedEntries.map((entry) => JSON.stringify(entry));
|
|
817
|
+
const operationsText = operational.length === 0 ? "" : `${operational.join("\n")}\n`;
|
|
818
|
+
const sessionText = withSession ? sessionArtifactText(session) : "";
|
|
819
|
+
const environmentText = `${JSON.stringify(redactedEnvironment, null, 2)}\n`;
|
|
820
|
+
const diagnosticsText = diagnostics.state === "present" ? diagnostics.text : "";
|
|
821
|
+
const reportInputsFiles = [
|
|
822
|
+
{
|
|
823
|
+
path: "environment.json",
|
|
824
|
+
bytes: Buffer.byteLength(environmentText, "utf8")
|
|
825
|
+
},
|
|
826
|
+
...withSession ? [{
|
|
827
|
+
path: "session.json",
|
|
828
|
+
bytes: Buffer.byteLength(sessionText, "utf8")
|
|
829
|
+
}] : [],
|
|
830
|
+
{
|
|
831
|
+
path: "operations.jsonl",
|
|
832
|
+
bytes: Buffer.byteLength(operationsText, "utf8")
|
|
833
|
+
},
|
|
834
|
+
...diagnosticsText === "" ? [] : [{
|
|
835
|
+
path: "diagnostics.jsonl",
|
|
836
|
+
bytes: Buffer.byteLength(diagnosticsText, "utf8")
|
|
837
|
+
}]
|
|
838
|
+
];
|
|
839
|
+
const report = renderReport({
|
|
840
|
+
bundleId,
|
|
841
|
+
generatedAt: createdAt,
|
|
842
|
+
draft: {
|
|
843
|
+
...draft,
|
|
844
|
+
title,
|
|
845
|
+
description
|
|
846
|
+
},
|
|
847
|
+
environment: redactedEnvironment,
|
|
848
|
+
session,
|
|
849
|
+
operations: redactedOperations,
|
|
850
|
+
diagnostics,
|
|
851
|
+
files: reportInputsFiles
|
|
852
|
+
});
|
|
853
|
+
const files = [
|
|
854
|
+
{
|
|
855
|
+
path: "report.md",
|
|
856
|
+
text: report
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
path: "environment.json",
|
|
860
|
+
text: environmentText
|
|
861
|
+
},
|
|
862
|
+
...withSession ? [{
|
|
863
|
+
path: "session.json",
|
|
864
|
+
text: sessionText
|
|
865
|
+
}] : [],
|
|
866
|
+
{
|
|
867
|
+
path: "operations.jsonl",
|
|
868
|
+
text: operationsText
|
|
869
|
+
},
|
|
870
|
+
...diagnosticsText === "" ? [] : [{
|
|
871
|
+
path: "diagnostics.jsonl",
|
|
872
|
+
text: diagnosticsText
|
|
873
|
+
}]
|
|
874
|
+
].map((payload) => ({
|
|
875
|
+
path: payload.path,
|
|
876
|
+
bytes: Buffer.byteLength(payload.text, "utf8"),
|
|
877
|
+
sha256: sha256(payload.text),
|
|
878
|
+
text: payload.text
|
|
879
|
+
}));
|
|
880
|
+
const counts = {
|
|
881
|
+
operations: operations.entries.length,
|
|
882
|
+
operationsDropped: operations.dropped,
|
|
883
|
+
operationsSkipped: operations.skipped,
|
|
884
|
+
sessionEntries: session.entries.length,
|
|
885
|
+
diagnostics: diagnostics.state === "present" ? diagnostics.bytes : 0,
|
|
886
|
+
skipped: session.skipped
|
|
887
|
+
};
|
|
888
|
+
const manifest = buildManifest({
|
|
889
|
+
bundleId,
|
|
890
|
+
createdAt,
|
|
891
|
+
draft,
|
|
892
|
+
diagnostics,
|
|
893
|
+
counts,
|
|
894
|
+
redactions: redactor.totals(),
|
|
895
|
+
files,
|
|
896
|
+
missing: redactedEnvironment.missing,
|
|
897
|
+
host: {
|
|
898
|
+
uiActivity: deps.uiActivity(),
|
|
899
|
+
hostInfo: hostInfo !== void 0
|
|
900
|
+
},
|
|
901
|
+
processId,
|
|
902
|
+
...draft.sessionId === void 0 ? {} : { sessionId: draft.sessionId },
|
|
903
|
+
...hostInfo?.runId === void 0 ? {} : { runId: hostInfo.runId }
|
|
904
|
+
});
|
|
905
|
+
const manifestText = `${JSON.stringify(manifest, null, 2)}\n`;
|
|
906
|
+
const all = [...files, {
|
|
907
|
+
path: "manifest.json",
|
|
908
|
+
bytes: Buffer.byteLength(manifestText, "utf8"),
|
|
909
|
+
sha256: sha256(manifestText),
|
|
910
|
+
text: manifestText
|
|
911
|
+
}];
|
|
912
|
+
if (all.reduce((total, file) => total + file.bytes, 0) > maxBytes() * 32) throw new Error("FEEDBACK_BUNDLE_TOO_LARGE");
|
|
913
|
+
const archive = writeZip(all.map((file) => ({
|
|
914
|
+
path: file.path,
|
|
915
|
+
data: Buffer.from(file.text ?? "", "utf8")
|
|
916
|
+
})));
|
|
917
|
+
if (archive.length > maxBytes()) throw new Error("FEEDBACK_BUNDLE_TOO_LARGE");
|
|
918
|
+
ensureActive(signal);
|
|
919
|
+
const directory = join(deps.home, "feedback", STAGING_DIRECTORY, bundleId);
|
|
920
|
+
await mkdir(join(deps.home, "feedback", STAGING_DIRECTORY), { recursive: true });
|
|
921
|
+
await rm(directory, {
|
|
922
|
+
recursive: true,
|
|
923
|
+
force: true
|
|
924
|
+
});
|
|
925
|
+
await mkdir(directory, { recursive: true });
|
|
926
|
+
const archivePath = join(directory, `${bundleId}.zip`);
|
|
927
|
+
try {
|
|
928
|
+
for (const file of all) await writeFile(join(directory, file.path), file.text ?? "", {
|
|
929
|
+
encoding: "utf8",
|
|
930
|
+
mode: 384
|
|
931
|
+
});
|
|
932
|
+
await writeFile(archivePath, archive, { mode: 384 });
|
|
933
|
+
} catch (error) {
|
|
934
|
+
await rm(directory, {
|
|
935
|
+
recursive: true,
|
|
936
|
+
force: true
|
|
937
|
+
}).catch(() => void 0);
|
|
938
|
+
throw error;
|
|
939
|
+
}
|
|
940
|
+
try {
|
|
941
|
+
for (const file of all) if (sha256(await readFile(join(directory, file.path), "utf8")) !== file.sha256) throw new Error("FEEDBACK_BUNDLE_INTEGRITY");
|
|
942
|
+
} catch (error) {
|
|
943
|
+
await rm(directory, {
|
|
944
|
+
recursive: true,
|
|
945
|
+
force: true
|
|
946
|
+
}).catch(() => void 0);
|
|
947
|
+
throw error;
|
|
948
|
+
}
|
|
949
|
+
return {
|
|
950
|
+
id: bundleId,
|
|
951
|
+
title,
|
|
952
|
+
category: draft.category,
|
|
953
|
+
directory,
|
|
954
|
+
archivePath,
|
|
955
|
+
bytes: archive.length,
|
|
956
|
+
files: all,
|
|
957
|
+
redactions: redactor.totals(),
|
|
958
|
+
counts,
|
|
959
|
+
missing: redactedEnvironment.missing,
|
|
960
|
+
report
|
|
961
|
+
};
|
|
962
|
+
},
|
|
963
|
+
async discard(bundle) {
|
|
964
|
+
await rm(bundle.directory, {
|
|
965
|
+
recursive: true,
|
|
966
|
+
force: true
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/command-constants.ts
|
|
974
|
+
const FEEDBACK_COMMAND_OWNER_MARKER = "feedback";
|
|
975
|
+
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region src/command.ts
|
|
978
|
+
function createFeedbackCommand(deps) {
|
|
979
|
+
return {
|
|
980
|
+
path: ["feedback"],
|
|
981
|
+
summary: "feedback::command.summary",
|
|
982
|
+
texts: {
|
|
983
|
+
en: { "feedback::command.summary": feedbackLocales.en["feedback::command.summary"] ?? "" },
|
|
984
|
+
zh: { "feedback::command.summary": feedbackLocales.zh["feedback::command.summary"] ?? "" }
|
|
985
|
+
},
|
|
986
|
+
surfaces: ["tui"],
|
|
987
|
+
gate: { runState: "any" },
|
|
988
|
+
argSpecs: [{
|
|
989
|
+
name: "action",
|
|
990
|
+
kind: "value",
|
|
991
|
+
choices: [
|
|
992
|
+
"status",
|
|
993
|
+
"build",
|
|
994
|
+
"publish",
|
|
995
|
+
"discard"
|
|
996
|
+
],
|
|
997
|
+
isRequired: false
|
|
998
|
+
}, {
|
|
999
|
+
name: "payload",
|
|
1000
|
+
kind: "value",
|
|
1001
|
+
isRequired: false
|
|
1002
|
+
}],
|
|
1003
|
+
run: async (context, invocation) => {
|
|
1004
|
+
const action = invocation?.values?.get("action")?.[0];
|
|
1005
|
+
if (action !== void 0) return dispatch(action, invocation?.values?.get("payload")?.[0], deps.actions);
|
|
1006
|
+
deps.open(context.sessionId);
|
|
1007
|
+
return {
|
|
1008
|
+
kind: "panel",
|
|
1009
|
+
path: FEEDBACK_PANEL_PATH
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function feedbackCommandKey() {
|
|
1015
|
+
return commandContributionKey(FEEDBACK_COMMAND_OWNER_MARKER, ["feedback"]);
|
|
1016
|
+
}
|
|
1017
|
+
async function dispatch(action, payload, actions) {
|
|
1018
|
+
if (actions === void 0) throw new Error("feedback: no engine-side actions are wired");
|
|
1019
|
+
const parsed = payload === void 0 ? void 0 : JSON.parse(payload);
|
|
1020
|
+
if (action === "status") return {
|
|
1021
|
+
kind: "data",
|
|
1022
|
+
value: actions.status()
|
|
1023
|
+
};
|
|
1024
|
+
if (action === "build") return {
|
|
1025
|
+
kind: "data",
|
|
1026
|
+
value: await actions.build(parsed)
|
|
1027
|
+
};
|
|
1028
|
+
if (action === "publish") {
|
|
1029
|
+
const input = parsed ?? {};
|
|
1030
|
+
return {
|
|
1031
|
+
kind: "data",
|
|
1032
|
+
value: await actions.publish({
|
|
1033
|
+
bundle: input.bundle,
|
|
1034
|
+
draft: input.draft
|
|
1035
|
+
})
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
if (action === "discard") {
|
|
1039
|
+
await actions.discard(parsed);
|
|
1040
|
+
return {
|
|
1041
|
+
kind: "data",
|
|
1042
|
+
value: null
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
throw new Error(`feedback: unknown action "${action}"`);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/log/activity-sink.ts
|
|
1050
|
+
const ROUTE_TEMPLATE = /^\/[A-Za-z0-9/_-]{1,64}$/;
|
|
1051
|
+
function operationKindOf(fact) {
|
|
1052
|
+
if (fact.kind === "panel" || fact.kind === "focus") return fact.kind;
|
|
1053
|
+
return "command";
|
|
1054
|
+
}
|
|
1055
|
+
function createActivitySink(log) {
|
|
1056
|
+
return {
|
|
1057
|
+
owner: "feedback",
|
|
1058
|
+
record(fact) {
|
|
1059
|
+
if (fact.kind === "panel" && !ROUTE_TEMPLATE.test(fact.name)) {
|
|
1060
|
+
log.record({
|
|
1061
|
+
kind: "panel",
|
|
1062
|
+
name: "unknown",
|
|
1063
|
+
at: fact.at,
|
|
1064
|
+
status: fact.status
|
|
1065
|
+
});
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
log.record({
|
|
1069
|
+
kind: operationKindOf(fact),
|
|
1070
|
+
name: fact.name,
|
|
1071
|
+
at: fact.at,
|
|
1072
|
+
...fact.status === void 0 ? {} : { status: fact.status },
|
|
1073
|
+
...fact.sessionId === void 0 ? {} : { sessionId: fact.sessionId }
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/log/normalize.ts
|
|
1081
|
+
const NAME_PATTERN = /^[A-Za-z0-9_./:-]{1,64}$/;
|
|
1082
|
+
const CODE_PATTERN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
1083
|
+
const SESSION_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1084
|
+
const SECRET_LIKE = /^(?:sk-|gh[opsu]_|glpat-|npm_|AIza|AKIA|xox[baprs]-|Bearer)/;
|
|
1085
|
+
const KINDS = new Set([
|
|
1086
|
+
"command",
|
|
1087
|
+
"panel",
|
|
1088
|
+
"prompt",
|
|
1089
|
+
"tool",
|
|
1090
|
+
"settings",
|
|
1091
|
+
"model",
|
|
1092
|
+
"session",
|
|
1093
|
+
"subagent",
|
|
1094
|
+
"job",
|
|
1095
|
+
"error",
|
|
1096
|
+
"focus"
|
|
1097
|
+
]);
|
|
1098
|
+
const REASONS = new Set([
|
|
1099
|
+
"turn-end",
|
|
1100
|
+
"stream-retry",
|
|
1101
|
+
"model-fallback",
|
|
1102
|
+
"settings-changed",
|
|
1103
|
+
"session-attached",
|
|
1104
|
+
"session-detached",
|
|
1105
|
+
"job-settled",
|
|
1106
|
+
"subagent-start",
|
|
1107
|
+
"subagent-end",
|
|
1108
|
+
"install-failed",
|
|
1109
|
+
"cancelled",
|
|
1110
|
+
"failed"
|
|
1111
|
+
]);
|
|
1112
|
+
const STATUSES = new Set([
|
|
1113
|
+
"ok",
|
|
1114
|
+
"failed",
|
|
1115
|
+
"denied",
|
|
1116
|
+
"cancelled"
|
|
1117
|
+
]);
|
|
1118
|
+
function normalizeName(value) {
|
|
1119
|
+
if (SECRET_LIKE.test(value)) return "unknown";
|
|
1120
|
+
return NAME_PATTERN.test(value) ? value : "unknown";
|
|
1121
|
+
}
|
|
1122
|
+
function normalizeCode(value) {
|
|
1123
|
+
if (value === void 0 || value === "") return void 0;
|
|
1124
|
+
return CODE_PATTERN.test(value) ? value : "unknown";
|
|
1125
|
+
}
|
|
1126
|
+
function normalizeReason(value) {
|
|
1127
|
+
if (value === void 0) return void 0;
|
|
1128
|
+
return REASONS.has(value) ? value : void 0;
|
|
1129
|
+
}
|
|
1130
|
+
function normalizeStatus(value) {
|
|
1131
|
+
if (value === void 0) return void 0;
|
|
1132
|
+
return STATUSES.has(value) ? value : void 0;
|
|
1133
|
+
}
|
|
1134
|
+
function normalizeSessionId(value) {
|
|
1135
|
+
if (value === void 0 || value === "") return void 0;
|
|
1136
|
+
return SESSION_PATTERN.test(value) ? value : void 0;
|
|
1137
|
+
}
|
|
1138
|
+
function normalizeCount(value) {
|
|
1139
|
+
if (value === void 0 || !Number.isFinite(value)) return void 0;
|
|
1140
|
+
const count = Math.trunc(value);
|
|
1141
|
+
return count > 1 ? count : void 0;
|
|
1142
|
+
}
|
|
1143
|
+
function normalizeCharacters(value) {
|
|
1144
|
+
if (value === void 0 || !Number.isFinite(value)) return void 0;
|
|
1145
|
+
const characters = Math.trunc(value);
|
|
1146
|
+
return characters > 0 && characters <= 1e7 ? characters : void 0;
|
|
1147
|
+
}
|
|
1148
|
+
function normalizeDuration(value) {
|
|
1149
|
+
if (value === void 0 || !Number.isFinite(value)) return void 0;
|
|
1150
|
+
const duration = Math.round(value);
|
|
1151
|
+
return duration >= 0 && duration <= 864e5 ? duration : void 0;
|
|
1152
|
+
}
|
|
1153
|
+
function normalizeAt(value) {
|
|
1154
|
+
return Number.isFinite(value) && value > 0 ? Math.trunc(value) : Date.now();
|
|
1155
|
+
}
|
|
1156
|
+
function normalizeInput(input, seq) {
|
|
1157
|
+
if (!KINDS.has(input.kind)) return void 0;
|
|
1158
|
+
const status = normalizeStatus(input.status);
|
|
1159
|
+
const reason = normalizeReason(input.reason);
|
|
1160
|
+
const code = normalizeCode(input.code);
|
|
1161
|
+
const count = normalizeCount(input.count);
|
|
1162
|
+
const characters = normalizeCharacters(input.characters);
|
|
1163
|
+
const durationMs = normalizeDuration(input.durationMs);
|
|
1164
|
+
const sessionId = normalizeSessionId(input.sessionId);
|
|
1165
|
+
return {
|
|
1166
|
+
seq,
|
|
1167
|
+
at: normalizeAt(input.at),
|
|
1168
|
+
kind: input.kind,
|
|
1169
|
+
name: normalizeName(input.name),
|
|
1170
|
+
...status === void 0 ? {} : { status },
|
|
1171
|
+
...reason === void 0 ? {} : { reason },
|
|
1172
|
+
...code === void 0 ? {} : { code },
|
|
1173
|
+
...count === void 0 ? {} : { count },
|
|
1174
|
+
...characters === void 0 ? {} : { characters },
|
|
1175
|
+
...durationMs === void 0 ? {} : { durationMs },
|
|
1176
|
+
...sessionId === void 0 ? {} : { sessionId }
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/log/operation-log.ts
|
|
1182
|
+
function createOperationLog(options) {
|
|
1183
|
+
let capacity = Math.max(1, Math.trunc(options.capacity));
|
|
1184
|
+
const mergeWindowMs = options.mergeWindowMs ?? 1e3;
|
|
1185
|
+
const entries = [];
|
|
1186
|
+
let seq = 0;
|
|
1187
|
+
let dropped = 0;
|
|
1188
|
+
let skipped = 0;
|
|
1189
|
+
const mergeable = (entry, input) => {
|
|
1190
|
+
return entry.kind === input.kind && entry.name === input.name && entry.sessionId === input.sessionId && entry.status === input.status && entry.code === input.code && entry.reason === input.reason;
|
|
1191
|
+
};
|
|
1192
|
+
return {
|
|
1193
|
+
record(input) {
|
|
1194
|
+
seq += 1;
|
|
1195
|
+
const next = normalizeInput(input, seq);
|
|
1196
|
+
if (next === void 0) {
|
|
1197
|
+
skipped += 1;
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
const at = options.now === void 0 ? input.at : options.now();
|
|
1201
|
+
const candidate = {
|
|
1202
|
+
...next,
|
|
1203
|
+
at: Number.isFinite(at) && at > 0 ? Math.trunc(at) : next.at
|
|
1204
|
+
};
|
|
1205
|
+
const last = entries[entries.length - 1];
|
|
1206
|
+
if (last !== void 0 && mergeWindowMs > 0 && candidate.at >= last.at && candidate.at - last.at <= mergeWindowMs && mergeable(last, candidate)) {
|
|
1207
|
+
const lastDuration = last.durationMs ?? 0;
|
|
1208
|
+
const nextDuration = candidate.durationMs ?? 0;
|
|
1209
|
+
const merged = {
|
|
1210
|
+
...last,
|
|
1211
|
+
at: Math.max(last.at, candidate.at),
|
|
1212
|
+
count: (last.count ?? 1) + 1,
|
|
1213
|
+
...last.durationMs === void 0 && candidate.durationMs === void 0 ? {} : { durationMs: Math.max(lastDuration, nextDuration) }
|
|
1214
|
+
};
|
|
1215
|
+
entries[entries.length - 1] = merged;
|
|
1216
|
+
options.onEntry?.(merged);
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
entries.push(candidate);
|
|
1220
|
+
options.onEntry?.(candidate);
|
|
1221
|
+
if (entries.length > capacity) {
|
|
1222
|
+
entries.shift();
|
|
1223
|
+
dropped += 1;
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
setCapacity(next) {
|
|
1227
|
+
capacity = Math.max(1, Math.trunc(next));
|
|
1228
|
+
while (entries.length > capacity) {
|
|
1229
|
+
entries.shift();
|
|
1230
|
+
dropped += 1;
|
|
1231
|
+
}
|
|
1232
|
+
},
|
|
1233
|
+
snapshot() {
|
|
1234
|
+
return {
|
|
1235
|
+
entries: entries.map((entry) => ({ ...entry })),
|
|
1236
|
+
dropped,
|
|
1237
|
+
skipped,
|
|
1238
|
+
capacity
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
//#endregion
|
|
1245
|
+
//#region src/log/observe.ts
|
|
1246
|
+
function asRecord(value) {
|
|
1247
|
+
return typeof value === "object" && value !== null ? value : void 0;
|
|
1248
|
+
}
|
|
1249
|
+
function textOf$1(value) {
|
|
1250
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
1251
|
+
}
|
|
1252
|
+
function messageCharacters(message) {
|
|
1253
|
+
const record = asRecord(message);
|
|
1254
|
+
if (record === void 0) return 0;
|
|
1255
|
+
const content = record["content"];
|
|
1256
|
+
if (typeof content === "string") return content.length;
|
|
1257
|
+
if (!Array.isArray(content)) return 0;
|
|
1258
|
+
let total = 0;
|
|
1259
|
+
for (const part of content) {
|
|
1260
|
+
const block = asRecord(part);
|
|
1261
|
+
if (block === void 0 || block["type"] !== "text") continue;
|
|
1262
|
+
const text = block["text"];
|
|
1263
|
+
if (typeof text === "string") total += text.length;
|
|
1264
|
+
}
|
|
1265
|
+
return total;
|
|
1266
|
+
}
|
|
1267
|
+
function registerObservers(ctx, deps) {
|
|
1268
|
+
const toolStarts = /* @__PURE__ */ new Map();
|
|
1269
|
+
const contribute = (timing, key, handle) => {
|
|
1270
|
+
ctx.contribute(`hook:${timing}`, `feedback::${key}`, {
|
|
1271
|
+
name: `feedback::${key}`,
|
|
1272
|
+
timing,
|
|
1273
|
+
kind: "observer",
|
|
1274
|
+
handle: (input) => {
|
|
1275
|
+
try {
|
|
1276
|
+
handle(input);
|
|
1277
|
+
} catch {
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
};
|
|
1283
|
+
ctx.effect(() => {
|
|
1284
|
+
contribute(TIMINGS.userMessage, "user-message", (input) => {
|
|
1285
|
+
const payload = asRecord(input);
|
|
1286
|
+
if (payload === void 0) return;
|
|
1287
|
+
const characters = messageCharacters(payload["message"]);
|
|
1288
|
+
deps.log.record({
|
|
1289
|
+
kind: "prompt",
|
|
1290
|
+
name: "prompt",
|
|
1291
|
+
at: deps.now(),
|
|
1292
|
+
...characters > 0 ? { characters } : {},
|
|
1293
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
contribute(TIMINGS.turnStart, "turn-start", (input) => {
|
|
1297
|
+
const payload = asRecord(input);
|
|
1298
|
+
if (payload === void 0) return;
|
|
1299
|
+
deps.log.record({
|
|
1300
|
+
kind: "session",
|
|
1301
|
+
name: "turn.start",
|
|
1302
|
+
at: deps.now(),
|
|
1303
|
+
status: "ok",
|
|
1304
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1305
|
+
});
|
|
1306
|
+
});
|
|
1307
|
+
contribute(TIMINGS.turnEnd, "turn-end", (input) => {
|
|
1308
|
+
const payload = asRecord(input);
|
|
1309
|
+
if (payload === void 0) return;
|
|
1310
|
+
deps.log.record({
|
|
1311
|
+
kind: "session",
|
|
1312
|
+
name: "turn.end",
|
|
1313
|
+
at: deps.now(),
|
|
1314
|
+
status: "ok",
|
|
1315
|
+
reason: "turn-end",
|
|
1316
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1317
|
+
});
|
|
1318
|
+
});
|
|
1319
|
+
contribute(TIMINGS.toolCallStart, "tool-start", (input) => {
|
|
1320
|
+
const payload = asRecord(input);
|
|
1321
|
+
if (payload === void 0) return;
|
|
1322
|
+
const call = asRecord(payload["call"]);
|
|
1323
|
+
const id = call === void 0 ? void 0 : textOf$1(call["id"]);
|
|
1324
|
+
if (id !== void 0) toolStarts.set(id, deps.now());
|
|
1325
|
+
});
|
|
1326
|
+
contribute(TIMINGS.toolCallEnd, "tool-end", (input) => {
|
|
1327
|
+
const payload = asRecord(input);
|
|
1328
|
+
if (payload === void 0) return;
|
|
1329
|
+
const call = asRecord(payload["call"]);
|
|
1330
|
+
const result = asRecord(payload["result"]);
|
|
1331
|
+
if (call === void 0) return;
|
|
1332
|
+
const id = textOf$1(call["id"]);
|
|
1333
|
+
const started = id === void 0 ? void 0 : toolStarts.get(id);
|
|
1334
|
+
if (id !== void 0) toolStarts.delete(id);
|
|
1335
|
+
const isError = result !== void 0 && result["isError"] === true;
|
|
1336
|
+
const errorKind = result === void 0 ? void 0 : textOf$1(result["errorKind"]);
|
|
1337
|
+
deps.log.record({
|
|
1338
|
+
kind: "tool",
|
|
1339
|
+
name: textOf$1(call["name"]) ?? "unknown",
|
|
1340
|
+
at: deps.now(),
|
|
1341
|
+
status: isError ? "failed" : "ok",
|
|
1342
|
+
...errorKind === void 0 ? {} : { code: errorKind },
|
|
1343
|
+
...started === void 0 ? {} : { durationMs: Math.max(0, deps.now() - started) },
|
|
1344
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1345
|
+
});
|
|
1346
|
+
});
|
|
1347
|
+
contribute(TIMINGS.settingsChange, "settings-change", (input) => {
|
|
1348
|
+
const payload = asRecord(input);
|
|
1349
|
+
const key = payload === void 0 ? void 0 : textOf$1(payload["key"]);
|
|
1350
|
+
if (key === void 0) return;
|
|
1351
|
+
deps.log.record({
|
|
1352
|
+
kind: "settings",
|
|
1353
|
+
name: key,
|
|
1354
|
+
at: deps.now(),
|
|
1355
|
+
status: "ok",
|
|
1356
|
+
reason: "settings-changed"
|
|
1357
|
+
});
|
|
1358
|
+
});
|
|
1359
|
+
contribute(TIMINGS.modelFallback, "model-fallback", (input) => {
|
|
1360
|
+
const payload = asRecord(input);
|
|
1361
|
+
if (payload === void 0) return;
|
|
1362
|
+
deps.log.record({
|
|
1363
|
+
kind: "model",
|
|
1364
|
+
name: textOf$1(payload["model"]) ?? "unknown",
|
|
1365
|
+
at: deps.now(),
|
|
1366
|
+
reason: "model-fallback",
|
|
1367
|
+
code: textOf$1(payload["errorKind"]),
|
|
1368
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
contribute(TIMINGS.streamRetry, "stream-retry", (input) => {
|
|
1372
|
+
const payload = asRecord(input);
|
|
1373
|
+
if (payload === void 0) return;
|
|
1374
|
+
const kind = textOf$1(payload["kind"]);
|
|
1375
|
+
const status = kind === "failed" ? "failed" : kind === "resolved" ? "ok" : void 0;
|
|
1376
|
+
deps.log.record({
|
|
1377
|
+
kind: "model",
|
|
1378
|
+
name: "model.retry",
|
|
1379
|
+
at: deps.now(),
|
|
1380
|
+
reason: "stream-retry",
|
|
1381
|
+
...status === void 0 ? {} : { status },
|
|
1382
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1383
|
+
});
|
|
1384
|
+
});
|
|
1385
|
+
contribute(TIMINGS.agentSessionAttached, "session-attached", (input) => {
|
|
1386
|
+
const payload = asRecord(input);
|
|
1387
|
+
if (payload === void 0) return;
|
|
1388
|
+
deps.log.record({
|
|
1389
|
+
kind: "session",
|
|
1390
|
+
name: "session.attached",
|
|
1391
|
+
at: deps.now(),
|
|
1392
|
+
status: "ok",
|
|
1393
|
+
reason: "session-attached",
|
|
1394
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1395
|
+
});
|
|
1396
|
+
});
|
|
1397
|
+
contribute(TIMINGS.agentSessionDetached, "session-detached", (input) => {
|
|
1398
|
+
const payload = asRecord(input);
|
|
1399
|
+
if (payload === void 0) return;
|
|
1400
|
+
deps.log.record({
|
|
1401
|
+
kind: "session",
|
|
1402
|
+
name: "session.detached",
|
|
1403
|
+
at: deps.now(),
|
|
1404
|
+
status: "ok",
|
|
1405
|
+
reason: "session-detached",
|
|
1406
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1407
|
+
});
|
|
1408
|
+
});
|
|
1409
|
+
contribute(TIMINGS.subagentStart, "subagent-start", (input) => {
|
|
1410
|
+
const payload = asRecord(input);
|
|
1411
|
+
if (payload === void 0) return;
|
|
1412
|
+
deps.log.record({
|
|
1413
|
+
kind: "subagent",
|
|
1414
|
+
name: "subagent.start",
|
|
1415
|
+
at: deps.now(),
|
|
1416
|
+
status: "ok",
|
|
1417
|
+
reason: "subagent-start",
|
|
1418
|
+
sessionId: textOf$1(payload["childSessionId"])
|
|
1419
|
+
});
|
|
1420
|
+
});
|
|
1421
|
+
contribute(TIMINGS.subagentEnd, "subagent-end", (input) => {
|
|
1422
|
+
const payload = asRecord(input);
|
|
1423
|
+
if (payload === void 0) return;
|
|
1424
|
+
deps.log.record({
|
|
1425
|
+
kind: "subagent",
|
|
1426
|
+
name: "subagent.end",
|
|
1427
|
+
at: deps.now(),
|
|
1428
|
+
status: "ok",
|
|
1429
|
+
reason: "subagent-end",
|
|
1430
|
+
sessionId: textOf$1(payload["childSessionId"])
|
|
1431
|
+
});
|
|
1432
|
+
});
|
|
1433
|
+
contribute(TIMINGS.jobSettled, "job-settled", () => {
|
|
1434
|
+
deps.log.record({
|
|
1435
|
+
kind: "job",
|
|
1436
|
+
name: "job.settled",
|
|
1437
|
+
at: deps.now(),
|
|
1438
|
+
status: "ok",
|
|
1439
|
+
reason: "job-settled"
|
|
1440
|
+
});
|
|
1441
|
+
});
|
|
1442
|
+
contribute(TIMINGS.runtimeDiagnostic, "runtime-diagnostic", (input) => {
|
|
1443
|
+
const payload = asRecord(input);
|
|
1444
|
+
if (payload === void 0) return;
|
|
1445
|
+
const severity = textOf$1(payload["severity"]);
|
|
1446
|
+
if (severity !== "warning" && severity !== "error") return;
|
|
1447
|
+
const code = textOf$1(payload["code"]);
|
|
1448
|
+
if (code === void 0) return;
|
|
1449
|
+
deps.log.record({
|
|
1450
|
+
kind: "error",
|
|
1451
|
+
name: code,
|
|
1452
|
+
at: deps.now(),
|
|
1453
|
+
status: severity === "error" ? "failed" : "ok",
|
|
1454
|
+
code,
|
|
1455
|
+
sessionId: textOf$1(payload["sessionId"])
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
contribute(TIMINGS.installNotify, "install-notify", (input) => {
|
|
1459
|
+
const payload = asRecord(input);
|
|
1460
|
+
if (payload === void 0) return;
|
|
1461
|
+
if (textOf$1(payload["level"]) !== "error") return;
|
|
1462
|
+
deps.log.record({
|
|
1463
|
+
kind: "error",
|
|
1464
|
+
name: "install.notify",
|
|
1465
|
+
at: deps.now(),
|
|
1466
|
+
status: "failed",
|
|
1467
|
+
reason: "install-failed"
|
|
1468
|
+
});
|
|
1469
|
+
});
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
//#endregion
|
|
1474
|
+
//#region src/publish/outbox.ts
|
|
1475
|
+
async function copyDirectory(source, target) {
|
|
1476
|
+
await mkdir(target, { recursive: true });
|
|
1477
|
+
for (const entry of await readdir(source)) {
|
|
1478
|
+
const from = join(source, entry);
|
|
1479
|
+
const to = join(target, entry);
|
|
1480
|
+
if ((await stat(from)).isDirectory()) {
|
|
1481
|
+
await copyDirectory(from, to);
|
|
1482
|
+
continue;
|
|
1483
|
+
}
|
|
1484
|
+
await copyFile(from, to);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
const CANCELLED = {
|
|
1488
|
+
kind: "failed",
|
|
1489
|
+
code: "FEEDBACK_PUBLISH_CANCELLED",
|
|
1490
|
+
message: "publishing was cancelled"
|
|
1491
|
+
};
|
|
1492
|
+
function createOutboxPublisher(options) {
|
|
1493
|
+
return {
|
|
1494
|
+
id: "outbox",
|
|
1495
|
+
async publish(bundle, _draft, signal) {
|
|
1496
|
+
const root = join(options.home, FEEDBACK_HOME_DIRECTORY, OUTBOX_DIRECTORY);
|
|
1497
|
+
const target = join(root, bundle.id);
|
|
1498
|
+
const isCancelled = () => signal?.aborted === true;
|
|
1499
|
+
if (isCancelled()) return CANCELLED;
|
|
1500
|
+
try {
|
|
1501
|
+
await mkdir(root, { recursive: true });
|
|
1502
|
+
await mkdir(target);
|
|
1503
|
+
} catch (error) {
|
|
1504
|
+
const code = error.code;
|
|
1505
|
+
if (code === "EEXIST") return {
|
|
1506
|
+
kind: "failed",
|
|
1507
|
+
code: "FEEDBACK_OUTBOX_EXISTS",
|
|
1508
|
+
message: `feedback bundle "${bundle.id}" already exists`
|
|
1509
|
+
};
|
|
1510
|
+
return {
|
|
1511
|
+
kind: "failed",
|
|
1512
|
+
code: code === "ENOSPC" ? "FEEDBACK_DISK_FULL" : "FEEDBACK_OUTBOX_UNWRITABLE",
|
|
1513
|
+
message: `cannot create the outbox directory: ${String(code ?? error)}`
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
if (isCancelled()) {
|
|
1517
|
+
await rm(target, {
|
|
1518
|
+
recursive: true,
|
|
1519
|
+
force: true
|
|
1520
|
+
});
|
|
1521
|
+
return CANCELLED;
|
|
1522
|
+
}
|
|
1523
|
+
try {
|
|
1524
|
+
await rename(bundle.directory, target);
|
|
1525
|
+
} catch {
|
|
1526
|
+
try {
|
|
1527
|
+
await copyDirectory(bundle.directory, target);
|
|
1528
|
+
} catch (error) {
|
|
1529
|
+
const code = error.code;
|
|
1530
|
+
await rm(target, {
|
|
1531
|
+
recursive: true,
|
|
1532
|
+
force: true
|
|
1533
|
+
}).catch(() => void 0);
|
|
1534
|
+
return {
|
|
1535
|
+
kind: "failed",
|
|
1536
|
+
code: code === "ENOSPC" ? "FEEDBACK_DISK_FULL" : "FEEDBACK_OUTBOX_UNWRITABLE",
|
|
1537
|
+
message: `cannot move the bundle into the outbox: ${String(code ?? error)}`
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
await rm(bundle.directory, {
|
|
1541
|
+
recursive: true,
|
|
1542
|
+
force: true
|
|
1543
|
+
}).catch(() => void 0);
|
|
1544
|
+
}
|
|
1545
|
+
return {
|
|
1546
|
+
kind: "stored",
|
|
1547
|
+
path: target
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
//#endregion
|
|
1554
|
+
//#region src/publish/service.ts
|
|
1555
|
+
const SERVICE_ERROR_CODES = {
|
|
1556
|
+
notConfigured: "FEEDBACK_SERVICE_NOT_CONFIGURED",
|
|
1557
|
+
urlInvalid: "FEEDBACK_SERVICE_URL_INVALID",
|
|
1558
|
+
loginRequired: "FEEDBACK_SERVICE_LOGIN_REQUIRED",
|
|
1559
|
+
unauthorized: "FEEDBACK_SERVICE_UNAUTHORIZED",
|
|
1560
|
+
unknown: "FEEDBACK_SERVICE_UNKNOWN",
|
|
1561
|
+
archiveUnreadable: "FEEDBACK_ARCHIVE_UNREADABLE",
|
|
1562
|
+
cancelled: "FEEDBACK_PUBLISH_CANCELLED"
|
|
1563
|
+
};
|
|
1564
|
+
const SERVICE_TIMEOUT_MS = 6e4;
|
|
1565
|
+
const LOOPBACK_HOSTS = new Set([
|
|
1566
|
+
"localhost",
|
|
1567
|
+
"127.0.0.1",
|
|
1568
|
+
"[::1]",
|
|
1569
|
+
"::1"
|
|
1570
|
+
]);
|
|
1571
|
+
function checkServiceUrl(raw, allowedHosts = [], allowHttp = false) {
|
|
1572
|
+
const trimmed = raw.trim();
|
|
1573
|
+
if (trimmed === "") return {
|
|
1574
|
+
ok: false,
|
|
1575
|
+
code: SERVICE_ERROR_CODES.notConfigured
|
|
1576
|
+
};
|
|
1577
|
+
let url;
|
|
1578
|
+
try {
|
|
1579
|
+
url = new URL(trimmed);
|
|
1580
|
+
} catch {
|
|
1581
|
+
return {
|
|
1582
|
+
ok: false,
|
|
1583
|
+
code: SERVICE_ERROR_CODES.urlInvalid
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
const loopback = LOOPBACK_HOSTS.has(url.hostname);
|
|
1587
|
+
const secure = url.protocol === "https:" || url.protocol === "http:" && loopback && allowHttp;
|
|
1588
|
+
const rootPath = url.pathname === "" || url.pathname === "/";
|
|
1589
|
+
if (!secure || !rootPath || url.username !== "" || url.password !== "" || url.search !== "" || url.hash !== "") return {
|
|
1590
|
+
ok: false,
|
|
1591
|
+
code: SERVICE_ERROR_CODES.urlInvalid
|
|
1592
|
+
};
|
|
1593
|
+
if (allowedHosts.length > 0 && !allowedHosts.includes(url.hostname.toLowerCase())) return {
|
|
1594
|
+
ok: false,
|
|
1595
|
+
code: SERVICE_ERROR_CODES.urlInvalid
|
|
1596
|
+
};
|
|
1597
|
+
return {
|
|
1598
|
+
ok: true,
|
|
1599
|
+
url: url.origin
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
function failed(code, message) {
|
|
1603
|
+
return {
|
|
1604
|
+
kind: "failed",
|
|
1605
|
+
code,
|
|
1606
|
+
message
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function unknown(message, code = SERVICE_ERROR_CODES.unknown) {
|
|
1610
|
+
return {
|
|
1611
|
+
kind: "unknown",
|
|
1612
|
+
code,
|
|
1613
|
+
message
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
function metaOf(bundle, bytes) {
|
|
1617
|
+
return {
|
|
1618
|
+
protocol: FEEDBACK_PROTOCOL_VERSION,
|
|
1619
|
+
bundleId: bundle.id,
|
|
1620
|
+
title: normalizeTitle(bundle.title),
|
|
1621
|
+
category: bundle.category,
|
|
1622
|
+
bytes,
|
|
1623
|
+
report: bundle.report
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
async function readBody(response) {
|
|
1627
|
+
try {
|
|
1628
|
+
return await response.json();
|
|
1629
|
+
} catch {
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
function createServicePublisher(options) {
|
|
1634
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
1635
|
+
const readArchive = options.readArchive ?? ((path) => readFile(path));
|
|
1636
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
1637
|
+
return { async publish(bundle, _draft, signal) {
|
|
1638
|
+
if (signal?.aborted === true) return failed(SERVICE_ERROR_CODES.cancelled, "publish cancelled before sending");
|
|
1639
|
+
const target = checkServiceUrl(options.serviceUrl(), options.allowedHosts?.() ?? [], options.allowHttp?.() ?? false);
|
|
1640
|
+
if (!target.ok) return failed(target.code, "the feedback service url is not usable");
|
|
1641
|
+
const session = await options.session();
|
|
1642
|
+
if (session === void 0 || session === "") return failed(SERVICE_ERROR_CODES.loginRequired, "sign in to otto before submitting feedback");
|
|
1643
|
+
let bytes;
|
|
1644
|
+
try {
|
|
1645
|
+
bytes = await readArchive(bundle.archivePath);
|
|
1646
|
+
} catch {
|
|
1647
|
+
return failed(SERVICE_ERROR_CODES.archiveUnreadable, "the feedback archive cannot be read");
|
|
1648
|
+
}
|
|
1649
|
+
if (signal !== void 0 && signal.aborted) return failed(SERVICE_ERROR_CODES.cancelled, "publish cancelled before sending");
|
|
1650
|
+
const form = new FormData();
|
|
1651
|
+
form.append(META_PART_NAME, JSON.stringify(metaOf(bundle, bytes.byteLength)));
|
|
1652
|
+
form.append(BUNDLE_PART_NAME, new Blob([bytes], { type: "application/zip" }), `${bundle.id}.zip`);
|
|
1653
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
1654
|
+
const combined = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
|
|
1655
|
+
let response;
|
|
1656
|
+
try {
|
|
1657
|
+
response = await fetchImpl(`${target.url}${FEEDBACK_SERVICE_PATH}`, {
|
|
1658
|
+
method: "POST",
|
|
1659
|
+
headers: {
|
|
1660
|
+
authorization: `Bearer ${session}`,
|
|
1661
|
+
[FEEDBACK_PROTOCOL_HEADER]: String(FEEDBACK_PROTOCOL_VERSION)
|
|
1662
|
+
},
|
|
1663
|
+
body: form,
|
|
1664
|
+
redirect: "manual",
|
|
1665
|
+
signal: combined
|
|
1666
|
+
});
|
|
1667
|
+
} catch {
|
|
1668
|
+
return unknown("the feedback service did not answer; the issue may or may not exist");
|
|
1669
|
+
}
|
|
1670
|
+
const result = parseSubmissionResponse({
|
|
1671
|
+
status: response.status,
|
|
1672
|
+
body: await readBody(response)
|
|
1673
|
+
});
|
|
1674
|
+
if (result.kind === "issue") return {
|
|
1675
|
+
kind: "issue",
|
|
1676
|
+
url: result.issueUrl,
|
|
1677
|
+
...result.iid === void 0 ? {} : { iid: result.iid }
|
|
1678
|
+
};
|
|
1679
|
+
if (result.kind === "failed" && result.code === SERVICE_ERROR_CODES.unauthorized) options.invalidateSession?.();
|
|
1680
|
+
return result.kind === "failed" ? failed(result.code, result.message) : unknown(result.message, result.code);
|
|
1681
|
+
} };
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
//#endregion
|
|
1685
|
+
//#region src/settings.ts
|
|
1686
|
+
function numberOf(raw) {
|
|
1687
|
+
const value = typeof raw === "string" ? Number(raw.trim()) : raw;
|
|
1688
|
+
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
1689
|
+
}
|
|
1690
|
+
function normalizePublisher(raw) {
|
|
1691
|
+
if (raw === "outbox") return PUBLISHER_OUTBOX;
|
|
1692
|
+
if (raw === "service" || raw === "coding") return PUBLISHER_SERVICE;
|
|
1693
|
+
}
|
|
1694
|
+
const SPECS = {
|
|
1695
|
+
operationLogSize: {
|
|
1696
|
+
key: SETTING_KEYS.operationLogSize,
|
|
1697
|
+
default: 100,
|
|
1698
|
+
env: SETTING_ENV.operationLogSize,
|
|
1699
|
+
ownership: "user-only",
|
|
1700
|
+
parse: (raw) => {
|
|
1701
|
+
const value = numberOf(raw);
|
|
1702
|
+
if (value === void 0) return void 0;
|
|
1703
|
+
if (value < 20 || value > 500) return void 0;
|
|
1704
|
+
return value;
|
|
1705
|
+
}
|
|
1706
|
+
},
|
|
1707
|
+
includeDiagnostics: {
|
|
1708
|
+
key: SETTING_KEYS.includeDiagnostics,
|
|
1709
|
+
default: true,
|
|
1710
|
+
ownership: "user-only",
|
|
1711
|
+
parse: (raw) => typeof raw === "boolean" ? raw : void 0
|
|
1712
|
+
},
|
|
1713
|
+
includeWorkspaceName: {
|
|
1714
|
+
key: SETTING_KEYS.includeWorkspaceName,
|
|
1715
|
+
default: false,
|
|
1716
|
+
ownership: "user-only",
|
|
1717
|
+
parse: (raw) => typeof raw === "boolean" ? raw : void 0
|
|
1718
|
+
},
|
|
1719
|
+
maxBundleBytes: {
|
|
1720
|
+
key: SETTING_KEYS.maxBundleBytes,
|
|
1721
|
+
default: MAX_BUNDLE_BYTES,
|
|
1722
|
+
ownership: "user-only",
|
|
1723
|
+
parse: (raw) => {
|
|
1724
|
+
const value = numberOf(raw);
|
|
1725
|
+
if (value === void 0) return void 0;
|
|
1726
|
+
return value >= 1024 && value <= 64 * 1024 * 1024 ? value : void 0;
|
|
1727
|
+
}
|
|
1728
|
+
},
|
|
1729
|
+
serviceUrl: {
|
|
1730
|
+
key: SETTING_KEYS.serviceUrl,
|
|
1731
|
+
default: "",
|
|
1732
|
+
env: SETTING_ENV.serviceUrl,
|
|
1733
|
+
ownership: "user-only",
|
|
1734
|
+
parse: (raw) => typeof raw === "string" ? raw.trim() : void 0
|
|
1735
|
+
},
|
|
1736
|
+
serviceAuthProvider: {
|
|
1737
|
+
key: SETTING_KEYS.serviceAuthProvider,
|
|
1738
|
+
default: DEFAULT_AUTH_PROVIDER,
|
|
1739
|
+
ownership: "user-only",
|
|
1740
|
+
parse: (raw) => typeof raw === "string" && raw.trim() !== "" ? raw.trim() : void 0
|
|
1741
|
+
},
|
|
1742
|
+
publisher: {
|
|
1743
|
+
key: SETTING_KEYS.publisher,
|
|
1744
|
+
default: PUBLISHER_SERVICE,
|
|
1745
|
+
ownership: "user-only",
|
|
1746
|
+
parse: (raw) => normalizePublisher(raw)
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
function registerFeedbackSettings(settings) {
|
|
1750
|
+
const handles = [];
|
|
1751
|
+
const register = (spec) => {
|
|
1752
|
+
const field = settings.registerField(spec, "feedback");
|
|
1753
|
+
handles.push(field);
|
|
1754
|
+
return field;
|
|
1755
|
+
};
|
|
1756
|
+
const operationLogSize = register(SPECS.operationLogSize);
|
|
1757
|
+
const includeDiagnostics = register(SPECS.includeDiagnostics);
|
|
1758
|
+
const includeWorkspaceName = register(SPECS.includeWorkspaceName);
|
|
1759
|
+
const maxBundleBytes = register(SPECS.maxBundleBytes);
|
|
1760
|
+
const serviceUrl = register(SPECS.serviceUrl);
|
|
1761
|
+
const serviceAuthProvider = register(SPECS.serviceAuthProvider);
|
|
1762
|
+
const publisher = register(SPECS.publisher);
|
|
1763
|
+
return {
|
|
1764
|
+
operationLogSize: () => operationLogSize.get(),
|
|
1765
|
+
includeDiagnostics: () => includeDiagnostics.get(),
|
|
1766
|
+
includeWorkspaceName: () => includeWorkspaceName.get(),
|
|
1767
|
+
maxBundleBytes: () => maxBundleBytes.get(),
|
|
1768
|
+
publisher: () => publisher.get(),
|
|
1769
|
+
serviceUrl: () => serviceUrl.get(),
|
|
1770
|
+
serviceAuthProvider: () => serviceAuthProvider.get(),
|
|
1771
|
+
dispose: () => {
|
|
1772
|
+
for (const handle of handles) handle.dispose();
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
//#endregion
|
|
1778
|
+
//#region src/ui/settings-page.ts
|
|
1779
|
+
const FEEDBACK_SETTINGS_PAGE_ID = "feedback.settings";
|
|
1780
|
+
function feedbackSettingsPage(spaceId) {
|
|
1781
|
+
return {
|
|
1782
|
+
owner: FEEDBACK_PLUGIN_ID,
|
|
1783
|
+
spaceId,
|
|
1784
|
+
id: FEEDBACK_SETTINGS_PAGE_ID,
|
|
1785
|
+
title: {
|
|
1786
|
+
key: "feedback.settings.title",
|
|
1787
|
+
fallback: "Feedback"
|
|
1788
|
+
},
|
|
1789
|
+
order: 35,
|
|
1790
|
+
schema: { sections: [{
|
|
1791
|
+
id: "channel",
|
|
1792
|
+
title: {
|
|
1793
|
+
key: "feedback.settings.channel",
|
|
1794
|
+
fallback: "Channel"
|
|
1795
|
+
},
|
|
1796
|
+
fields: [{
|
|
1797
|
+
kind: "select",
|
|
1798
|
+
key: "publisher",
|
|
1799
|
+
label: {
|
|
1800
|
+
key: "feedback.settings.publisher",
|
|
1801
|
+
fallback: "Submit channel"
|
|
1802
|
+
},
|
|
1803
|
+
description: {
|
|
1804
|
+
key: "feedback.settings.publisher.description",
|
|
1805
|
+
fallback: "Save locally keeps the bundle in the outbox; Feedback service submits it with your otto login and opens an issue."
|
|
1806
|
+
},
|
|
1807
|
+
options: [{
|
|
1808
|
+
value: "outbox",
|
|
1809
|
+
label: {
|
|
1810
|
+
key: "feedback.settings.publisher.outbox",
|
|
1811
|
+
fallback: "Save locally"
|
|
1812
|
+
}
|
|
1813
|
+
}, {
|
|
1814
|
+
value: PUBLISHER_SERVICE,
|
|
1815
|
+
label: {
|
|
1816
|
+
key: "feedback.settings.publisher.service",
|
|
1817
|
+
fallback: "Feedback service"
|
|
1818
|
+
}
|
|
1819
|
+
}],
|
|
1820
|
+
default: PUBLISHER_SERVICE
|
|
1821
|
+
}]
|
|
1822
|
+
}, {
|
|
1823
|
+
id: "service",
|
|
1824
|
+
title: {
|
|
1825
|
+
key: "feedback.settings.service",
|
|
1826
|
+
fallback: "Feedback service"
|
|
1827
|
+
},
|
|
1828
|
+
fields: [{
|
|
1829
|
+
kind: "text",
|
|
1830
|
+
key: "service.url",
|
|
1831
|
+
label: {
|
|
1832
|
+
key: "feedback.settings.serviceUrl",
|
|
1833
|
+
fallback: "Service URL"
|
|
1834
|
+
},
|
|
1835
|
+
description: {
|
|
1836
|
+
key: "feedback.settings.serviceUrl.description",
|
|
1837
|
+
fallback: "HTTPS address of the feedback service, for example https://feedback.example.com. Your otto login is sent to this service, so only use a service you trust."
|
|
1838
|
+
},
|
|
1839
|
+
default: ""
|
|
1840
|
+
}, {
|
|
1841
|
+
kind: "text",
|
|
1842
|
+
key: "service.authProvider",
|
|
1843
|
+
label: {
|
|
1844
|
+
key: "feedback.settings.authProvider",
|
|
1845
|
+
fallback: "Login provider"
|
|
1846
|
+
},
|
|
1847
|
+
description: {
|
|
1848
|
+
key: "feedback.settings.authProvider.description",
|
|
1849
|
+
fallback: "Provider whose login is forwarded to the service; uipaas by default."
|
|
1850
|
+
},
|
|
1851
|
+
default: DEFAULT_AUTH_PROVIDER
|
|
1852
|
+
}]
|
|
1853
|
+
}] }
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region src/index.ts
|
|
1859
|
+
const DEFAULT_SETTINGS = {
|
|
1860
|
+
operationLogSize: () => 100,
|
|
1861
|
+
includeDiagnostics: () => true,
|
|
1862
|
+
includeWorkspaceName: () => false,
|
|
1863
|
+
maxBundleBytes: () => MAX_BUNDLE_BYTES,
|
|
1864
|
+
publisher: () => PUBLISHER_SERVICE,
|
|
1865
|
+
serviceUrl: () => "",
|
|
1866
|
+
serviceAuthProvider: () => DEFAULT_AUTH_PROVIDER,
|
|
1867
|
+
dispose: () => void 0
|
|
1868
|
+
};
|
|
1869
|
+
function createFeedbackComponent(defaults = {}) {
|
|
1870
|
+
const Feedback = (ctx, config) => {
|
|
1871
|
+
const options = {
|
|
1872
|
+
...defaults,
|
|
1873
|
+
...config ?? {}
|
|
1874
|
+
};
|
|
1875
|
+
const settingsAccessor = ctx.maybe(SLOTS.settings);
|
|
1876
|
+
const envAccessor = ctx.maybe(SLOTS.env);
|
|
1877
|
+
const sessionsAccessor = ctx.maybe(SLOTS.sessions);
|
|
1878
|
+
const hostInfoAccessor = ctx.maybe(SLOTS.hostInfo);
|
|
1879
|
+
const spaceAccessor = ctx.maybe(SLOTS.spaceCatalog);
|
|
1880
|
+
const hooksAccessor = ctx.maybe(SLOTS.hooks);
|
|
1881
|
+
const reportWarning = (code, error) => {
|
|
1882
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1883
|
+
hooksAccessor()?.emitAndWait(TIMINGS.runtimeDiagnostic, {
|
|
1884
|
+
source: "plugins",
|
|
1885
|
+
severity: "warning",
|
|
1886
|
+
code,
|
|
1887
|
+
message: `feedback: ${message}`
|
|
1888
|
+
}).catch(() => {});
|
|
1889
|
+
};
|
|
1890
|
+
const authAccessor = ctx.maybe(SLOTS.authStore);
|
|
1891
|
+
const resolverAccessor = ctx.maybe(SLOTS.credentialResolver);
|
|
1892
|
+
const home = options.home ?? resolveOttoHome(envAccessor(), homedir());
|
|
1893
|
+
const cwd = process.cwd();
|
|
1894
|
+
let sessionId;
|
|
1895
|
+
let settings = DEFAULT_SETTINGS;
|
|
1896
|
+
const ensuredSpaces = /* @__PURE__ */ new Set();
|
|
1897
|
+
let capacity = DEFAULT_SETTINGS.operationLogSize();
|
|
1898
|
+
const log = createOperationLog({
|
|
1899
|
+
capacity: DEFAULT_SETTINGS.operationLogSize(),
|
|
1900
|
+
...options.onOperation === void 0 ? {} : { onEntry: options.onOperation }
|
|
1901
|
+
});
|
|
1902
|
+
const activitySeen = { value: false };
|
|
1903
|
+
ctx.effect(() => {
|
|
1904
|
+
const manager = settingsAccessor();
|
|
1905
|
+
if (manager === void 0) return void 0;
|
|
1906
|
+
let registered;
|
|
1907
|
+
try {
|
|
1908
|
+
registered = registerFeedbackSettings(manager);
|
|
1909
|
+
} catch (error) {
|
|
1910
|
+
reportWarning("FEEDBACK_SETTINGS_UNAVAILABLE", error);
|
|
1911
|
+
return;
|
|
1912
|
+
}
|
|
1913
|
+
settings = registered;
|
|
1914
|
+
ensuredSpaces.clear();
|
|
1915
|
+
capacity = Math.max(20, Math.min(500, registered.operationLogSize()));
|
|
1916
|
+
log.setCapacity(capacity);
|
|
1917
|
+
const unwatch = manager.watch?.([SETTING_KEYS.operationLogSize], () => {
|
|
1918
|
+
capacity = Math.max(20, Math.min(500, registered.operationLogSize()));
|
|
1919
|
+
log.setCapacity(capacity);
|
|
1920
|
+
});
|
|
1921
|
+
return () => {
|
|
1922
|
+
unwatch?.();
|
|
1923
|
+
registered.dispose();
|
|
1924
|
+
settings = DEFAULT_SETTINGS;
|
|
1925
|
+
};
|
|
1926
|
+
});
|
|
1927
|
+
registerObservers(ctx, {
|
|
1928
|
+
log,
|
|
1929
|
+
now: () => Date.now()
|
|
1930
|
+
});
|
|
1931
|
+
const activitySink = createActivitySink(log);
|
|
1932
|
+
ctx.contribute(SLOTS.uiActivitySinks, "feedback", {
|
|
1933
|
+
owner: "feedback",
|
|
1934
|
+
record: (fact) => {
|
|
1935
|
+
activitySeen.value = true;
|
|
1936
|
+
try {
|
|
1937
|
+
activitySink.record(fact);
|
|
1938
|
+
} catch {
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
});
|
|
1943
|
+
const bundler = createBundler({
|
|
1944
|
+
home,
|
|
1945
|
+
cwd,
|
|
1946
|
+
pluginVersion: FEEDBACK_PLUGIN_VERSION,
|
|
1947
|
+
hostInfo: () => hostInfoAccessor()?.snapshot(),
|
|
1948
|
+
sessions: {
|
|
1949
|
+
get: (id) => sessionsAccessor()?.get(id) ?? Promise.resolve(null),
|
|
1950
|
+
surface: (id) => {
|
|
1951
|
+
const manager = sessionsAccessor();
|
|
1952
|
+
if (manager === void 0) throw new Error("feedback: sessions are unavailable");
|
|
1953
|
+
return manager.surface(id);
|
|
1954
|
+
},
|
|
1955
|
+
surfaceWindowOf: (id) => sessionsAccessor()?.surfaceWindowOf?.(id)
|
|
1956
|
+
},
|
|
1957
|
+
operations: () => log.snapshot(),
|
|
1958
|
+
model: () => {
|
|
1959
|
+
const value = settingsAccessor()?.get("model");
|
|
1960
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
1961
|
+
},
|
|
1962
|
+
provider: () => {
|
|
1963
|
+
const value = settingsAccessor()?.get("model");
|
|
1964
|
+
if (typeof value !== "string" || value === "") return void 0;
|
|
1965
|
+
const slash = value.indexOf("/");
|
|
1966
|
+
return slash === -1 ? void 0 : value.slice(0, slash);
|
|
1967
|
+
},
|
|
1968
|
+
permissionMode: () => adoptedPermissionModeOfSettings(settingsAccessor()),
|
|
1969
|
+
includeDiagnostics: () => settings.includeDiagnostics(),
|
|
1970
|
+
includeWorkspaceName: () => settings.includeWorkspaceName(),
|
|
1971
|
+
maxBundleBytes: () => settings.maxBundleBytes(),
|
|
1972
|
+
uiActivity: () => activitySeen.value,
|
|
1973
|
+
...options.now === void 0 ? {} : { now: options.now },
|
|
1974
|
+
...options.newId === void 0 ? {} : { newId: options.newId }
|
|
1975
|
+
});
|
|
1976
|
+
const outbox = createOutboxPublisher({ home });
|
|
1977
|
+
const spaceIdOf = () => spaceAccessor()?.ref().id ?? "universal";
|
|
1978
|
+
const spaceFields = [
|
|
1979
|
+
["publisher", PUBLISHER_SERVICE],
|
|
1980
|
+
["service.url", ""],
|
|
1981
|
+
["service.authProvider", DEFAULT_AUTH_PROVIDER]
|
|
1982
|
+
];
|
|
1983
|
+
const ensureSpaceFields = (spaceId) => {
|
|
1984
|
+
const manager = settingsAccessor();
|
|
1985
|
+
if (manager === void 0 || ensuredSpaces.has(spaceId)) return;
|
|
1986
|
+
for (const [field, fallback] of spaceFields) try {
|
|
1987
|
+
manager.registerField({
|
|
1988
|
+
key: spaceSettingKey(spaceId, "feedback", field),
|
|
1989
|
+
default: fallback,
|
|
1990
|
+
ownership: "any",
|
|
1991
|
+
sync: "user",
|
|
1992
|
+
namingExempt: true
|
|
1993
|
+
});
|
|
1994
|
+
} catch {
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
ensuredSpaces.add(spaceId);
|
|
1998
|
+
};
|
|
1999
|
+
const spaceText = (field) => {
|
|
2000
|
+
const spaceId = spaceIdOf();
|
|
2001
|
+
ensureSpaceFields(spaceId);
|
|
2002
|
+
const manager = settingsAccessor();
|
|
2003
|
+
const key = spaceSettingKey(spaceId, "feedback", field);
|
|
2004
|
+
const value = manager?.get(key);
|
|
2005
|
+
if (typeof value !== "string" || value === "") return "";
|
|
2006
|
+
return manager?.originOf?.(key)?.layer === "project" ? "" : value;
|
|
2007
|
+
};
|
|
2008
|
+
const publisherMode = () => normalizePublisher(spaceText("publisher") || settings.publisher()) === "outbox" ? "outbox" : "service";
|
|
2009
|
+
const authProvider = () => spaceText("service.authProvider") || settings.serviceAuthProvider();
|
|
2010
|
+
const service = createServicePublisher({
|
|
2011
|
+
serviceUrl: () => spaceText("service.url") || settings.serviceUrl(),
|
|
2012
|
+
allowHttp: () => envAccessor()?.get(FEEDBACK_SERVICE_ALLOW_HTTP_ENV) === "1",
|
|
2013
|
+
allowedHosts: () => (envAccessor()?.get("OTTO_FEEDBACK_SERVICE_HOSTS") ?? "").split(",").map((host) => host.trim().toLowerCase()).filter((host) => host !== ""),
|
|
2014
|
+
session: async () => {
|
|
2015
|
+
const provider = authProvider();
|
|
2016
|
+
const resolved = await resolverAccessor()?.resolve(provider).catch(() => void 0);
|
|
2017
|
+
if ((resolved?.kind === "bearer" || resolved?.kind === "api-key") && resolved.token !== void 0 && resolved.token !== "") return resolved.token;
|
|
2018
|
+
const stored = await authAccessor()?.get(provider).catch(() => void 0);
|
|
2019
|
+
if (stored?.kind === "oauth" && typeof stored.access === "string" && stored.access !== "") return stored.access;
|
|
2020
|
+
return stored?.kind === "api-key" && typeof stored.key === "string" && stored.key !== "" ? stored.key : void 0;
|
|
2021
|
+
},
|
|
2022
|
+
invalidateSession: () => resolverAccessor()?.invalidate(authProvider())
|
|
2023
|
+
});
|
|
2024
|
+
const ports = {
|
|
2025
|
+
locale: () => settingsAccessor()?.get("language") === "zh" ? "zh" : "en",
|
|
2026
|
+
messages: () => messagesOf(ports.locale()),
|
|
2027
|
+
sessionId: () => sessionId,
|
|
2028
|
+
operations: () => log.snapshot(),
|
|
2029
|
+
includeDiagnostics: () => settings.includeDiagnostics(),
|
|
2030
|
+
includeWorkspaceName: () => settings.includeWorkspaceName(),
|
|
2031
|
+
publisherMode,
|
|
2032
|
+
build: (draft, signal) => bundler.build(draft, signal),
|
|
2033
|
+
publish: (bundle, draft, signal) => publisherMode() === "service" ? service.publish(bundle, draft, signal) : outbox.publish(bundle, draft, signal),
|
|
2034
|
+
discard: (bundle) => bundler.discard(bundle)
|
|
2035
|
+
};
|
|
2036
|
+
const actions = {
|
|
2037
|
+
status: () => ({
|
|
2038
|
+
sessionId,
|
|
2039
|
+
publisherMode: publisherMode(),
|
|
2040
|
+
includeDiagnostics: settings.includeDiagnostics(),
|
|
2041
|
+
includeWorkspaceName: settings.includeWorkspaceName()
|
|
2042
|
+
}),
|
|
2043
|
+
build: (draft) => bundler.build(draft, new AbortController().signal),
|
|
2044
|
+
publish: (input) => publisherMode() === "service" ? service.publish(input.bundle, input.draft) : outbox.publish(input.bundle, input.draft),
|
|
2045
|
+
discard: (bundle) => bundler.discard(bundle)
|
|
2046
|
+
};
|
|
2047
|
+
try {
|
|
2048
|
+
ctx.contribute(SLOTS.commands, feedbackCommandKey(), createFeedbackCommand({
|
|
2049
|
+
open: (id) => {
|
|
2050
|
+
sessionId = id;
|
|
2051
|
+
},
|
|
2052
|
+
actions
|
|
2053
|
+
}));
|
|
2054
|
+
ctx.contribute(SLOTS.uiPositions, feedbackPositionKey(), feedbackPosition(ports));
|
|
2055
|
+
ctx.contribute(SLOTS.uiSettings, FEEDBACK_SETTINGS_PAGE_ID, feedbackSettingsPage(spaceIdOf()));
|
|
2056
|
+
} catch (error) {
|
|
2057
|
+
reportWarning("FEEDBACK_CONTRIBUTION_FAILED", error);
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
Object.defineProperty(Feedback, "name", {
|
|
2061
|
+
value: "Feedback",
|
|
2062
|
+
configurable: true
|
|
2063
|
+
});
|
|
2064
|
+
return Feedback;
|
|
2065
|
+
}
|
|
2066
|
+
const Feedback = createFeedbackComponent();
|
|
2067
|
+
|
|
2068
|
+
//#endregion
|
|
2069
|
+
export { Feedback, Feedback as default, checkServiceUrl, collectDiagnostics, collectEnvironment, collectSession, createBundler, createFeedbackCommand, createFeedbackComponent, createOperationLog, createOutboxPublisher, createRedactor, createServicePublisher, defaultBundleId, feedbackCommandKey, feedbackPosition, feedbackPositionKey, linesOf, messagesOf, registerFeedbackSettings, renderReport, textOf, writeZip };
|