@zero-gravity/zero-gravity 0.0.0-stage → 0.1.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -2
  4. package/THIRD-PARTY-NOTICES.md +100 -0
  5. package/dist/adv-context-SLTP32JQ.js +36 -0
  6. package/dist/advanced-EPLZB6DG.js +164 -0
  7. package/dist/agents-JYRQHH7R.js +181 -0
  8. package/dist/chat-AEHVCKXX.js +47 -0
  9. package/dist/chunk-2OH5KHWO.js +112 -0
  10. package/dist/chunk-2ZYSAYMJ.js +108 -0
  11. package/dist/chunk-4BZ4IXTO.js +161 -0
  12. package/dist/chunk-4ITJY25Z.js +144 -0
  13. package/dist/chunk-4JBLZQAQ.js +65 -0
  14. package/dist/chunk-6QLYRU3N.js +28 -0
  15. package/dist/chunk-7TACFVY2.js +57 -0
  16. package/dist/chunk-AY36KJTH.js +3023 -0
  17. package/dist/chunk-BJABQO7S.js +378 -0
  18. package/dist/chunk-C2GFK4JP.js +387 -0
  19. package/dist/chunk-CDC2K2KP.js +47 -0
  20. package/dist/chunk-DKCCXMSE.js +27 -0
  21. package/dist/chunk-FC3UOHOO.js +194 -0
  22. package/dist/chunk-FIASMDLX.js +216 -0
  23. package/dist/chunk-GMVDCQVW.js +88 -0
  24. package/dist/chunk-JQYZX56A.js +231 -0
  25. package/dist/chunk-JU5PGDOD.js +138 -0
  26. package/dist/chunk-JUZP5SXD.js +309 -0
  27. package/dist/chunk-KGA7VWQG.js +70 -0
  28. package/dist/chunk-L7VNR5LM.js +407 -0
  29. package/dist/chunk-LOSXCWHU.js +145 -0
  30. package/dist/chunk-NVC433AX.js +24 -0
  31. package/dist/chunk-QH27MDJM.js +248 -0
  32. package/dist/chunk-QUC5URWQ.js +708 -0
  33. package/dist/chunk-R2CPYTSP.js +31 -0
  34. package/dist/chunk-R5KQACGR.js +2833 -0
  35. package/dist/chunk-R6DONQKN.js +153 -0
  36. package/dist/chunk-RIX4S3J7.js +4747 -0
  37. package/dist/chunk-SZKAZ2VN.js +35 -0
  38. package/dist/chunk-T6DDNE3W.js +1338 -0
  39. package/dist/chunk-U4URD6TU.js +4605 -0
  40. package/dist/chunk-U5UIUB6L.js +51 -0
  41. package/dist/chunk-UMC77TR3.js +79 -0
  42. package/dist/chunk-UQURXFAE.js +80 -0
  43. package/dist/chunk-VBG7T7XY.js +1703 -0
  44. package/dist/chunk-VCCMJIAG.js +326 -0
  45. package/dist/chunk-VS375NYD.js +91 -0
  46. package/dist/chunk-WANZOLI5.js +1073 -0
  47. package/dist/chunk-WUF3TVAE.js +51 -0
  48. package/dist/chunk-XCWLFZSM.js +149 -0
  49. package/dist/chunk-YJEUXO5I.js +76 -0
  50. package/dist/chunk-YR6RCC6Y.js +894 -0
  51. package/dist/chunk-ZQFAX275.js +35 -0
  52. package/dist/config-ELG4FQ3K.js +30 -0
  53. package/dist/config-IEWRCG7R.js +50 -0
  54. package/dist/doctor-ZZC2D3RW.js +357 -0
  55. package/dist/ext-context-RIMZMEPB.js +37 -0
  56. package/dist/index.js +20 -0
  57. package/dist/init-UB3E47KM.js +22 -0
  58. package/dist/integrations-HW4VTLN4.js +183 -0
  59. package/dist/main-RAWWT22W.js +115 -0
  60. package/dist/mcp-SWD4SO35.js +232 -0
  61. package/dist/mcp-context-PM5FY665.js +28 -0
  62. package/dist/memory-QQ54GRCN.js +128 -0
  63. package/dist/memory-session-R6DGT6CS.js +14 -0
  64. package/dist/memory-summary-4P26B2ZY.js +18 -0
  65. package/dist/plugins-VUGTEUNV.js +166 -0
  66. package/dist/providers-O3WOVP5Q.js +417 -0
  67. package/dist/report-DDIZ6BLF.js +28 -0
  68. package/dist/sec-context-VQHW6TOZ.js +15 -0
  69. package/dist/security-SAYW4LU4.js +95 -0
  70. package/dist/sessions-CL6CRNQL.js +160 -0
  71. package/dist/skills-7KDGTTKX.js +126 -0
  72. package/dist/version-6E6A23B3.js +13 -0
  73. package/package.json +70 -4
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/redact.ts
4
+ var SECRET_VALUE_PATTERNS = [
5
+ /\bsk-[A-Za-z0-9_-]{16,}/g,
6
+ // generic "sk-" style API keys
7
+ /\bgh[pousr]_[A-Za-z0-9]{20,}/g,
8
+ // GitHub tokens
9
+ /\bAKIA[0-9A-Z]{16}\b/g,
10
+ // AWS access key id
11
+ /\bAIza[0-9A-Za-z_-]{30,}/g,
12
+ // Google API key
13
+ /\bxox[abprs]-[A-Za-z0-9-]{10,}/g,
14
+ // Slack tokens
15
+ /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/gi,
16
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
17
+ // PEM private keys (even when cut off)
18
+ /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,
19
+ // JSON web tokens
20
+ /\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{16,}/g,
21
+ // Stripe-style keys
22
+ /\bnpm_[A-Za-z0-9]{30,}/g,
23
+ // npm tokens
24
+ /\b(?:glpat|github_pat)_[A-Za-z0-9_-]{20,}/g,
25
+ // GitLab / fine-grained GitHub tokens
26
+ /(?<=:\/\/[^\s:@/]{1,100}:)[^\s@/]{3,200}(?=@)/g,
27
+ // password inside a URL: scheme://user:PASSWORD@host
28
+ /(?<=(?<![A-Za-z0-9])(?:password|passwd|pwd|secret|api[_-]?key|access[_-]?token|auth[_-]?token|client[_-]?secret)\s*[=:]\s*["']?)[^\s"',;&]{6,}/gi
29
+ // key=value assignments
30
+ ];
31
+ var SECRET_KEY_PATTERN = /(api[-_]?key|secret|token|passw(or)?d|credential|auth)/i;
32
+ function redactSecrets(text) {
33
+ let out = text;
34
+ for (const pattern of SECRET_VALUE_PATTERNS) out = out.replace(pattern, "[REDACTED]");
35
+ return out;
36
+ }
37
+ function looksLikeSecretValue(value) {
38
+ return SECRET_VALUE_PATTERNS.some((p) => {
39
+ p.lastIndex = 0;
40
+ return p.test(value);
41
+ });
42
+ }
43
+ function looksLikeSecretKey(key) {
44
+ return SECRET_KEY_PATTERN.test(key);
45
+ }
46
+
47
+ export {
48
+ redactSecrets,
49
+ looksLikeSecretValue,
50
+ looksLikeSecretKey
51
+ };
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/memory/memory-types.ts
4
+ import { z } from "zod";
5
+ var FORMAT_VERSION = 1;
6
+ var MEMORY_KINDS = ["preference", "convention", "decision", "instruction", "context", "summary"];
7
+ var iso = z.string().min(10).max(40);
8
+ var MemoryEntrySchema = z.object({
9
+ id: z.string().regex(/^[0-9a-f]{8}$/),
10
+ kind: z.enum(MEMORY_KINDS),
11
+ text: z.string().min(1).max(5e3),
12
+ tags: z.array(z.string().max(40)).max(10).default([]),
13
+ createdAt: iso,
14
+ updatedAt: iso,
15
+ source: z.enum(["user", "session"]).default("user"),
16
+ sessionId: z.string().max(80).optional(),
17
+ /** Hash of the normalised text; used to refuse duplicates. */
18
+ hash: z.string().min(8).max(64)
19
+ }).strict();
20
+ var MemoryFileSchema = z.object({
21
+ version: z.literal(FORMAT_VERSION),
22
+ scope: z.enum(["global", "project"]),
23
+ projectId: z.string().max(64).optional(),
24
+ projectPath: z.string().max(4096).optional(),
25
+ updatedAt: iso,
26
+ entries: z.array(MemoryEntrySchema).max(5e3)
27
+ }).strict();
28
+ var SESSION_STATUSES = ["active", "ended", "summarized"];
29
+ var SessionMetaSchema = z.object({
30
+ version: z.literal(FORMAT_VERSION),
31
+ id: z.string().regex(/^[A-Za-z0-9-]{8,64}$/),
32
+ title: z.string().min(1).max(200),
33
+ titleSource: z.enum(["auto", "user"]).default("auto"),
34
+ projectId: z.string().min(4).max(64),
35
+ projectPath: z.string().max(4096),
36
+ createdAt: iso,
37
+ lastActivityAt: iso,
38
+ status: z.enum(SESSION_STATUSES),
39
+ provider: z.string().max(80).nullable().default(null),
40
+ model: z.string().max(200).nullable().default(null),
41
+ messageCount: z.number().int().min(0).max(1e6),
42
+ /** True once the per-session message limit stopped further saving. */
43
+ truncated: z.boolean().default(false),
44
+ summaryAt: iso.nullable().default(null),
45
+ /** Project-relative files or notes the session referred to. Informational. */
46
+ contextRefs: z.array(z.string().max(300)).max(50).default([]),
47
+ origin: z.enum(["chat", "import"]).default("chat")
48
+ }).strict();
49
+ var StoredMessageSchema = z.object({
50
+ seq: z.number().int().min(1),
51
+ role: z.enum(["user", "assistant"]),
52
+ content: z.string().min(1).max(5e5),
53
+ at: iso
54
+ }).strict();
55
+ var SessionExportSchema = z.object({
56
+ format: z.literal("zg-session-export"),
57
+ version: z.literal(FORMAT_VERSION),
58
+ exportedAt: iso,
59
+ redacted: z.literal(true),
60
+ session: SessionMetaSchema,
61
+ summary: z.string().max(2e4).nullable(),
62
+ messages: z.array(StoredMessageSchema).max(1e5)
63
+ }).strict();
64
+ var MemoryError = class extends Error {
65
+ code;
66
+ hint;
67
+ constructor(code, message, hint) {
68
+ super(message);
69
+ this.name = "MemoryError";
70
+ this.code = code;
71
+ this.hint = hint;
72
+ }
73
+ };
74
+
75
+ // src/memory/memory-policy.ts
76
+ import { createHash } from "crypto";
77
+ var PATTERNS = [
78
+ { name: "private key", re: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----|$)/g },
79
+ { name: "API key", re: /\bsk-[A-Za-z0-9_-]{16,}/g },
80
+ { name: "API key", re: /\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{16,}/g },
81
+ { name: "GitHub token", re: /\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})/g },
82
+ { name: "GitLab token", re: /\bglpat-[A-Za-z0-9_-]{16,}/g },
83
+ { name: "npm token", re: /\bnpm_[A-Za-z0-9]{30,}/g },
84
+ { name: "AWS access key", re: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g },
85
+ { name: "Google API key", re: /\bAIza[0-9A-Za-z_-]{30,}/g },
86
+ { name: "Slack token", re: /\bxox[abprs]-[A-Za-z0-9-]{10,}/g },
87
+ { name: "bearer token", re: /\bBearer\s+[A-Za-z0-9._~+/=-]{16,}/gi },
88
+ { name: "JSON web token", re: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g },
89
+ { name: "credentials in a URL", re: /\b[a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:[^\s/@]+@[^\s/]+/gi },
90
+ { name: "password or token assignment", re: /\b(?:pass(?:word|wd)?|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key|auth(?:orization)?|credential)s?\b["']?\s*[:=]\s*["']?[^\s"',;]{6,}/gi }
91
+ ];
92
+ function detectSensitive(text) {
93
+ const found = /* @__PURE__ */ new Map();
94
+ for (const { name, re } of PATTERNS) {
95
+ re.lastIndex = 0;
96
+ const m = text.match(re);
97
+ if (m) found.set(name, (found.get(name) ?? 0) + m.length);
98
+ }
99
+ return [...found].map(([kind, count]) => ({ kind, count }));
100
+ }
101
+ function redactSensitive(text) {
102
+ let out = text;
103
+ for (const { re } of PATTERNS) out = out.replace(re, "[REDACTED]");
104
+ return out;
105
+ }
106
+ function normaliseText(text) {
107
+ return text.normalize("NFC").replace(/\s+/g, " ").trim();
108
+ }
109
+ function textHash(text) {
110
+ return createHash("sha256").update(normaliseText(text).toLowerCase()).digest("hex").slice(0, 32);
111
+ }
112
+ function cleanText(text) {
113
+ return text.normalize("NFC").replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f‪-‮⁦-⁩]/g, "").replace(/\r\n?/g, "\n").trim();
114
+ }
115
+ function checkEntryText(raw, limits) {
116
+ const text = cleanText(raw);
117
+ if (text === "") throw new MemoryError("invalid", "A memory entry cannot be empty.");
118
+ if (text.length > limits.maxEntryChars) throw new MemoryError("invalid", `That entry is ${text.length} characters; the limit is ${limits.maxEntryChars} (memory.maxEntryChars).`, "Keep entries short and specific.");
119
+ const found = detectSensitive(text);
120
+ if (found.length > 0) {
121
+ throw new MemoryError("sensitive", `That text looks like it contains sensitive information (${found.map((f) => f.kind).join(", ")}), so it was not saved.`, "Memory never stores passwords, keys, tokens or credentials. Remove the secret and save the rest. Detection is pattern-based and not perfect: you are responsible for what you save.");
122
+ }
123
+ return text;
124
+ }
125
+ function parseKind(raw) {
126
+ const k = (raw ?? "context").toLowerCase();
127
+ if (!MEMORY_KINDS.includes(k)) throw new MemoryError("invalid", `Unknown kind "${raw}". Use one of: ${MEMORY_KINDS.join(", ")}.`);
128
+ return k;
129
+ }
130
+ function findDuplicate(entries, text, exceptId) {
131
+ const h = textHash(text);
132
+ return entries.find((e) => e.hash === h && e.id !== exceptId);
133
+ }
134
+
135
+ export {
136
+ FORMAT_VERSION,
137
+ MEMORY_KINDS,
138
+ MemoryFileSchema,
139
+ SessionMetaSchema,
140
+ StoredMessageSchema,
141
+ SessionExportSchema,
142
+ MemoryError,
143
+ redactSensitive,
144
+ textHash,
145
+ cleanText,
146
+ checkEntryText,
147
+ parseKind,
148
+ findDuplicate
149
+ };
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/utils/text.ts
4
+ function sanitizeForDisplay(text) {
5
+ let out = "";
6
+ for (const ch of text.replace(/\r\n?/g, "\n")) {
7
+ const code = ch.codePointAt(0) ?? 0;
8
+ if (ch === "\n") out += ch;
9
+ else if (ch === " ") out += " ";
10
+ else if (code < 32 || code >= 127 && code <= 159) continue;
11
+ else out += ch;
12
+ }
13
+ return out;
14
+ }
15
+ function wrapText(text, width) {
16
+ const limit = Math.max(8, Math.floor(width));
17
+ const lines = [];
18
+ for (const paragraph of text.split("\n")) {
19
+ if (paragraph.trim() === "") {
20
+ lines.push("");
21
+ continue;
22
+ }
23
+ let current = "";
24
+ for (const word of paragraph.split(/\s+/).filter(Boolean)) {
25
+ let w = word;
26
+ while (w.length > limit) {
27
+ if (current) {
28
+ lines.push(current);
29
+ current = "";
30
+ }
31
+ lines.push(w.slice(0, limit));
32
+ w = w.slice(limit);
33
+ }
34
+ if (current === "") current = w;
35
+ else if (current.length + 1 + w.length <= limit) current += ` ${w}`;
36
+ else {
37
+ lines.push(current);
38
+ current = w;
39
+ }
40
+ }
41
+ if (current) lines.push(current);
42
+ }
43
+ return lines;
44
+ }
45
+ function truncate(text, max, ellipsis = "\u2026") {
46
+ const flat = text.replace(/\s+/g, " ").trim();
47
+ if (flat.length <= max) return flat;
48
+ return `${flat.slice(0, Math.max(0, max - ellipsis.length))}${ellipsis}`;
49
+ }
50
+ function pad2(n) {
51
+ return String(n).padStart(2, "0");
52
+ }
53
+ function formatClock(date) {
54
+ return `${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
55
+ }
56
+ function formatDateTime(date) {
57
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${formatClock(date)}:${pad2(date.getSeconds())}`;
58
+ }
59
+ function formatDuration(ms) {
60
+ const s = Math.max(0, Math.floor(ms / 1e3));
61
+ if (s < 5) return "just now";
62
+ if (s < 60) return `${s}s`;
63
+ const m = Math.floor(s / 60);
64
+ if (m < 60) return `${m}m ${s % 60}s`;
65
+ const h = Math.floor(m / 60);
66
+ return `${h}h ${m % 60}m`;
67
+ }
68
+
69
+ export {
70
+ sanitizeForDisplay,
71
+ wrapText,
72
+ truncate,
73
+ formatClock,
74
+ formatDateTime,
75
+ formatDuration
76
+ };