@dsh-ray/assistant-delivery 0.3.4 → 0.3.5

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.
@@ -0,0 +1,24 @@
1
+ import { type Context } from '@deepseek-ai/cordis';
2
+ export interface DiagnosticStderrExporterOptions {
3
+ /** Custom sink for formatted lines; defaults to `process.stderr.write`. */
4
+ readonly write?: (line: string) => void;
5
+ /** Install even when `profileContext` is absent (for unit tests). */
6
+ readonly force?: boolean;
7
+ }
8
+ /**
9
+ * Redact secrets, tokens, keys, and URL credentials from runtime diagnostic log
10
+ * lines before writing to stderr/journald, while preserving local paths useful
11
+ * for operator troubleshooting.
12
+ */
13
+ export declare function redactDiagnosticSecrets(value: string): string;
14
+ /**
15
+ * Attach a Cordis-effect-owned `warn`/`error` exporter to `ctx.logger` so
16
+ * headless DSH profiles (which do not mount `cordis-plugin-logger-console`)
17
+ * emit runtime warnings and errors to `stderr`, making them visible in Linux
18
+ * `journalctl` / `dsh-ray logs` and macOS/Windows `*-host.error.log`.
19
+ *
20
+ * Deduplicated per `LoggerService` via a well-known symbol and automatically
21
+ * unregistered when `ctx` disposes.
22
+ */
23
+ export declare function installDiagnosticStderrExporter(ctx: Context, options?: DiagnosticStderrExporterOptions): (() => void) | undefined;
24
+ //# sourceMappingURL=stderr-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stderr-logger.d.ts","sourceRoot":"","sources":["../src/stderr-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,OAAO,EAA+B,MAAM,qBAAqB,CAAA;AAevF,MAAM,WAAW,+BAA+B;IAC9C,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,+BAAoC,GAC5C,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CA2C1B"}
@@ -0,0 +1,89 @@
1
+ import { Logger } from '@deepseek-ai/cordis';
2
+ const STDERR_EXPORTER_INSTALLED = Symbol.for('dsh-ray.stderr-diagnostic-exporter');
3
+ function stripControlChars(value) {
4
+ let out = '';
5
+ for (let i = 0; i < value.length; i += 1) {
6
+ const code = value.charCodeAt(i);
7
+ if (code === 0x09 || code === 0x0a || (code >= 0x20 && code !== 0x7f)) {
8
+ out += value[i];
9
+ }
10
+ }
11
+ return out;
12
+ }
13
+ /**
14
+ * Redact secrets, tokens, keys, and URL credentials from runtime diagnostic log
15
+ * lines before writing to stderr/journald, while preserving local paths useful
16
+ * for operator troubleshooting.
17
+ */
18
+ export function redactDiagnosticSecrets(value) {
19
+ return stripControlChars(value
20
+ .replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/giu, '[REDACTED_KEY]')
21
+ .replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^/\s@]+@/giu, '$1[REDACTED]@')
22
+ .replace(/([?&](?:token|api[_-]?key|key|secret|password|passwd|access[_-]?token|auth)=)[^&\s#]+/giu, '$1[REDACTED]')
23
+ .replace(/\b((?:proxy-)?authorization\s*[:=]\s*)(?:basic|bearer)\s+[^\s,;]+/giu, '$1[REDACTED]')
24
+ .replace(/\bBearer\s+[A-Za-z0-9._~+/=-]{4,}(?=$|[^A-Za-z0-9._~+/=-])/giu, 'Bearer [REDACTED]')
25
+ .replace(/(["']?(?:proxy[_-]?)?(?:api[_-]?key|access[_-]?key|private[_-]?key|auth(?:orization)?|bearer|credentials?|passwd|password|secret|session[_-]?(?:id|token)|token)["']?\s*[:=]\s*)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;}\]]+)/giu, '$1[REDACTED]')
26
+ .replace(/(?:^|(?<=[^A-Za-z0-9]))(?:github_pat_[A-Za-z0-9_]{12,}|gh[pousr]_[A-Za-z0-9]{12,}|(?:sk|xai|pk)[-_][A-Za-z0-9_-]{8,}|xox[bpoa]-[A-Za-z0-9-]{8,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,})(?=$|[^A-Za-z0-9_-])/gu, '[REDACTED]')
27
+ .replace(/\r\n?/gu, '\n'));
28
+ }
29
+ /**
30
+ * Attach a Cordis-effect-owned `warn`/`error` exporter to `ctx.logger` so
31
+ * headless DSH profiles (which do not mount `cordis-plugin-logger-console`)
32
+ * emit runtime warnings and errors to `stderr`, making them visible in Linux
33
+ * `journalctl` / `dsh-ray logs` and macOS/Windows `*-host.error.log`.
34
+ *
35
+ * Deduplicated per `LoggerService` via a well-known symbol and automatically
36
+ * unregistered when `ctx` disposes.
37
+ */
38
+ export function installDiagnosticStderrExporter(ctx, options = {}) {
39
+ if (options.force !== true && ctx.get('profileContext') === undefined)
40
+ return undefined;
41
+ const logger = ctx.logger;
42
+ if (typeof logger?.exporter !== 'function')
43
+ return undefined;
44
+ if (logger.exporters instanceof Map) {
45
+ for (const existing of logger.exporters.values()) {
46
+ if (existing[STDERR_EXPORTER_INSTALLED] === true) {
47
+ return undefined;
48
+ }
49
+ }
50
+ }
51
+ const write = options.write ?? ((line) => {
52
+ try {
53
+ process.stderr.write(line);
54
+ }
55
+ catch { }
56
+ });
57
+ const exporter = {
58
+ [STDERR_EXPORTER_INSTALLED]: true,
59
+ colors: false,
60
+ maxLength: 2048,
61
+ // Cordis levels: error = 0, warn = 1, info = 2, debug = 3.
62
+ levels: { default: 1 },
63
+ export(message) {
64
+ if (message.type !== 'warn' && message.type !== 'error')
65
+ return;
66
+ try {
67
+ const formatted = Logger.format(this, message);
68
+ const sanitized = redactDiagnosticSecrets(formatted);
69
+ const ts = Number.isFinite(message.ts) ? new Date(message.ts).toISOString() : new Date().toISOString();
70
+ const severity = message.type === 'error' ? 'ERROR' : 'WARN';
71
+ const scope = typeof message.name === 'string' && message.name.length > 0
72
+ ? stripControlChars(message.name)
73
+ : 'dsh';
74
+ write(`[${ts}] [${severity}] [${scope}] ${sanitized}\n`);
75
+ }
76
+ catch {
77
+ // Never allow diagnostic logging failures to disrupt runtime execution.
78
+ }
79
+ },
80
+ };
81
+ const dispose = logger.exporter(exporter);
82
+ return () => {
83
+ try {
84
+ dispose();
85
+ }
86
+ catch { }
87
+ };
88
+ }
89
+ //# sourceMappingURL=stderr-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stderr-logger.js","sourceRoot":"","sources":["../src/stderr-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6C,MAAM,qBAAqB,CAAA;AAEvF,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;AAElF,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACtE,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,iBAAiB,CACtB,KAAK;SACF,OAAO,CAAC,iFAAiF,EAAE,gBAAgB,CAAC;SAC5G,OAAO,CAAC,wCA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}
package/lib/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.3.4";
1
+ export declare const version = "0.3.5";
2
2
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '0.3.4';
1
+ export const version = '0.3.5';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-ray/assistant-delivery",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "A durable, policy-gated inbound/outbound message core for DeepSeek Harness.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,9 +51,9 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@deepseek-ai/schemastery": "3.19.0",
54
- "@dsh-ray/assistant-growth-contract": "0.3.4",
55
- "@dsh-ray/llm-route-capabilities": "0.3.4",
56
- "@dsh-ray/task-acceptance-contract": "0.3.4"
54
+ "@dsh-ray/assistant-growth-contract": "0.3.5",
55
+ "@dsh-ray/task-acceptance-contract": "0.3.5",
56
+ "@dsh-ray/llm-route-capabilities": "0.3.5"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@deepseek-ai/cordis": "^4.1.0",
@@ -168,12 +168,12 @@
168
168
  "vitest": "4.1.8",
169
169
  "@deepseek-ai/dsh-session-persistence": "0.2.2-rc.5",
170
170
  "@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.5",
171
- "@dsh-ray/assistant-automations": "0.3.4",
172
- "@dsh-ray/assistant-evaluation": "0.3.4",
173
- "@dsh-ray/assistant-evolution": "0.3.4",
174
- "@dsh-ray/assistant-goals": "0.3.4",
175
- "@dsh-ray/assistant-policy": "0.3.4",
176
- "@dsh-ray/assistant-verifier": "0.3.4"
171
+ "@dsh-ray/assistant-automations": "0.3.5",
172
+ "@dsh-ray/assistant-evaluation": "0.3.5",
173
+ "@dsh-ray/assistant-evolution": "0.3.5",
174
+ "@dsh-ray/assistant-policy": "0.3.5",
175
+ "@dsh-ray/assistant-goals": "0.3.5",
176
+ "@dsh-ray/assistant-verifier": "0.3.5"
177
177
  },
178
178
  "scripts": {
179
179
  "build": "tsc -p tsconfig.build.json",