@groundtrack/hooks 0.1.23 → 0.1.24

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.
@@ -1,7 +1,13 @@
1
- export declare const CANONICALIZATION_VERSION = 1;
1
+ export declare const CANONICALIZATION_VERSION = 2;
2
2
  export declare const CANONICAL_IMPORT_MAX_BYTES: number;
3
3
  export declare const CANONICAL_IMPORT_MAX_RECORD_BYTES: number;
4
4
  export declare const CANONICAL_IMPORT_MAX_ENTRIES = 25000;
5
+ /**
6
+ * Versions the server accepts. Version 2 fixed flag-style credential redaction
7
+ * (`--api-key value` no longer becomes `--api-key $2[REDACTED]`). Version 1 is
8
+ * retained so already-installed CLIs keep importing during rollout.
9
+ */
10
+ export type CanonicalSessionVersion = 1 | 2;
5
11
  export type SessionRecord = Record<string, unknown>;
6
12
  export type CanonicalSessionEntry = Readonly<{
7
13
  kind: "user_message" | "assistant_message" | "tool_call" | "tool_result";
@@ -10,7 +16,7 @@ export type CanonicalSessionEntry = Readonly<{
10
16
  }>;
11
17
  export type CanonicalSessionMetadata = Readonly<{
12
18
  type: "session";
13
- version: 1;
19
+ version: CanonicalSessionVersion;
14
20
  externalSessionId: string;
15
21
  repositoryUrl: string | null;
16
22
  repositoryBranch: string | null;
@@ -1,4 +1,4 @@
1
- export const CANONICALIZATION_VERSION = 1;
1
+ export const CANONICALIZATION_VERSION = 2;
2
2
  export const CANONICAL_IMPORT_MAX_BYTES = 50 * 1024 * 1024;
3
3
  export const CANONICAL_IMPORT_MAX_RECORD_BYTES = 4 * 1024 * 1024;
4
4
  export const CANONICAL_IMPORT_MAX_ENTRIES = 25_000;
@@ -1,4 +1,4 @@
1
- import { isSessionRecord, sessionString, } from "./canonical.js";
1
+ import { CANONICALIZATION_VERSION, isSessionRecord, sessionString, } from "./canonical.js";
2
2
  import { sessionImportFormatIdentity, } from "./format.js";
3
3
  import { containsInternalInstructionText, redactCredentialText, sanitizeSessionValue, sanitizeWorkingDirectory, } from "./redaction.js";
4
4
  const knownSkippedRecordTypes = new Set([
@@ -129,7 +129,7 @@ function normalizeMessage(record, entryBudget = Number.POSITIVE_INFINITY) {
129
129
  payload: {
130
130
  callId: sessionString(block.tool_use_id),
131
131
  output: result.output,
132
- ...(typeof block.is_error === "boolean" ? { isError: block.is_error } : {}),
132
+ ...(block.is_error === true ? { isError: true } : {}),
133
133
  },
134
134
  });
135
135
  }
@@ -210,7 +210,7 @@ export function createClaudeSessionNormalizer() {
210
210
  return null;
211
211
  return {
212
212
  type: "session",
213
- version: 1,
213
+ version: CANONICALIZATION_VERSION,
214
214
  externalSessionId: metadata.externalSessionId,
215
215
  repositoryUrl: null,
216
216
  repositoryBranch: metadata.repositoryBranch
@@ -1,5 +1,5 @@
1
1
  import { containsInternalInstructionText, redactCredentialText, sanitizeRepositoryUrl, sanitizeSessionValue, sanitizeWorkingDirectory, } from "./redaction.js";
2
- import { isSessionRecord, sessionString, } from "./canonical.js";
2
+ import { CANONICALIZATION_VERSION, isSessionRecord, sessionString, } from "./canonical.js";
3
3
  import { sessionImportFormatIdentity, } from "./format.js";
4
4
  function messageText(content) {
5
5
  if (!Array.isArray(content))
@@ -116,7 +116,7 @@ export function codexSessionMetadata(record) {
116
116
  const originator = sessionString(payload.originator);
117
117
  return {
118
118
  type: "session",
119
- version: 1,
119
+ version: CANONICALIZATION_VERSION,
120
120
  externalSessionId,
121
121
  repositoryUrl: sanitizeRepositoryUrl(git.repository_url),
122
122
  repositoryBranch: sessionString(git.branch),
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
- import { isSessionRecord, sessionString, } from "./canonical.js";
4
+ import { CANONICALIZATION_VERSION, isSessionRecord, sessionString, } from "./canonical.js";
5
5
  import { sessionImportFormatIdentity, } from "./format.js";
6
6
  import { containsInternalInstructionText, sanitizeSessionValue, sanitizeWorkingDirectory, } from "./redaction.js";
7
7
  function timestamp(value) {
@@ -245,7 +245,7 @@ export function createCursorSessionNormalizer(metadata) {
245
245
  canonicalMetadata: () => metadata
246
246
  ? {
247
247
  type: "session",
248
- version: 1,
248
+ version: CANONICALIZATION_VERSION,
249
249
  externalSessionId: metadata.externalSessionId,
250
250
  repositoryUrl: metadata.repositoryUrl,
251
251
  repositoryBranch: metadata.repositoryBranch,
@@ -1,4 +1,4 @@
1
- import { isSessionRecord, sessionString, } from "./canonical.js";
1
+ import { CANONICALIZATION_VERSION, isSessionRecord, sessionString, } from "./canonical.js";
2
2
  import { containsInternalInstructionText, redactCredentialText, sanitizeSessionValue, sanitizeWorkingDirectory, } from "./redaction.js";
3
3
  function unixMillisecondsDate(value) {
4
4
  if (!Number.isSafeInteger(value) || value < 0)
@@ -216,7 +216,7 @@ export function createOpenCodeSessionNormalizer(metadata) {
216
216
  canonicalMetadata: () => metadata
217
217
  ? {
218
218
  type: "session",
219
- version: 1,
219
+ version: CANONICALIZATION_VERSION,
220
220
  externalSessionId: metadata.externalSessionId,
221
221
  repositoryUrl: metadata.repositoryUrl,
222
222
  repositoryBranch: metadata.repositoryBranch,
@@ -21,7 +21,7 @@ export function redactCredentialText(value) {
21
21
  .replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g, "[REDACTED PRIVATE KEY]")
22
22
  .replace(/\b(authorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/gi, "$1[REDACTED]")
23
23
  .replace(/\b((?:[a-z0-9_-]*(?:api[_-]?key|access[_-]?key(?:[_-]?id)?|token|password|passwd|secret|private[_-]?key|credentials?|database[_-]?url))\s*[=:]\s*)[^\s,;]+/gi, "$1[REDACTED]")
24
- .replace(/(?:^|\s)((?:--)?(?:api-key|token|password|secret)\s+)[^\s,;]+/gi, "$1$2[REDACTED]")
24
+ .replace(/(^|\s)((?:--)?(?:api-key|token|password|secret)\s+)[^\s,;]+/gi, "$1$2[REDACTED]")
25
25
  .replace(/\b(?:gti_[A-Za-z]{32,}|sk-[A-Za-z0-9_-]{16,}|ghp_[A-Za-z0-9]{8,}|github_pat_[A-Za-z0-9_]{8,}|glpat-[A-Za-z0-9_-]{12,}|npm_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{12,}|(?:AKIA|ASIA)[A-Z0-9]{16}|AIza[A-Za-z0-9_-]{20,})\b/g, "[REDACTED]")
26
26
  .replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, "[REDACTED]")
27
27
  .replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^\s/:@]+:[^\s/@]+@/gi, "$1[REDACTED]@");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groundtrack/hooks",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Lifecycle hook utilities for Groundtrack MCP clients.",
5
5
  "keywords": [
6
6
  "claude-code",