@slock-ai/daemon 0.46.1 → 0.46.2-play.20260509145625
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/{chunk-XW57NR6Y.js → chunk-PLSUHXSG.js} +220 -36
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1093,6 +1093,17 @@ Keep the user informed. They cannot see your internal reasoning, so:
|
|
|
1093
1093
|
- For multi-step work, send short progress updates (e.g. "Working on step 2/3\u2026").
|
|
1094
1094
|
- When done, summarize the result.
|
|
1095
1095
|
- Keep updates concise \u2014 one or two sentences. Don't flood the chat.
|
|
1096
|
+
- For long answers where users need the conclusion first but details still matter, put the conclusion and next action outside any collapse, then use sanitized HTML details blocks for optional depth:
|
|
1097
|
+
|
|
1098
|
+
\`\`\`html
|
|
1099
|
+
<details>
|
|
1100
|
+
<summary>Evidence, logs, or edge cases</summary>
|
|
1101
|
+
|
|
1102
|
+
Detailed notes go here.
|
|
1103
|
+
</details>
|
|
1104
|
+
\`\`\`
|
|
1105
|
+
|
|
1106
|
+
Do not hide the main recommendation, blocker, or required action inside \`<details>\`; only fold supporting evidence, logs, alternatives, or extended rationale.
|
|
1096
1107
|
|
|
1097
1108
|
### Conversation etiquette
|
|
1098
1109
|
|
|
@@ -2772,13 +2783,16 @@ var GeminiDriver = class {
|
|
|
2772
2783
|
// src/drivers/kimi.ts
|
|
2773
2784
|
import { randomUUID } from "crypto";
|
|
2774
2785
|
import { spawn as spawn6 } from "child_process";
|
|
2775
|
-
import { existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
2786
|
+
import { chmodSync, existsSync as existsSync6, readFileSync as readFileSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
2776
2787
|
import os3 from "os";
|
|
2777
2788
|
import path8 from "path";
|
|
2778
2789
|
var KIMI_WIRE_PROTOCOL_VERSION = "1.3";
|
|
2779
2790
|
var KIMI_SYSTEM_PROMPT_FILE = ".slock-kimi-system.md";
|
|
2780
2791
|
var KIMI_AGENT_FILE = ".slock-kimi-agent.yaml";
|
|
2781
2792
|
var KIMI_MCP_FILE = ".slock-kimi-mcp.json";
|
|
2793
|
+
var KIMI_GENERATED_CONFIG_FILE = ".slock-kimi-config.toml";
|
|
2794
|
+
var SLOCK_KIMI_CONFIG_CONTENT_ENV = "SLOCK_KIMI_CONFIG_CONTENT";
|
|
2795
|
+
var SLOCK_KIMI_CONFIG_FILE_ENV = "SLOCK_KIMI_CONFIG_FILE";
|
|
2782
2796
|
function parseToolArguments(raw) {
|
|
2783
2797
|
if (typeof raw !== "string") return raw;
|
|
2784
2798
|
try {
|
|
@@ -2787,6 +2801,73 @@ function parseToolArguments(raw) {
|
|
|
2787
2801
|
return raw;
|
|
2788
2802
|
}
|
|
2789
2803
|
}
|
|
2804
|
+
function readKimiConfigSource(home = os3.homedir(), env = process.env) {
|
|
2805
|
+
const inlineConfig = env[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
2806
|
+
if (inlineConfig && inlineConfig.trim()) {
|
|
2807
|
+
return {
|
|
2808
|
+
raw: inlineConfig,
|
|
2809
|
+
explicitPath: null,
|
|
2810
|
+
sourcePath: SLOCK_KIMI_CONFIG_CONTENT_ENV
|
|
2811
|
+
};
|
|
2812
|
+
}
|
|
2813
|
+
const explicitPath = env[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
2814
|
+
const configPath = explicitPath && explicitPath.trim() ? explicitPath : path8.join(home, ".kimi", "config.toml");
|
|
2815
|
+
try {
|
|
2816
|
+
return {
|
|
2817
|
+
raw: readFileSync3(configPath, "utf8"),
|
|
2818
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
2819
|
+
sourcePath: configPath
|
|
2820
|
+
};
|
|
2821
|
+
} catch {
|
|
2822
|
+
return {
|
|
2823
|
+
raw: null,
|
|
2824
|
+
explicitPath: explicitPath && explicitPath.trim() ? explicitPath : null,
|
|
2825
|
+
sourcePath: configPath
|
|
2826
|
+
};
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
function buildKimiSpawnEnv(env = process.env) {
|
|
2830
|
+
const spawnEnv = { ...env, FORCE_COLOR: "0", NO_COLOR: "1" };
|
|
2831
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_CONTENT_ENV];
|
|
2832
|
+
delete spawnEnv[SLOCK_KIMI_CONFIG_FILE_ENV];
|
|
2833
|
+
return spawnEnv;
|
|
2834
|
+
}
|
|
2835
|
+
function buildKimiEffectiveEnv(ctx, overrideEnv) {
|
|
2836
|
+
return {
|
|
2837
|
+
...process.env,
|
|
2838
|
+
...ctx.config.envVars || {},
|
|
2839
|
+
...overrideEnv || {}
|
|
2840
|
+
};
|
|
2841
|
+
}
|
|
2842
|
+
function buildKimiLaunchOptions(ctx, opts = {}) {
|
|
2843
|
+
const env = buildKimiEffectiveEnv(ctx, opts.env);
|
|
2844
|
+
const source = readKimiConfigSource(opts.home ?? os3.homedir(), env);
|
|
2845
|
+
const args = [];
|
|
2846
|
+
let configFilePath = null;
|
|
2847
|
+
let configContent = null;
|
|
2848
|
+
if (source.explicitPath) {
|
|
2849
|
+
configFilePath = source.explicitPath;
|
|
2850
|
+
} else if (source.raw !== null && source.sourcePath === SLOCK_KIMI_CONFIG_CONTENT_ENV) {
|
|
2851
|
+
configFilePath = path8.join(ctx.workingDirectory, KIMI_GENERATED_CONFIG_FILE);
|
|
2852
|
+
configContent = source.raw;
|
|
2853
|
+
if (opts.writeGeneratedConfig !== false) {
|
|
2854
|
+
writeFileSync6(configFilePath, source.raw, { encoding: "utf8", mode: 384 });
|
|
2855
|
+
chmodSync(configFilePath, 384);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
if (configFilePath) {
|
|
2859
|
+
args.push("--config-file", configFilePath);
|
|
2860
|
+
}
|
|
2861
|
+
if (ctx.config.model && ctx.config.model !== "default") {
|
|
2862
|
+
args.push("--model", ctx.config.model);
|
|
2863
|
+
}
|
|
2864
|
+
return {
|
|
2865
|
+
args,
|
|
2866
|
+
env: buildKimiSpawnEnv(env),
|
|
2867
|
+
configFilePath,
|
|
2868
|
+
configContent
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2790
2871
|
var KimiDriver = class {
|
|
2791
2872
|
id = "kimi";
|
|
2792
2873
|
lifecycle = {
|
|
@@ -2803,7 +2884,25 @@ var KimiDriver = class {
|
|
|
2803
2884
|
};
|
|
2804
2885
|
model = {
|
|
2805
2886
|
detectedModelsVerifiedAs: "launchable",
|
|
2806
|
-
toLaunchSpec: (modelId) =>
|
|
2887
|
+
toLaunchSpec: (modelId, ctx, opts) => {
|
|
2888
|
+
if (!ctx) return { args: ["--model", modelId] };
|
|
2889
|
+
const launchCtx = {
|
|
2890
|
+
...ctx,
|
|
2891
|
+
config: {
|
|
2892
|
+
...ctx.config,
|
|
2893
|
+
model: modelId
|
|
2894
|
+
}
|
|
2895
|
+
};
|
|
2896
|
+
const launch = buildKimiLaunchOptions(launchCtx, {
|
|
2897
|
+
home: opts?.home,
|
|
2898
|
+
writeGeneratedConfig: false
|
|
2899
|
+
});
|
|
2900
|
+
return {
|
|
2901
|
+
args: launch.args,
|
|
2902
|
+
env: launch.env,
|
|
2903
|
+
configFiles: launch.configFilePath ? [launch.configFilePath] : void 0
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2807
2906
|
};
|
|
2808
2907
|
supportsStdinNotification = true;
|
|
2809
2908
|
mcpToolPrefix = "";
|
|
@@ -2855,6 +2954,7 @@ var KimiDriver = class {
|
|
|
2855
2954
|
}
|
|
2856
2955
|
}
|
|
2857
2956
|
}), "utf8");
|
|
2957
|
+
const launch = buildKimiLaunchOptions(ctx);
|
|
2858
2958
|
const args = [
|
|
2859
2959
|
"--wire",
|
|
2860
2960
|
"--yolo",
|
|
@@ -2863,16 +2963,13 @@ var KimiDriver = class {
|
|
|
2863
2963
|
"--mcp-config-file",
|
|
2864
2964
|
mcpConfigPath,
|
|
2865
2965
|
"--session",
|
|
2866
|
-
this.sessionId
|
|
2966
|
+
this.sessionId,
|
|
2967
|
+
...launch.args
|
|
2867
2968
|
];
|
|
2868
|
-
if (ctx.config.model && ctx.config.model !== "default") {
|
|
2869
|
-
args.push("--model", ctx.config.model);
|
|
2870
|
-
}
|
|
2871
|
-
const spawnEnv = { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1" };
|
|
2872
2969
|
const proc = spawn6("kimi", args, {
|
|
2873
2970
|
cwd: ctx.workingDirectory,
|
|
2874
2971
|
stdio: ["pipe", "pipe", "pipe"],
|
|
2875
|
-
env:
|
|
2972
|
+
env: launch.env,
|
|
2876
2973
|
shell: process.platform === "win32"
|
|
2877
2974
|
});
|
|
2878
2975
|
proc.stdin?.write(JSON.stringify({
|
|
@@ -2989,14 +3086,9 @@ var KimiDriver = class {
|
|
|
2989
3086
|
return detectKimiModels();
|
|
2990
3087
|
}
|
|
2991
3088
|
};
|
|
2992
|
-
function detectKimiModels(home = os3.homedir()) {
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2995
|
-
try {
|
|
2996
|
-
raw = readFileSync3(configPath, "utf8");
|
|
2997
|
-
} catch {
|
|
2998
|
-
return null;
|
|
2999
|
-
}
|
|
3089
|
+
function detectKimiModels(home = os3.homedir(), opts = {}) {
|
|
3090
|
+
const raw = readKimiConfigSource(home, opts.env).raw;
|
|
3091
|
+
if (raw === null) return null;
|
|
3000
3092
|
const models = [];
|
|
3001
3093
|
const sectionRe = /^\s*\[models(?:\.([^\]]+)|"\.[^"]+"|\."[^"]+")\s*\]\s*$/gm;
|
|
3002
3094
|
const lineRe = /^\s*\[models\.(.+?)\s*\]\s*$/gm;
|
|
@@ -6830,6 +6922,7 @@ function acquireDaemonMachineLock(options) {
|
|
|
6830
6922
|
import { appendFileSync, mkdirSync as mkdirSync6, readdirSync as readdirSync3, rmSync as rmSync3, statSync as statSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
6831
6923
|
import path13 from "path";
|
|
6832
6924
|
var DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
6925
|
+
var DEFAULT_MAX_FILE_AGE_MS = 5 * 60 * 1e3;
|
|
6833
6926
|
var DEFAULT_MAX_FILES = 8;
|
|
6834
6927
|
var DIAGNOSTIC_ID_ATTRS = /* @__PURE__ */ new Set([
|
|
6835
6928
|
"serverId",
|
|
@@ -6846,14 +6939,25 @@ var DIAGNOSTIC_ID_ATTRS = /* @__PURE__ */ new Set([
|
|
|
6846
6939
|
var LocalRotatingTraceSink = class {
|
|
6847
6940
|
traceDir;
|
|
6848
6941
|
maxFileBytes;
|
|
6942
|
+
maxFileAgeMs;
|
|
6849
6943
|
maxFiles;
|
|
6944
|
+
nowMsProvider;
|
|
6850
6945
|
currentFile = null;
|
|
6946
|
+
currentFileOpenedAtMs = null;
|
|
6851
6947
|
currentSize = 0;
|
|
6852
6948
|
sequence = 0;
|
|
6853
6949
|
constructor(options) {
|
|
6854
6950
|
this.traceDir = path13.join(options.machineDir, "traces");
|
|
6855
6951
|
this.maxFileBytes = Math.max(1024, Math.floor(options.maxFileBytes ?? DEFAULT_MAX_FILE_BYTES));
|
|
6952
|
+
const baseAgeMs = Math.max(1e3, Math.floor(options.maxFileAgeMs ?? DEFAULT_MAX_FILE_AGE_MS));
|
|
6953
|
+
const ageJitterMs = Math.max(0, Math.floor(options.maxFileAgeJitterMs ?? 0));
|
|
6954
|
+
this.maxFileAgeMs = baseAgeMs + ageJitterMs;
|
|
6856
6955
|
this.maxFiles = Math.max(1, Math.floor(options.maxFiles ?? DEFAULT_MAX_FILES));
|
|
6956
|
+
this.nowMsProvider = options.nowMsProvider ?? Date.now;
|
|
6957
|
+
}
|
|
6958
|
+
/** Exposed for observability — the effective rotation age after jitter. */
|
|
6959
|
+
getMaxFileAgeMs() {
|
|
6960
|
+
return this.maxFileAgeMs;
|
|
6857
6961
|
}
|
|
6858
6962
|
record(span) {
|
|
6859
6963
|
try {
|
|
@@ -6870,13 +6974,16 @@ var LocalRotatingTraceSink = class {
|
|
|
6870
6974
|
}
|
|
6871
6975
|
ensureFile(nextBytes) {
|
|
6872
6976
|
mkdirSync6(this.traceDir, { recursive: true, mode: 448 });
|
|
6873
|
-
|
|
6977
|
+
const nowMs = this.nowMsProvider();
|
|
6978
|
+
const shouldRotateForAge = this.currentFileOpenedAtMs !== null && nowMs - this.currentFileOpenedAtMs >= this.maxFileAgeMs;
|
|
6979
|
+
if (!this.currentFile || this.currentSize + nextBytes > this.maxFileBytes || shouldRotateForAge) {
|
|
6874
6980
|
this.currentFile = path13.join(
|
|
6875
6981
|
this.traceDir,
|
|
6876
|
-
`daemon-trace-${safeTimestamp(
|
|
6982
|
+
`daemon-trace-${safeTimestamp(nowMs)}-${process.pid}-${String(this.sequence++).padStart(4, "0")}.jsonl`
|
|
6877
6983
|
);
|
|
6878
6984
|
writeFileSync9(this.currentFile, "", { flag: "a", mode: 384 });
|
|
6879
6985
|
this.currentSize = statSync4(this.currentFile).size;
|
|
6986
|
+
this.currentFileOpenedAtMs = nowMs;
|
|
6880
6987
|
this.pruneOldFiles();
|
|
6881
6988
|
}
|
|
6882
6989
|
}
|
|
@@ -6961,7 +7068,7 @@ function isDiagnosticIdAttr(key) {
|
|
|
6961
7068
|
}
|
|
6962
7069
|
|
|
6963
7070
|
// src/traceBundleUpload.ts
|
|
6964
|
-
import { createHash as
|
|
7071
|
+
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
6965
7072
|
import { gzipSync } from "zlib";
|
|
6966
7073
|
import { mkdir as mkdir2, readFile as readFile2, readdir as readdir3, stat as stat3, writeFile as writeFile2 } from "fs/promises";
|
|
6967
7074
|
import path14 from "path";
|
|
@@ -7090,6 +7197,35 @@ async function uploadWithSignedCapability({
|
|
|
7090
7197
|
return { capability, session, uploadResponse };
|
|
7091
7198
|
}
|
|
7092
7199
|
|
|
7200
|
+
// src/traceJitter.ts
|
|
7201
|
+
import { createHash as createHash2 } from "crypto";
|
|
7202
|
+
var INITIAL_UPLOAD_DELAY_SPAN_MS = 3e4;
|
|
7203
|
+
var UPLOAD_INTERVAL_JITTER_SPAN_MS = 6e4;
|
|
7204
|
+
var MAX_FILE_AGE_JITTER_SPAN_MS = 6e4;
|
|
7205
|
+
function computeTraceJitter(lockId) {
|
|
7206
|
+
const seed = createHash2("sha256").update(lockId).digest();
|
|
7207
|
+
return {
|
|
7208
|
+
initialUploadDelayMs: seed.readUInt32BE(0) % INITIAL_UPLOAD_DELAY_SPAN_MS,
|
|
7209
|
+
uploadIntervalJitterMs: seed.readUInt32BE(4) % UPLOAD_INTERVAL_JITTER_SPAN_MS,
|
|
7210
|
+
maxFileAgeJitterMs: seed.readUInt32BE(8) % MAX_FILE_AGE_JITTER_SPAN_MS
|
|
7211
|
+
};
|
|
7212
|
+
}
|
|
7213
|
+
var NO_JITTER = {
|
|
7214
|
+
initialUploadDelayMs: 0,
|
|
7215
|
+
uploadIntervalJitterMs: 0,
|
|
7216
|
+
maxFileAgeJitterMs: 0
|
|
7217
|
+
};
|
|
7218
|
+
function bucketDelayMs(delayMs) {
|
|
7219
|
+
if (delayMs < 1e3) return "0-1s";
|
|
7220
|
+
if (delayMs < 5e3) return "1-5s";
|
|
7221
|
+
if (delayMs < 15e3) return "5-15s";
|
|
7222
|
+
if (delayMs < 3e4) return "15-30s";
|
|
7223
|
+
if (delayMs < 6e4) return "30-60s";
|
|
7224
|
+
if (delayMs < 3e5) return "60s-5m";
|
|
7225
|
+
if (delayMs < 6e5) return "5-10m";
|
|
7226
|
+
return "10m+";
|
|
7227
|
+
}
|
|
7228
|
+
|
|
7093
7229
|
// src/traceBundleUpload.ts
|
|
7094
7230
|
var TRACE_UPLOAD_SCOPE = "daemon-trace-bundle:create";
|
|
7095
7231
|
var DEFAULT_UPLOAD_INTERVAL_MS = 5 * 60 * 1e3;
|
|
@@ -7097,30 +7233,66 @@ var DEFAULT_MIN_FILE_AGE_MS = 60 * 1e3;
|
|
|
7097
7233
|
var DEFAULT_MAX_FILES_PER_RUN = 4;
|
|
7098
7234
|
var DaemonTraceBundleUploader = class {
|
|
7099
7235
|
options;
|
|
7100
|
-
|
|
7236
|
+
jitter;
|
|
7237
|
+
timers;
|
|
7238
|
+
initialDelayTimer = null;
|
|
7239
|
+
intervalTimer = null;
|
|
7240
|
+
stopped = false;
|
|
7101
7241
|
constructor(options) {
|
|
7102
7242
|
this.options = options;
|
|
7243
|
+
this.jitter = options.jitter ?? (options.lockId ? computeTraceJitter(options.lockId) : NO_JITTER);
|
|
7244
|
+
this.timers = options.timers ?? {
|
|
7245
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
7246
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
7247
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
7248
|
+
clearInterval: globalThis.clearInterval.bind(globalThis)
|
|
7249
|
+
};
|
|
7103
7250
|
}
|
|
7104
7251
|
start() {
|
|
7105
|
-
if (this.
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7252
|
+
if (this.stopped) return;
|
|
7253
|
+
if (this.initialDelayTimer || this.intervalTimer) return;
|
|
7254
|
+
const initialDelayMs = this.jitter.initialUploadDelayMs;
|
|
7255
|
+
this.initialDelayTimer = this.timers.setTimeout(() => {
|
|
7256
|
+
this.initialDelayTimer = null;
|
|
7257
|
+
if (this.stopped) return;
|
|
7258
|
+
void this.uploadOnce("initial");
|
|
7259
|
+
this.scheduleNextTick();
|
|
7260
|
+
}, initialDelayMs);
|
|
7110
7261
|
}
|
|
7111
7262
|
stop() {
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7263
|
+
this.stopped = true;
|
|
7264
|
+
if (this.initialDelayTimer) {
|
|
7265
|
+
this.timers.clearTimeout(this.initialDelayTimer);
|
|
7266
|
+
this.initialDelayTimer = null;
|
|
7267
|
+
}
|
|
7268
|
+
if (this.intervalTimer) {
|
|
7269
|
+
this.timers.clearTimeout(this.intervalTimer);
|
|
7270
|
+
this.intervalTimer = null;
|
|
7271
|
+
}
|
|
7115
7272
|
}
|
|
7116
|
-
|
|
7273
|
+
/**
|
|
7274
|
+
* Drive a single upload pass. `trigger` is surfaced as a span attribute so
|
|
7275
|
+
* we can distinguish startup drain vs steady-state ticks in ScopeDB.
|
|
7276
|
+
*/
|
|
7277
|
+
async uploadOnce(trigger = "manual") {
|
|
7117
7278
|
const files = await this.findUploadCandidates();
|
|
7118
7279
|
let uploaded = 0;
|
|
7119
7280
|
for (const file of files.slice(0, this.options.maxFilesPerRun ?? DEFAULT_MAX_FILES_PER_RUN)) {
|
|
7120
|
-
if (await this.uploadFile(file)) uploaded += 1;
|
|
7281
|
+
if (await this.uploadFile(file, trigger)) uploaded += 1;
|
|
7121
7282
|
}
|
|
7122
7283
|
return { attempted: files.length, uploaded };
|
|
7123
7284
|
}
|
|
7285
|
+
scheduleNextTick() {
|
|
7286
|
+
if (this.stopped) return;
|
|
7287
|
+
const baseIntervalMs = this.options.intervalMs ?? readPositiveIntegerEnv2("SLOCK_DAEMON_TRACE_UPLOAD_INTERVAL_MS", DEFAULT_UPLOAD_INTERVAL_MS);
|
|
7288
|
+
const nextMs = baseIntervalMs + this.jitter.uploadIntervalJitterMs;
|
|
7289
|
+
this.intervalTimer = this.timers.setTimeout(() => {
|
|
7290
|
+
this.intervalTimer = null;
|
|
7291
|
+
if (this.stopped) return;
|
|
7292
|
+
void this.uploadOnce("interval");
|
|
7293
|
+
this.scheduleNextTick();
|
|
7294
|
+
}, nextMs);
|
|
7295
|
+
}
|
|
7124
7296
|
async findUploadCandidates() {
|
|
7125
7297
|
const traceDir = path14.join(this.options.machineDir, "traces");
|
|
7126
7298
|
let names;
|
|
@@ -7147,13 +7319,16 @@ var DaemonTraceBundleUploader = class {
|
|
|
7147
7319
|
}
|
|
7148
7320
|
return candidates;
|
|
7149
7321
|
}
|
|
7150
|
-
async uploadFile(file) {
|
|
7322
|
+
async uploadFile(file, trigger) {
|
|
7151
7323
|
const span = this.options.tracer?.startSpan("daemon.bundle.upload", {
|
|
7152
7324
|
surface: "daemon",
|
|
7153
7325
|
kind: "producer",
|
|
7154
7326
|
attrs: {
|
|
7155
7327
|
file_present: true,
|
|
7156
|
-
worker_url_present: Boolean(this.options.workerUrl)
|
|
7328
|
+
worker_url_present: Boolean(this.options.workerUrl),
|
|
7329
|
+
upload_trigger: trigger,
|
|
7330
|
+
initial_delay_ms_bucket: bucketDelayMs(this.jitter.initialUploadDelayMs),
|
|
7331
|
+
interval_jitter_ms_bucket: bucketDelayMs(this.jitter.uploadIntervalJitterMs)
|
|
7157
7332
|
}
|
|
7158
7333
|
});
|
|
7159
7334
|
try {
|
|
@@ -7229,7 +7404,7 @@ var DaemonTraceBundleUploader = class {
|
|
|
7229
7404
|
}
|
|
7230
7405
|
};
|
|
7231
7406
|
function sha256Hex(body) {
|
|
7232
|
-
return
|
|
7407
|
+
return createHash3("sha256").update(body).digest("hex");
|
|
7233
7408
|
}
|
|
7234
7409
|
function readPositiveIntegerEnv2(name, fallback) {
|
|
7235
7410
|
const value = process.env[name];
|
|
@@ -7239,6 +7414,7 @@ function readPositiveIntegerEnv2(name, fallback) {
|
|
|
7239
7414
|
}
|
|
7240
7415
|
|
|
7241
7416
|
// src/core.ts
|
|
7417
|
+
var DEFAULT_TRACE_UPLOAD_URL = "https://slock-trace-upload.botiverse.dev";
|
|
7242
7418
|
var DAEMON_CLI_USAGE = "Usage: slock-daemon --server-url <url> --api-key <key>";
|
|
7243
7419
|
function parseDaemonCliArgs(args) {
|
|
7244
7420
|
let serverUrl = "";
|
|
@@ -7459,11 +7635,18 @@ var DaemonCore = class {
|
|
|
7459
7635
|
if (!this.options.localTrace) return false;
|
|
7460
7636
|
return process.env.SLOCK_DAEMON_LOCAL_TRACE !== "0";
|
|
7461
7637
|
}
|
|
7638
|
+
resolveTraceJitter() {
|
|
7639
|
+
const lockId = this.machineLock?.lockId;
|
|
7640
|
+
return lockId ? computeTraceJitter(lockId) : NO_JITTER;
|
|
7641
|
+
}
|
|
7462
7642
|
installLocalTraceSink(machineDir) {
|
|
7463
7643
|
if (!this.shouldEnableLocalTrace()) return;
|
|
7644
|
+
const jitter = this.resolveTraceJitter();
|
|
7464
7645
|
this.localTraceSink = new LocalRotatingTraceSink({
|
|
7465
7646
|
machineDir,
|
|
7466
7647
|
maxFileBytes: this.options.localTraceMaxFileBytes ?? readPositiveIntegerEnv3("SLOCK_DAEMON_TRACE_MAX_FILE_BYTES", 5 * 1024 * 1024),
|
|
7648
|
+
maxFileAgeMs: this.options.localTraceMaxFileAgeMs ?? readPositiveIntegerEnv3("SLOCK_DAEMON_TRACE_MAX_FILE_AGE_MS", 5 * 60 * 1e3),
|
|
7649
|
+
maxFileAgeJitterMs: jitter.maxFileAgeJitterMs,
|
|
7467
7650
|
maxFiles: this.options.localTraceMaxFiles ?? readPositiveIntegerEnv3("SLOCK_DAEMON_TRACE_MAX_FILES", 8)
|
|
7468
7651
|
});
|
|
7469
7652
|
this.tracer = new BasicTracer({
|
|
@@ -7474,15 +7657,16 @@ var DaemonCore = class {
|
|
|
7474
7657
|
installTraceBundleUploader(machineDir) {
|
|
7475
7658
|
if (!this.shouldEnableLocalTrace()) return;
|
|
7476
7659
|
if (this.traceBundleUploader) return;
|
|
7477
|
-
|
|
7478
|
-
|
|
7660
|
+
if (process.env.SLOCK_DAEMON_TRACE_UPLOAD_DISABLED === "1") return;
|
|
7661
|
+
const workerUrl = process.env.SLOCK_DAEMON_TRACE_UPLOAD_URL || DEFAULT_TRACE_UPLOAD_URL;
|
|
7479
7662
|
this.traceBundleUploader = new DaemonTraceBundleUploader({
|
|
7480
7663
|
machineDir,
|
|
7481
7664
|
serverUrl: this.options.serverUrl,
|
|
7482
7665
|
apiKey: this.options.apiKey,
|
|
7483
7666
|
workerUrl,
|
|
7484
7667
|
tracer: this.tracer,
|
|
7485
|
-
currentFileProvider: () => this.localTraceSink?.getCurrentFile() ?? null
|
|
7668
|
+
currentFileProvider: () => this.localTraceSink?.getCurrentFile() ?? null,
|
|
7669
|
+
lockId: this.machineLock?.lockId
|
|
7486
7670
|
});
|
|
7487
7671
|
this.traceBundleUploader.start();
|
|
7488
7672
|
}
|
package/dist/core.js
CHANGED
package/dist/index.js
CHANGED