@lore-co/core 0.2.38 → 0.2.40
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/auth-schemas.d.ts +16 -0
- package/dist/auth-schemas.d.ts.map +1 -1
- package/dist/auth-schemas.js +14 -0
- package/dist/auth-schemas.js.map +1 -1
- package/dist/connection-refresh.d.ts +91 -0
- package/dist/connection-refresh.d.ts.map +1 -0
- package/dist/connection-refresh.js +525 -0
- package/dist/connection-refresh.js.map +1 -0
- package/dist/guard-evaluation.d.ts +29 -0
- package/dist/guard-evaluation.d.ts.map +1 -1
- package/dist/guard-evaluation.js +174 -0
- package/dist/guard-evaluation.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/local-scope.d.ts +3 -0
- package/dist/local-scope.d.ts.map +1 -1
- package/dist/local-scope.js +8 -4
- package/dist/local-scope.js.map +1 -1
- package/dist/package-warnings.d.ts +63 -0
- package/dist/package-warnings.d.ts.map +1 -0
- package/dist/package-warnings.js +69 -0
- package/dist/package-warnings.js.map +1 -0
- package/dist/pilot-schemas.d.ts +3 -3
- package/dist/problem-reports.d.ts +352 -0
- package/dist/problem-reports.d.ts.map +1 -0
- package/dist/problem-reports.js +94 -0
- package/dist/problem-reports.js.map +1 -0
- package/dist/product-usage.d.ts +20 -3
- package/dist/product-usage.d.ts.map +1 -1
- package/dist/product-usage.js +12 -4
- package/dist/product-usage.js.map +1 -1
- package/dist/public-rule-text.d.ts +1 -1
- package/dist/public-rule-text.d.ts.map +1 -1
- package/dist/public-rule-text.js +1 -1
- package/dist/public-rule-text.js.map +1 -1
- package/dist/public-rules.d.ts +1 -1
- package/dist/public-rules.d.ts.map +1 -1
- package/dist/public-rules.js +36 -3
- package/dist/public-rules.js.map +1 -1
- package/dist/redaction.d.ts +7 -0
- package/dist/redaction.d.ts.map +1 -1
- package/dist/redaction.js +30 -0
- package/dist/redaction.js.map +1 -1
- package/dist/reliability-schemas.d.ts +13 -4
- package/dist/reliability-schemas.d.ts.map +1 -1
- package/dist/reliability-schemas.js +16 -3
- package/dist/reliability-schemas.js.map +1 -1
- package/dist/schemas.d.ts +2 -2
- package/dist/search-schemas.d.ts +1 -1
- package/dist/skill-context.d.ts +0 -3
- package/dist/skill-context.d.ts.map +1 -1
- package/dist/skill-context.js +2 -15
- package/dist/skill-context.js.map +1 -1
- package/dist/skill-folder.d.ts.map +1 -1
- package/dist/skill-folder.js +10 -5
- package/dist/skill-folder.js.map +1 -1
- package/dist/skill-secrets.d.ts +11 -0
- package/dist/skill-secrets.d.ts.map +1 -0
- package/dist/skill-secrets.js +263 -0
- package/dist/skill-secrets.js.map +1 -0
- package/dist/skills.d.ts +34 -5
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +127 -36
- package/dist/skills.js.map +1 -1
- package/dist/user-message.d.ts +2 -1
- package/dist/user-message.d.ts.map +1 -1
- package/dist/user-message.js +5 -3
- package/dist/user-message.js.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// The capture redactor errs toward redacting: a session may hold anything. Skills
|
|
2
|
+
// are reviewed text full of setup examples, so here each value the redactor hid
|
|
3
|
+
// is looked at again, and comes back only when it is plainly not a secret: a
|
|
4
|
+
// placeholder, a variable or environment-variable name, code, or prose. Anything
|
|
5
|
+
// not recognized, including whatever a new redactor rule hides, stays hidden.
|
|
6
|
+
//
|
|
7
|
+
// Copied beside the hook runtime in ~/.lore, so this file has no imports: each
|
|
8
|
+
// caller passes its own redactor, which is core's or the runtime's parity copy.
|
|
9
|
+
const TRAILING_PUNCTUATION = /[.,;:!?)\]}"'`*]+$/u;
|
|
10
|
+
const VOWELS = /[aeiouy]/gu;
|
|
11
|
+
const CONSONANT_RUN = /[^aeiouy]+/gu;
|
|
12
|
+
function isWordPart(part) {
|
|
13
|
+
// The redactor ignores tokens shorter than 8 characters, so short words are prose.
|
|
14
|
+
if (part.length < 8)
|
|
15
|
+
return true;
|
|
16
|
+
if (part.length > 16 || /^[a-f]+$/u.test(part))
|
|
17
|
+
return false;
|
|
18
|
+
const vowels = part.match(VOWELS)?.length ?? 0;
|
|
19
|
+
const longestConsonantRun = Math.max(0, ...(part.match(CONSONANT_RUN) ?? []).map(run => run.length));
|
|
20
|
+
return vowels / part.length >= 0.25 && longestConsonantRun <= 4;
|
|
21
|
+
}
|
|
22
|
+
export function isProseWord(token) {
|
|
23
|
+
const word = token.replace(TRAILING_PUNCTUATION, "");
|
|
24
|
+
if (!/^[a-z]+(?:-[a-z]+){0,2}$/u.test(word))
|
|
25
|
+
return false;
|
|
26
|
+
// A run of short hyphenated hex parts is still a hex token.
|
|
27
|
+
if (word.replace(/-/gu, "").length >= 8 && /^[a-f-]+$/u.test(word))
|
|
28
|
+
return false;
|
|
29
|
+
return word.split("-").every(isWordPart);
|
|
30
|
+
}
|
|
31
|
+
/** "Operations", "Multi-Turn", "EventProcessorClient", "--location", "text/image":
|
|
32
|
+
* what follows "Basic" in headings, SKU tables, and CLI flags. Base64 has no such shape. */
|
|
33
|
+
function isHeadingWord(token) {
|
|
34
|
+
const word = token.replace(TRAILING_PUNCTUATION, "");
|
|
35
|
+
if (/^--?[a-z]+(?:-[a-z]+)*$/u.test(word))
|
|
36
|
+
return true;
|
|
37
|
+
if (/^[a-z]+\/[a-z]+$/u.test(word))
|
|
38
|
+
return word.split("/").every(isProseWord);
|
|
39
|
+
if (!/^(?:[A-Z][a-z]{2,})+(?:-(?:[A-Z][a-z]{2,})+)?$/u.test(word))
|
|
40
|
+
return false;
|
|
41
|
+
return (word.match(/[A-Z][a-z]+/gu) ?? []).every(part => /[aeiouy]/u.test(part) && isProseWord(part.toLowerCase()));
|
|
42
|
+
}
|
|
43
|
+
// `your-api-key`, `YourSecurePassword123!`: people do not start a real secret with "your".
|
|
44
|
+
const YOUR_PLACEHOLDER = /^your[-_ a-z]+\d{0,4}!?$/iu;
|
|
45
|
+
// `build-placeholder`: a hyphenated value that says so.
|
|
46
|
+
const SAYS_PLACEHOLDER = /^(?:[a-z]+-)*(?:placeholder|example|changeme|dummy)(?:-[a-z]+)*$/iu;
|
|
47
|
+
// `mypassword`, `secret123`, `abc123`: only stock words, then at most a stock number.
|
|
48
|
+
const STOCK_WORDS = /^(?:my|the|some|new|secure|strong|example|sample|test|dummy|fake|placeholder|replace|change|changeme|me|here|this|value|api|key|keys|token|tokens|secret|secrets|password|passwd|pass|pwd|credential|credentials|auth|client|access|bearer|user|username|connection|string|abc|xyz|foo|bar|baz)+$/u;
|
|
49
|
+
const STOCK_NUMBER = /(?:12345|1234|123|456|789|1|2)?!?$/u;
|
|
50
|
+
// `ghp_xxx`, `xxxx`, `***`; `eyJ0eXAi...`, `postgres://...`: masked or cut short on purpose.
|
|
51
|
+
const MASKED = /^(?:\w+[-_])?(?:[xX]{3,}|\*{3,})$|^\*{3,}\\n/u;
|
|
52
|
+
const CUT_SHORT = /^\S{0,12}\.\.\.[)\]`]*$/u;
|
|
53
|
+
// A secret-store reference such as `secretref:db-password`, not the secret.
|
|
54
|
+
const STORE_REFERENCE = /^(?:secretref|keyvaultref):/u;
|
|
55
|
+
const TEMPLATE = /^(?:[A-Za-z.:/_-]{0,12}\$\{\S*|\$(?:\(\S*|[A-Za-z_][\w.:\\()-]*)|\{+[\w.()'[\]$ -]*\}*|%[\w%]+%?|\[[^\s]*\]?)$/u;
|
|
56
|
+
/** A value that says what belongs there instead of holding it. */
|
|
57
|
+
function isPlaceholder(raw, rest = "") {
|
|
58
|
+
const value = raw.replace(/^`+/u, "");
|
|
59
|
+
if (/^<[^<>]*>[.,;:!?)\]}`]*$/u.test(value) || (/^<[^<>]*$/u.test(value) && /^[^<>\n]{0,80}>/u.test(rest)))
|
|
60
|
+
return true;
|
|
61
|
+
if (TEMPLATE.test(value) || MASKED.test(value) || CUT_SHORT.test(value) || STORE_REFERENCE.test(value))
|
|
62
|
+
return true;
|
|
63
|
+
// The redactor keeps trailing dots out of what it hides.
|
|
64
|
+
if (value.length <= 12 && rest.startsWith("..."))
|
|
65
|
+
return true;
|
|
66
|
+
const trimmed = value.replace(/[.,;:?)\]}"'`*]+$/u, "");
|
|
67
|
+
if (trimmed.length > 64)
|
|
68
|
+
return false;
|
|
69
|
+
if (YOUR_PLACEHOLDER.test(trimmed) || SAYS_PLACEHOLDER.test(trimmed))
|
|
70
|
+
return true;
|
|
71
|
+
const words = trimmed.replace(STOCK_NUMBER, "").replace(/[-_ .]/gu, "").toLowerCase();
|
|
72
|
+
return words.length > 0 && STOCK_WORDS.test(words);
|
|
73
|
+
}
|
|
74
|
+
const NOT_A_VALUE = /^(?:none|null|nil|true|false|undefined|str|string|int|bool|boolean|bytes|required|optional|read|write|development|production|staging|await|new|async|lambda|function|if|not|return|this|self)$/iu;
|
|
75
|
+
const ENVIRONMENT_NAME = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]*[A-Z][A-Z0-9]*)+$/u;
|
|
76
|
+
/** `FIGMA_OAUTH_TOKEN`, `S3_ACCESS_KEY`. `A1B2_C3D4_E5F6` reads as a key, not a name. */
|
|
77
|
+
function isEnvironmentName(value) {
|
|
78
|
+
return ENVIRONMENT_NAME.test(value) && value.split("_").filter(part => /[0-9]/u.test(part)).length <= 1;
|
|
79
|
+
}
|
|
80
|
+
const CREDENTIAL_NOUN = /^(?:apikey|key|secret|token|password|passwd|credential|credentials|connectionstring|string|text|auth)$/u;
|
|
81
|
+
/** A name such as `blueprint_secret`, `SendGridApiKey`, or `_credential`: at most
|
|
82
|
+
* three words ending in the kind of thing it holds. Digits and hyphens rule it out. */
|
|
83
|
+
function isVariableName(value) {
|
|
84
|
+
if (!/^_*[A-Za-z][A-Za-z_]*$/u.test(value))
|
|
85
|
+
return false;
|
|
86
|
+
const words = value.replace(/_+/gu, " ").replace(/([a-z])([A-Z])/gu, "$1 $2").toLowerCase()
|
|
87
|
+
.replace(/\bapi key\b/u, "apikey").replace(/\bconnection string\b/u, "connectionstring").trim().split(" ");
|
|
88
|
+
return words.length <= 3 && CREDENTIAL_NOUN.test(words.at(-1) ?? "");
|
|
89
|
+
}
|
|
90
|
+
// `process.env.TOKEN`, `token.Token`, `DefaultAzureCredential()`, `os.environ[`, `Optional[str]`.
|
|
91
|
+
const CODE_EXPRESSION = /^[!&*]?[A-Za-z_$][A-Za-z_$]*(?:(?:\.|::|\?\.|->)[A-Za-z_$][A-Za-z_$]*)*(?:[([<].*|[!?])?$/u;
|
|
92
|
+
const CODE_MEMBER_OR_CALL = /(?:\.|::|\?\.|->|[([<])/u;
|
|
93
|
+
// The tail of `DeveloperToolsCredential::new(None)`: the redactor reads the first colon as a separator.
|
|
94
|
+
const PATH_TAIL = /^:[A-Za-z_]+(?:\(.*)?$/u;
|
|
95
|
+
// After `if not token:` or `Secret:`, the next line is usually code, another key, or a code fence. Anything else may be the value.
|
|
96
|
+
const NEXT_LINE_NOT_A_VALUE = /^(?:(?:raise|try|with|break|continue|return|for|if|else|elif|while|def|class|yield|pass)\b.*|[\w-]+:|`{3}.*)$/u;
|
|
97
|
+
const CODE_ASSIGNMENT = /(?:\$\w+|\b(?:let|const|var)\s+\w+)\s*=\s*$/u;
|
|
98
|
+
/** A quoted argument that could be the secret itself: `AzureKeyCredential("0a1b…")`. */
|
|
99
|
+
function hasSecretLiteral(line) {
|
|
100
|
+
return [...line.matchAll(/["'`]([^"'`\n]+)["'`]/gu)].some(([, literal = ""]) => {
|
|
101
|
+
if (/\s/u.test(literal) || /^[a-z+]+:\/\//u.test(literal) || isPlaceholder(literal))
|
|
102
|
+
return false;
|
|
103
|
+
const classes = [/[a-z]/u, /[A-Z]/u, /[0-9]/u, /[^A-Za-z0-9]/u].filter(kind => kind.test(literal)).length;
|
|
104
|
+
return /[0-9]/u.test(literal) && (literal.length >= 16 ? /[A-Za-z]/u.test(literal) : literal.length >= 8 && classes >= 3);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// `The access token is returned`, `API key is invalid`: a state, not a value.
|
|
108
|
+
const PROSE_SEPARATOR = /\s(?:is|was|equals?)\s+["'`]?$/iu;
|
|
109
|
+
const STATE_WORD = /^(?:[a-z]+-)*[a-z]+(?:ed|ing|able|ible)$|^(?:valid|invalid|not|never|only|still|also|now)$/u;
|
|
110
|
+
// `count-correct:token:cited→actual`: a table's notation, read as `token: value`.
|
|
111
|
+
const WORD_ARROW_WORD = /^[a-z]+→[a-z]+$/u;
|
|
112
|
+
// How much of the line after a value is read, so one huge line of values stays linear.
|
|
113
|
+
const MAX_REST = 1000;
|
|
114
|
+
// Parts of an Azure-style connection string that hold no secret.
|
|
115
|
+
const PUBLIC_CONNECTION_PART = /^(?:defaultendpointsprotocol|accountname|endpoint|endpointsuffix|ingestionendpoint|liveendpoint|applicationid|resourceid|sharedaccesskeyname|version|id)$/iu;
|
|
116
|
+
/** The redactor stops a value at `;`, so `AccountName=…` could be followed by a
|
|
117
|
+
* real `AccountKey=…`. Every part up to the next space has to be safe. */
|
|
118
|
+
function isSafeConnectionString(value, rest) {
|
|
119
|
+
if (!/^[A-Za-z]+=/u.test(value))
|
|
120
|
+
return false;
|
|
121
|
+
const tail = /^[^\s"'`]*/u.exec(rest)?.[0] ?? "";
|
|
122
|
+
// Too long to read to its end, so it can't be vouched for.
|
|
123
|
+
if (tail.length >= MAX_REST)
|
|
124
|
+
return false;
|
|
125
|
+
const whole = `${value}${tail}`;
|
|
126
|
+
return whole.split(";").filter(Boolean).every(part => {
|
|
127
|
+
const separator = part.indexOf("=");
|
|
128
|
+
if (separator < 1)
|
|
129
|
+
return false;
|
|
130
|
+
return PUBLIC_CONNECTION_PART.test(part.slice(0, separator)) || isPlaceholder(part.slice(separator + 1));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** `https://jwt.ms`, `postgres://user:pass@host/db`: a URL that holds no real password.
|
|
134
|
+
* A web URL with a path can carry the secret itself, as a webhook does. */
|
|
135
|
+
function isSafeUrl(value) {
|
|
136
|
+
if (/^https?:\/\/[\w.-]+\/?$/u.test(value))
|
|
137
|
+
return true;
|
|
138
|
+
if (/^https?:/u.test(value))
|
|
139
|
+
return false;
|
|
140
|
+
const url = /^[a-z][a-z+]*:\/\/(?:[^:@/\s]*:([^@/\s]+)@)?[^@\s]*$/u.exec(value);
|
|
141
|
+
return url !== null && (url[1] === undefined || isPlaceholder(url[1]));
|
|
142
|
+
}
|
|
143
|
+
const HARD_SECRET = /\[REDACTED:(?:API_KEY|JWT|PRIVATE_KEY|SECRET)\]/u;
|
|
144
|
+
function isSafeCredentialValue(hidden, before, rest, redact) {
|
|
145
|
+
// `${ghp_…}` is a real token inside placeholder syntax.
|
|
146
|
+
if (HARD_SECRET.test(redact(hidden)))
|
|
147
|
+
return false;
|
|
148
|
+
// A listing such as `token: "abc",` hides the quotes along with the value.
|
|
149
|
+
const unquoted = /^(["'])(.*)\1[);,]*$/u.exec(hidden)?.[2];
|
|
150
|
+
if (isPlaceholder(unquoted ?? hidden, rest))
|
|
151
|
+
return true;
|
|
152
|
+
const exact = unquoted ?? hidden;
|
|
153
|
+
const value = exact.replace(/^`+/u, "");
|
|
154
|
+
const word = value.replace(TRAILING_PUNCTUATION, "");
|
|
155
|
+
if (NOT_A_VALUE.test(word) || WORD_ARROW_WORD.test(word) || isEnvironmentName(word) || isVariableName(word) || isSafeUrl(word))
|
|
156
|
+
return true;
|
|
157
|
+
if (isSafeConnectionString(value, rest))
|
|
158
|
+
return true;
|
|
159
|
+
if (/\n\s*$/u.test(before) && (NEXT_LINE_NOT_A_VALUE.test(exact) || /^\s*=/u.test(rest)))
|
|
160
|
+
return true;
|
|
161
|
+
if (PROSE_SEPARATOR.test(before))
|
|
162
|
+
return STATE_WORD.test(word);
|
|
163
|
+
if (unquoted !== undefined || /["'`]$/u.test(before) || hasSecretLiteral(rest))
|
|
164
|
+
return false;
|
|
165
|
+
return (CODE_ASSIGNMENT.test(before) && !/\d/u.test(word)) || PATH_TAIL.test(word) || (CODE_EXPRESSION.test(word) && CODE_MEMBER_OR_CALL.test(word));
|
|
166
|
+
}
|
|
167
|
+
const AUTHORIZATION_LABEL = /auth(?:orization)?["'`]?\s*[:=]\s*["'`]?$/iu;
|
|
168
|
+
function isSafeAuthorization(hidden, before) {
|
|
169
|
+
// A Cookie header is always name=value; `cookie: { secure }` is an options object.
|
|
170
|
+
if (/cookie\s*:\s*$/iu.test(before))
|
|
171
|
+
return !hidden.includes("=") && !/^\S{16,}$/u.test(hidden.trim());
|
|
172
|
+
const token = /^(?:bearer|basic)\s+(\S+)$/iu.exec(hidden)?.[1];
|
|
173
|
+
if (token === undefined)
|
|
174
|
+
return false;
|
|
175
|
+
if (isPlaceholder(token.replace(/[,;"'`]+$/u, "")))
|
|
176
|
+
return true;
|
|
177
|
+
// A header says what follows it is a credential, however readable.
|
|
178
|
+
return !AUTHORIZATION_LABEL.test(before) && (isProseWord(token) || isHeadingWord(token));
|
|
179
|
+
}
|
|
180
|
+
// An SVG path's letters are all drawing commands; a random token's almost never are.
|
|
181
|
+
const SVG_PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.-]+$/u;
|
|
182
|
+
/** `eyJoYXNTZXNzaW9uIjpmYWxzZX0` is `{"hasSession":false}`: base64 JSON holding only flags and numbers. */
|
|
183
|
+
function isEncodedFlags(hidden) {
|
|
184
|
+
if (!/^eyJ[A-Za-z0-9_-]+={0,2}$/u.test(hidden))
|
|
185
|
+
return false;
|
|
186
|
+
try {
|
|
187
|
+
const decoded = JSON.parse(Buffer.from(hidden, "base64url").toString("utf8"));
|
|
188
|
+
return typeof decoded === "object" && decoded !== null && Object.values(decoded).every(value => typeof value === "boolean" || typeof value === "number");
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// `sk-xxxxxxxxxxxx`: a provider prefix over a masked tail.
|
|
195
|
+
const MASKED_PROVIDER_TOKEN = /^[A-Za-z_-]*[-_][xX*]{8,}$/u;
|
|
196
|
+
function isSafeHiddenText(kind, hidden, before, rest, redact) {
|
|
197
|
+
if (/^\[REDACTED(?::[A-Z_]+|_[A-Z_]+)?\]$/u.test(hidden))
|
|
198
|
+
return true;
|
|
199
|
+
if (kind === "AUTHORIZATION")
|
|
200
|
+
return isSafeAuthorization(hidden, before);
|
|
201
|
+
if (kind === "CREDENTIAL")
|
|
202
|
+
return isSafeCredentialValue(hidden, before, rest, redact);
|
|
203
|
+
if (kind === "PASSWORD")
|
|
204
|
+
return isPlaceholder(hidden);
|
|
205
|
+
if (kind === "API_KEY")
|
|
206
|
+
return MASKED_PROVIDER_TOKEN.test(hidden);
|
|
207
|
+
if (kind === "SECRET")
|
|
208
|
+
return SVG_PATH.test(hidden) || isEncodedFlags(hidden);
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
// The redactor rewrites "Bearer<space>token", so the scheme counts as part of what it hid.
|
|
212
|
+
const MARKER = /(?:\b(?:bearer|basic) (?=\[REDACTED:AUTHORIZATION\]))?\[REDACTED:([A-Z_]+)\]/giu;
|
|
213
|
+
/** Walk the redacted text against the original and restore each stretch it hid
|
|
214
|
+
* that is safe. Undefined when the two can't be lined up, so nothing is restored. */
|
|
215
|
+
function restoreSafeText(text, redacted, redact) {
|
|
216
|
+
const parts = [];
|
|
217
|
+
let from = 0, written = 0, kind, marker = "";
|
|
218
|
+
const settle = (end) => {
|
|
219
|
+
if (kind === undefined)
|
|
220
|
+
return "";
|
|
221
|
+
const hidden = text.slice(from, end);
|
|
222
|
+
return isSafeHiddenText(kind, hidden, text.slice(Math.max(0, from - 80), from), text.slice(end, end + MAX_REST).split("\n", 1)[0], redact) ? hidden : marker;
|
|
223
|
+
};
|
|
224
|
+
for (const match of redacted.matchAll(MARKER)) {
|
|
225
|
+
const literal = redacted.slice(written, match.index);
|
|
226
|
+
const at = text.indexOf(literal, from);
|
|
227
|
+
if (at < 0 || (kind === undefined && at !== from))
|
|
228
|
+
return undefined;
|
|
229
|
+
parts.push(settle(at), literal);
|
|
230
|
+
from = at + literal.length;
|
|
231
|
+
written = match.index + match[0].length;
|
|
232
|
+
kind = match[1];
|
|
233
|
+
marker = match[0];
|
|
234
|
+
}
|
|
235
|
+
const tail = redacted.slice(written);
|
|
236
|
+
if (!text.endsWith(tail) || text.length - tail.length < from)
|
|
237
|
+
return undefined;
|
|
238
|
+
parts.push(settle(text.length - tail.length), tail);
|
|
239
|
+
return parts.join("");
|
|
240
|
+
}
|
|
241
|
+
// Inline images and fonts are base64 by design, and a timestamp's "T" reads as mixed case to the redactor.
|
|
242
|
+
const BINARY_DATA_URI = /\bdata:(?:(?:image|font|audio|video)\/[\w.+-]+|application\/(?:pdf|(?:x-)?font-[\w.+-]+))(?:;[\w=.-]+)*;base64,[A-Za-z0-9+/]+={0,2}/gu;
|
|
243
|
+
const TIMESTAMP = /\b\d{4}-\d{2}-\d{2}T\d{2}[-:]\d{2}(?:[-:]\d{2}(?:\.\d+)?)?Z?\b/gu;
|
|
244
|
+
// Stands in for what's set aside, long enough that `password=<date>` is still hidden as a value.
|
|
245
|
+
const SET_ASIDE = /\uE000(?:data|date)(\d+)\uE001/gu;
|
|
246
|
+
/**
|
|
247
|
+
* Skill text with every real-looking secret hidden and everything else exact. It
|
|
248
|
+
* doesn't matter when a skill was added or what the check was then: this judges
|
|
249
|
+
* the text as it stands, with the redactor as it stands. Unchanged text means the
|
|
250
|
+
* skill holds no credential, so importing and delivering always agree.
|
|
251
|
+
*/
|
|
252
|
+
export function maskSkillSecrets(text, redact) {
|
|
253
|
+
const saved = [];
|
|
254
|
+
const setAside = (kind) => (value) => `\uE000${kind}${saved.push(value) - 1}\uE001`;
|
|
255
|
+
// Text that already holds the stand-in characters is judged as it is, which only hides more.
|
|
256
|
+
const checked = text.includes("\uE000") ? text : text.replace(BINARY_DATA_URI, setAside("data")).replace(TIMESTAMP, setAside("date"));
|
|
257
|
+
const redacted = redact(checked);
|
|
258
|
+
if (redacted === checked)
|
|
259
|
+
return text;
|
|
260
|
+
const masked = restoreSafeText(checked, redacted, redact) ?? redacted;
|
|
261
|
+
return saved.length ? masked.replace(SET_ASIDE, (standIn, index) => saved[Number(index)] ?? standIn) : masked;
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=skill-secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-secrets.js","sourceRoot":"","sources":["../src/skill-secrets.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,gFAAgF;AAChF,6EAA6E;AAC7E,iFAAiF;AACjF,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAIhF,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AACnD,MAAM,MAAM,GAAG,YAAY,CAAC;AAC5B,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC,SAAS,UAAU,CAAC,IAAY;IAC9B,mFAAmF;IACnF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACjC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAC/C,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACrG,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,IAAI,mBAAmB,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,2BAA2B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AC,IAAI,QAAQ,CAAC;IACtE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACxH,CAAC"}
|
package/dist/skills.d.ts
CHANGED
|
@@ -31,30 +31,49 @@ export declare const SkillDocumentSchema: z.ZodObject<{
|
|
|
31
31
|
}, z.core.$strict>;
|
|
32
32
|
export type SkillDocument = z.infer<typeof SkillDocumentSchema>;
|
|
33
33
|
export type SkillSource = z.infer<typeof SkillSourceSchema>;
|
|
34
|
-
export declare const MAX_SKILL_FILES =
|
|
34
|
+
export declare const MAX_SKILL_FILES = 500;
|
|
35
35
|
export declare const MAX_SKILL_FILE_BYTES: number;
|
|
36
36
|
export declare const MAX_SKILL_FOLDER_BYTES: number;
|
|
37
|
+
/** Room for a full skill folder as JSON: base64 and escaping make it larger than its files. */
|
|
38
|
+
export declare const MAX_SKILL_RESPONSE_BYTES: number;
|
|
39
|
+
export type SkillMediaKind = "image" | "font" | "pdf";
|
|
40
|
+
/** Whether a supporting file is an image, font, or PDF, by its name. */
|
|
41
|
+
export declare function skillMediaKind(path: string): SkillMediaKind | undefined;
|
|
42
|
+
export declare function encodeBase64(bytes: Uint8Array): string;
|
|
43
|
+
export declare function decodeBase64(text: string): Uint8Array;
|
|
37
44
|
/** Folders never imported with a skill, matching local SKILL.md discovery. */
|
|
38
45
|
export declare const SKIPPED_SKILL_FOLDERS: ReadonlySet<string>;
|
|
39
46
|
export declare const SkillFilePathSchema: z.ZodString;
|
|
40
47
|
export declare const SkillFileSchema: z.ZodObject<{
|
|
41
48
|
path: z.ZodString;
|
|
42
49
|
content: z.ZodString;
|
|
50
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
43
51
|
}, z.core.$strict>;
|
|
52
|
+
export type SkillFile = z.infer<typeof SkillFileSchema>;
|
|
53
|
+
/** The size of a supporting file on disk. */
|
|
54
|
+
export declare const skillFileBytes: (file: SkillFile) => number;
|
|
44
55
|
export declare const SkillFilesSchema: z.ZodArray<z.ZodObject<{
|
|
45
56
|
path: z.ZodString;
|
|
46
57
|
content: z.ZodString;
|
|
58
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
47
59
|
}, z.core.$strict>>;
|
|
48
|
-
export type SkillFile = z.infer<typeof SkillFileSchema>;
|
|
49
60
|
export declare const SkillFileEntrySchema: z.ZodObject<{
|
|
50
61
|
path: z.ZodString;
|
|
51
62
|
content: z.ZodString;
|
|
63
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
52
64
|
bytes: z.ZodNumber;
|
|
53
65
|
script: z.ZodBoolean;
|
|
54
66
|
}, z.core.$strict>;
|
|
55
67
|
export type SkillFileEntry = z.infer<typeof SkillFileEntrySchema>;
|
|
56
68
|
/** Code an agent could run. Shown to reviewers; Lore itself never runs it. */
|
|
57
69
|
export declare function isSkillScript(path: string, content: string): boolean;
|
|
70
|
+
/** Over what fit in a skill before Lore 0.2.39: 100 files, 2 MB in total. */
|
|
71
|
+
export declare function isLargeSkill(files: readonly SkillFile[]): boolean;
|
|
72
|
+
/** Clients before Lore 0.2.39 refuse a response with images, fonts, or PDFs, a
|
|
73
|
+
* file over 256 KB, or more than 8 MB in all. They're asked to update instead. */
|
|
74
|
+
export declare function needsCurrentSkillClient(files: readonly SkillFile[]): boolean;
|
|
75
|
+
/** The files to send or store, without the sizes and labels shown for review. */
|
|
76
|
+
export declare function skillFilesOf(entries: readonly SkillFileEntry[]): SkillFile[];
|
|
58
77
|
export declare function skillFileEntries(files: readonly SkillFile[]): SkillFileEntry[];
|
|
59
78
|
/** One digest for SKILL.md and every supporting file, so a review covers the
|
|
60
79
|
* whole folder. A skill without files keeps the SKILL.md digest it had before. */
|
|
@@ -68,10 +87,11 @@ export interface SkillFolderEntry {
|
|
|
68
87
|
/** Paths a folder import leaves out: hidden files, build output, and nested skills. */
|
|
69
88
|
export declare function skippedSkillPath(path: string, nestedSkillFolders?: readonly string[]): boolean;
|
|
70
89
|
/** Choose the files beside SKILL.md to import, before reading any of them, or
|
|
71
|
-
* name
|
|
72
|
-
* folders holding their own SKILL.md (another skill) are left out. */
|
|
90
|
+
* name every problem that stops the import at once. Only hidden files, build
|
|
91
|
+
* output, and folders holding their own SKILL.md (another skill) are left out. */
|
|
73
92
|
export declare function selectSkillFolder(entries: readonly SkillFolderEntry[]): string[];
|
|
74
|
-
/**
|
|
93
|
+
/** Read the selected files: text as text, images, fonts, and PDFs as base64.
|
|
94
|
+
* Anything else stops the import by name. */
|
|
75
95
|
export declare function readSkillFolder(files: readonly {
|
|
76
96
|
path: string;
|
|
77
97
|
bytes: Uint8Array;
|
|
@@ -209,6 +229,7 @@ export declare const PreviewSkillSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
209
229
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
210
230
|
path: z.ZodString;
|
|
211
231
|
content: z.ZodString;
|
|
232
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
212
233
|
}, z.core.$strict>>>;
|
|
213
234
|
}, z.core.$strict>]>;
|
|
214
235
|
export declare const PreviewSkillResponseSchema: z.ZodObject<{
|
|
@@ -231,6 +252,7 @@ export declare const PreviewSkillResponseSchema: z.ZodObject<{
|
|
|
231
252
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
232
253
|
path: z.ZodString;
|
|
233
254
|
content: z.ZodString;
|
|
255
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
234
256
|
bytes: z.ZodNumber;
|
|
235
257
|
script: z.ZodBoolean;
|
|
236
258
|
}, z.core.$strict>>>;
|
|
@@ -250,6 +272,7 @@ export declare const ImportSkillSchema: z.ZodObject<{
|
|
|
250
272
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
251
273
|
path: z.ZodString;
|
|
252
274
|
content: z.ZodString;
|
|
275
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
253
276
|
}, z.core.$strict>>>;
|
|
254
277
|
}, z.core.$strict>;
|
|
255
278
|
/**
|
|
@@ -271,6 +294,7 @@ export declare const UpdateSkillSchema: z.ZodObject<{
|
|
|
271
294
|
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
272
295
|
path: z.ZodString;
|
|
273
296
|
content: z.ZodString;
|
|
297
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
274
298
|
}, z.core.$strict>>>;
|
|
275
299
|
expectedVersion: z.ZodNumber;
|
|
276
300
|
}, z.core.$strict>;
|
|
@@ -292,6 +316,7 @@ export declare const SkillFilesResponseSchema: z.ZodObject<{
|
|
|
292
316
|
files: z.ZodArray<z.ZodObject<{
|
|
293
317
|
path: z.ZodString;
|
|
294
318
|
content: z.ZodString;
|
|
319
|
+
encoding: z.ZodOptional<z.ZodLiteral<"base64">>;
|
|
295
320
|
bytes: z.ZodNumber;
|
|
296
321
|
script: z.ZodBoolean;
|
|
297
322
|
}, z.core.$strict>>;
|
|
@@ -305,6 +330,10 @@ export declare const SetSkillEnabledSchema: z.ZodObject<{
|
|
|
305
330
|
export declare const SkillScopeSchema: z.ZodObject<{
|
|
306
331
|
repo: z.ZodOptional<z.ZodString>;
|
|
307
332
|
}, z.core.$strict>;
|
|
333
|
+
export declare const SkillFilesQuerySchema: z.ZodObject<{
|
|
334
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
335
|
+
include: z.ZodOptional<z.ZodLiteral<"all">>;
|
|
336
|
+
}, z.core.$strict>;
|
|
308
337
|
export declare const SkillParamsSchema: z.ZodObject<{
|
|
309
338
|
name: z.ZodString;
|
|
310
339
|
}, z.core.$strict>;
|
package/dist/skills.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceR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