@threadbase-sh/streamer 1.46.1 → 1.47.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/cli.cjs +11410 -10660
- package/dist/cli.cjs.map +1 -1
- package/dist/ensure-demo-project-dirs.cjs +105 -0
- package/dist/ensure-demo-project-dirs.cjs.map +1 -0
- package/dist/index.cjs +936 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -4
- package/dist/index.d.ts +100 -4
- package/dist/index.js +937 -195
- package/dist/index.js.map +1 -1
- package/dist/merge-server-yaml.cjs +97 -0
- package/dist/merge-server-yaml.cjs.map +1 -0
- package/dist/migrations/015_drop_projects_message_count.sql +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/docker/mergeServerYaml.ts
|
|
22
|
+
var mergeServerYaml_exports = {};
|
|
23
|
+
__export(mergeServerYaml_exports, {
|
|
24
|
+
mergeServerYaml: () => mergeServerYaml
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(mergeServerYaml_exports);
|
|
27
|
+
var import_node_fs = require("fs");
|
|
28
|
+
var import_node_path = require("path");
|
|
29
|
+
function mergeServerYaml(filePath, values) {
|
|
30
|
+
(0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(filePath), { recursive: true });
|
|
31
|
+
let content = "";
|
|
32
|
+
try {
|
|
33
|
+
content = (0, import_node_fs.readFileSync)(filePath, "utf-8");
|
|
34
|
+
} catch (err) {
|
|
35
|
+
if (err.code !== "ENOENT") throw err;
|
|
36
|
+
}
|
|
37
|
+
let updated = content;
|
|
38
|
+
for (const [key, value] of Object.entries(values)) {
|
|
39
|
+
if (!/^[a-z_][a-z0-9_]*$/i.test(key)) {
|
|
40
|
+
throw new Error(`refusing to write invalid server.yaml key: ${key}`);
|
|
41
|
+
}
|
|
42
|
+
if (/[\r\n]/.test(value)) {
|
|
43
|
+
throw new Error(`refusing to write multi-line value for server.yaml key: ${key}`);
|
|
44
|
+
}
|
|
45
|
+
const lineRe = new RegExp(`^${key}:\\s*.*$\\n?`, "m");
|
|
46
|
+
const line = `${key}: ${value}`;
|
|
47
|
+
if (lineRe.test(updated)) {
|
|
48
|
+
updated = updated.replace(lineRe, `${line}
|
|
49
|
+
`);
|
|
50
|
+
} else if (updated.length === 0 || updated.endsWith("\n")) {
|
|
51
|
+
updated = `${updated}${line}
|
|
52
|
+
`;
|
|
53
|
+
} else {
|
|
54
|
+
updated = `${updated}
|
|
55
|
+
${line}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const tmpFile = `${filePath}.tmp`;
|
|
60
|
+
(0, import_node_fs.writeFileSync)(tmpFile, updated, { encoding: "utf-8", mode: 384 });
|
|
61
|
+
(0, import_node_fs.chmodSync)(tmpFile, 384);
|
|
62
|
+
(0, import_node_fs.renameSync)(tmpFile, filePath);
|
|
63
|
+
}
|
|
64
|
+
function main() {
|
|
65
|
+
const filePath = process.env.SERVER_YAML_PATH;
|
|
66
|
+
if (!filePath) {
|
|
67
|
+
console.error("[entrypoint] merge-server-yaml: SERVER_YAML_PATH is not set");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
const values = {};
|
|
71
|
+
for (const arg of process.argv.slice(2)) {
|
|
72
|
+
const eq = arg.indexOf("=");
|
|
73
|
+
if (eq <= 0) {
|
|
74
|
+
console.error(`[entrypoint] merge-server-yaml: expected key=value, got: ${arg}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
values[arg.slice(0, eq)] = arg.slice(eq + 1);
|
|
78
|
+
}
|
|
79
|
+
if (Object.keys(values).length === 0) {
|
|
80
|
+
console.error("[entrypoint] merge-server-yaml: no key=value arguments provided");
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
mergeServerYaml(filePath, values);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(`[entrypoint] ${err.message}`);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (require.main === module) {
|
|
91
|
+
main();
|
|
92
|
+
}
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
mergeServerYaml
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=merge-server-yaml.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/docker/mergeServerYaml.ts"],"sourcesContent":["// Upsert flat `key: value` lines into server.yaml without clobbering unrelated\n// keys. The docker entrypoint used to rewrite the whole file on every boot,\n// which wiped operator-added settings (claude_flags, feature_flags, …) that\n// survived on the Fly volume. This merge keeps those lines and only touches\n// the keys the container must own (api_key, public_url, browse_root).\n//\n// Same encoding rules as src/auth.ts setConfigValue: one line per key, atomic\n// tmp+rename, mode 0600. Compiled by tsup to dist/merge-server-yaml.cjs.\nimport { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\n/**\n * Upsert each key in `values` into the flat server.yaml at `filePath`.\n * Existing unrelated keys are preserved. Missing file → created.\n */\nexport function mergeServerYaml(filePath: string, values: Record<string, string>): void {\n mkdirSync(dirname(filePath), { recursive: true });\n\n let content = \"\";\n try {\n content = readFileSync(filePath, \"utf-8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") throw err;\n }\n\n let updated = content;\n for (const [key, value] of Object.entries(values)) {\n if (!/^[a-z_][a-z0-9_]*$/i.test(key)) {\n throw new Error(`refusing to write invalid server.yaml key: ${key}`);\n }\n // Values must stay on one line — newlines would break the regex readers.\n if (/[\\r\\n]/.test(value)) {\n throw new Error(`refusing to write multi-line value for server.yaml key: ${key}`);\n }\n const lineRe = new RegExp(`^${key}:\\\\s*.*$\\\\n?`, \"m\");\n const line = `${key}: ${value}`;\n if (lineRe.test(updated)) {\n updated = updated.replace(lineRe, `${line}\\n`);\n } else if (updated.length === 0 || updated.endsWith(\"\\n\")) {\n updated = `${updated}${line}\\n`;\n } else {\n updated = `${updated}\\n${line}\\n`;\n }\n }\n\n const tmpFile = `${filePath}.tmp`;\n writeFileSync(tmpFile, updated, { encoding: \"utf-8\", mode: 0o600 });\n chmodSync(tmpFile, 0o600);\n renameSync(tmpFile, filePath);\n}\n\nfunction main(): void {\n const filePath = process.env.SERVER_YAML_PATH;\n if (!filePath) {\n console.error(\"[entrypoint] merge-server-yaml: SERVER_YAML_PATH is not set\");\n process.exit(1);\n }\n\n const values: Record<string, string> = {};\n for (const arg of process.argv.slice(2)) {\n const eq = arg.indexOf(\"=\");\n if (eq <= 0) {\n console.error(`[entrypoint] merge-server-yaml: expected key=value, got: ${arg}`);\n process.exit(1);\n }\n values[arg.slice(0, eq)] = arg.slice(eq + 1);\n }\n if (Object.keys(values).length === 0) {\n console.error(\"[entrypoint] merge-server-yaml: no key=value arguments provided\");\n process.exit(1);\n }\n\n try {\n mergeServerYaml(filePath, values);\n } catch (err) {\n console.error(`[entrypoint] ${(err as Error).message}`);\n process.exit(1);\n }\n}\n\nif (require.main === module) {\n main();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAA8E;AAC9E,uBAAwB;AAMjB,SAAS,gBAAgB,UAAkB,QAAsC;AACtF,oCAAU,0BAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAEhD,MAAI,UAAU;AACd,MAAI;AACF,kBAAU,6BAAa,UAAU,OAAO;AAAA,EAC1C,SAAS,KAAK;AACZ,QAAK,IAA8B,SAAS,SAAU,OAAM;AAAA,EAC9D;AAEA,MAAI,UAAU;AACd,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,CAAC,sBAAsB,KAAK,GAAG,GAAG;AACpC,YAAM,IAAI,MAAM,8CAA8C,GAAG,EAAE;AAAA,IACrE;AAEA,QAAI,SAAS,KAAK,KAAK,GAAG;AACxB,YAAM,IAAI,MAAM,2DAA2D,GAAG,EAAE;AAAA,IAClF;AACA,UAAM,SAAS,IAAI,OAAO,IAAI,GAAG,gBAAgB,GAAG;AACpD,UAAM,OAAO,GAAG,GAAG,KAAK,KAAK;AAC7B,QAAI,OAAO,KAAK,OAAO,GAAG;AACxB,gBAAU,QAAQ,QAAQ,QAAQ,GAAG,IAAI;AAAA,CAAI;AAAA,IAC/C,WAAW,QAAQ,WAAW,KAAK,QAAQ,SAAS,IAAI,GAAG;AACzD,gBAAU,GAAG,OAAO,GAAG,IAAI;AAAA;AAAA,IAC7B,OAAO;AACL,gBAAU,GAAG,OAAO;AAAA,EAAK,IAAI;AAAA;AAAA,IAC/B;AAAA,EACF;AAEA,QAAM,UAAU,GAAG,QAAQ;AAC3B,oCAAc,SAAS,SAAS,EAAE,UAAU,SAAS,MAAM,IAAM,CAAC;AAClE,gCAAU,SAAS,GAAK;AACxB,iCAAW,SAAS,QAAQ;AAC9B;AAEA,SAAS,OAAa;AACpB,QAAM,WAAW,QAAQ,IAAI;AAC7B,MAAI,CAAC,UAAU;AACb,YAAQ,MAAM,6DAA6D;AAC3E,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,SAAiC,CAAC;AACxC,aAAW,OAAO,QAAQ,KAAK,MAAM,CAAC,GAAG;AACvC,UAAM,KAAK,IAAI,QAAQ,GAAG;AAC1B,QAAI,MAAM,GAAG;AACX,cAAQ,MAAM,4DAA4D,GAAG,EAAE;AAC/E,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,WAAO,IAAI,MAAM,GAAG,EAAE,CAAC,IAAI,IAAI,MAAM,KAAK,CAAC;AAAA,EAC7C;AACA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AACpC,YAAQ,MAAM,iEAAiE;AAC/E,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI;AACF,oBAAgB,UAAU,MAAM;AAAA,EAClC,SAAS,KAAK;AACZ,YAAQ,MAAM,gBAAiB,IAAc,OAAO,EAAE;AACtD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC3B,OAAK;AACP;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- projects.message_count was written as 0 on insert and never updated by
|
|
2
|
+
-- anything, and no code or endpoint ever read it back. A column that always
|
|
3
|
+
-- reads 0 is worse than an absent one: it invites a caller to trust it.
|
|
4
|
+
--
|
|
5
|
+
-- Conversation counts per project come from conversation_meta (the same rows
|
|
6
|
+
-- /api/conversations pages), which is where a count can be consistent with
|
|
7
|
+
-- what a client renders.
|
|
8
|
+
ALTER TABLE projects DROP COLUMN message_count;
|
package/package.json
CHANGED