openmates 0.27.0-alpha.20 → 0.27.0-alpha.21
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-VFPYXPEU.js → chunk-UIW7XY2C.js} +433 -356
- package/dist/{cli-D6LLx3BR.d.ts → cli-C2G3DpGo.d.ts} +32 -11
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/fixtures/privacy-runtime/linux-arm64/libggml-base.so +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml-base.so.0 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml-base.so.0.15.1 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml-cpu.so +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml-cpu.so.0 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml-cpu.so.0.15.1 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml.so +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml.so.0 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/libggml.so.0.15.1 +0 -0
- package/fixtures/privacy-runtime/linux-arm64/manifest.json +9 -9
- package/package.json +1 -1
|
@@ -194,8 +194,8 @@ import { chmodSync, closeSync, fsyncSync, mkdirSync, openSync, readFileSync, ren
|
|
|
194
194
|
import { join } from "path";
|
|
195
195
|
var digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
196
196
|
var shortenTaskText = (value, length) => {
|
|
197
|
-
const
|
|
198
|
-
return
|
|
197
|
+
const text6 = value.replace(/\s+/g, " ").trim();
|
|
198
|
+
return text6.length <= length ? text6 : `${text6.slice(0, length - 1)}\u2026`;
|
|
199
199
|
};
|
|
200
200
|
function atomicPrivateFile(path2, content) {
|
|
201
201
|
const temporary = `${path2}.${randomUUID()}.tmp`;
|
|
@@ -403,7 +403,7 @@ async function lockTaskDeliveryRecord(directory, id) {
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
// src/taskMutationDelivery.ts
|
|
406
|
-
var digest2 = (
|
|
406
|
+
var digest2 = (text6) => createHash3("sha256").update(text6).digest("hex");
|
|
407
407
|
var stable = (value) => JSON.stringify(value, (_key, item) => item && !Array.isArray(item) && typeof item === "object" ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
|
|
408
408
|
function reconcileMutation(mutation, current) {
|
|
409
409
|
if (mutation.kind === "delete") {
|
|
@@ -576,9 +576,9 @@ function collectGeneratedFiles(value) {
|
|
|
576
576
|
const filename = suppliedName ? safeName(suppliedName) : `openmates-${safeName(assetId ?? "generated")}.${extension}`;
|
|
577
577
|
files.push({ url, filename, assetId });
|
|
578
578
|
};
|
|
579
|
-
const
|
|
579
|
+
const visit2 = (node) => {
|
|
580
580
|
if (Array.isArray(node)) {
|
|
581
|
-
node.forEach(
|
|
581
|
+
node.forEach(visit2);
|
|
582
582
|
return;
|
|
583
583
|
}
|
|
584
584
|
const data = record(node);
|
|
@@ -596,9 +596,9 @@ function collectGeneratedFiles(value) {
|
|
|
596
596
|
if (meta && text(meta.download_url)) add(meta, data, text(meta.variant) ?? "original");
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
|
-
for (const field of RESULT_FIELDS) if (data[field] !== void 0)
|
|
599
|
+
for (const field of RESULT_FIELDS) if (data[field] !== void 0) visit2(data[field]);
|
|
600
600
|
};
|
|
601
|
-
|
|
601
|
+
visit2(value);
|
|
602
602
|
return files;
|
|
603
603
|
}
|
|
604
604
|
function fetchGeneratedFile(url) {
|
|
@@ -766,10 +766,10 @@ function assertCodexClaimCaller(threadId, currentThread = process.env.CODEX_THRE
|
|
|
766
766
|
}
|
|
767
767
|
|
|
768
768
|
// ../secret-scanner/src/identifierRanges.ts
|
|
769
|
-
function codingIdentifierRanges(
|
|
769
|
+
function codingIdentifierRanges(text6) {
|
|
770
770
|
const ranges = [];
|
|
771
771
|
const identifiers2 = /\b[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}\b|\b[\da-f]{40,64}\b|\[[A-Z][A-Z\d_]*\]/gi;
|
|
772
|
-
for (const match of Array.from(
|
|
772
|
+
for (const match of Array.from(text6.matchAll(identifiers2))) {
|
|
773
773
|
ranges.push({ start: match.index, end: match.index + match[0].length });
|
|
774
774
|
}
|
|
775
775
|
return ranges;
|
|
@@ -1247,16 +1247,16 @@ var PII_TYPE_TO_CATEGORY = {
|
|
|
1247
1247
|
USER_AT_HOSTNAME: "user_at_hostname",
|
|
1248
1248
|
MAC_ADDRESS: "mac_addresses"
|
|
1249
1249
|
};
|
|
1250
|
-
function detectPII(
|
|
1250
|
+
function detectPII(text6, excludedIdsOrOptions = /* @__PURE__ */ new Set()) {
|
|
1251
1251
|
const options = excludedIdsOrOptions instanceof Set ? { excludedIds: excludedIdsOrOptions } : excludedIdsOrOptions;
|
|
1252
1252
|
const excludedIds = options.excludedIds ?? /* @__PURE__ */ new Set();
|
|
1253
1253
|
const disabledCategories = options.disabledCategories ?? /* @__PURE__ */ new Set();
|
|
1254
1254
|
const personalEntries = options.personalDataEntries ?? [];
|
|
1255
|
-
if (!
|
|
1255
|
+
if (!text6 || text6.length < MIN_PII_TEXT_LENGTH && personalEntries.length === 0)
|
|
1256
1256
|
return [];
|
|
1257
1257
|
const matches2 = [];
|
|
1258
1258
|
const coveredRanges = [];
|
|
1259
|
-
const identifierRanges = codingIdentifierRanges(
|
|
1259
|
+
const identifierRanges = codingIdentifierRanges(text6);
|
|
1260
1260
|
const typeCounts = {};
|
|
1261
1261
|
const hasExclusions = excludedIds.size > 0;
|
|
1262
1262
|
const hasDisabledCategories = disabledCategories.size > 0;
|
|
@@ -1264,14 +1264,14 @@ function detectPII(text5, excludedIdsOrOptions = /* @__PURE__ */ new Set()) {
|
|
|
1264
1264
|
const urlExclusionZones = [];
|
|
1265
1265
|
URL_EXCLUSION_REGEX.lastIndex = 0;
|
|
1266
1266
|
let urlMatch;
|
|
1267
|
-
while ((urlMatch = URL_EXCLUSION_REGEX.exec(
|
|
1267
|
+
while ((urlMatch = URL_EXCLUSION_REGEX.exec(text6)) !== null) {
|
|
1268
1268
|
urlExclusionZones.push({
|
|
1269
1269
|
start: urlMatch.index,
|
|
1270
1270
|
end: urlMatch.index + urlMatch[0].length
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
1273
|
const hasUrlExclusions = urlExclusionZones.length > 0;
|
|
1274
|
-
if (
|
|
1274
|
+
if (text6.length >= MIN_PII_TEXT_LENGTH) {
|
|
1275
1275
|
for (const pattern of PII_PATTERNS) {
|
|
1276
1276
|
if (hasDisabledCategories) {
|
|
1277
1277
|
const category = PII_TYPE_TO_CATEGORY[pattern.type];
|
|
@@ -1279,7 +1279,7 @@ function detectPII(text5, excludedIdsOrOptions = /* @__PURE__ */ new Set()) {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
pattern.regex.lastIndex = 0;
|
|
1281
1281
|
let regexMatch;
|
|
1282
|
-
while ((regexMatch = pattern.regex.exec(
|
|
1282
|
+
while ((regexMatch = pattern.regex.exec(text6)) !== null) {
|
|
1283
1283
|
const matchText = regexMatch[0];
|
|
1284
1284
|
const startIndex = regexMatch.index;
|
|
1285
1285
|
const endIndex = startIndex + matchText.length;
|
|
@@ -1325,7 +1325,7 @@ function detectPII(text5, excludedIdsOrOptions = /* @__PURE__ */ new Set()) {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
1327
|
for (const searchText of textsToSearch) {
|
|
1328
|
-
const lowerText =
|
|
1328
|
+
const lowerText = text6.toLowerCase();
|
|
1329
1329
|
const lowerSearch = searchText.toLowerCase();
|
|
1330
1330
|
let searchFrom = 0;
|
|
1331
1331
|
while (searchFrom < lowerText.length) {
|
|
@@ -1337,7 +1337,7 @@ function detectPII(text5, excludedIdsOrOptions = /* @__PURE__ */ new Set()) {
|
|
|
1337
1337
|
(range) => startIndex >= range.start && startIndex < range.end || endIndex > range.start && endIndex <= range.end || startIndex <= range.start && endIndex >= range.end
|
|
1338
1338
|
);
|
|
1339
1339
|
if (!overlaps) {
|
|
1340
|
-
const matchText =
|
|
1340
|
+
const matchText = text6.substring(startIndex, endIndex);
|
|
1341
1341
|
const matchId = `pii-PERSONAL_DATA-${entry.id}-${startIndex}`;
|
|
1342
1342
|
if (!hasExclusions || !excludedIds.has(matchId)) {
|
|
1343
1343
|
const placeholder = entry.replaceWith.startsWith("[") ? entry.replaceWith : `[${entry.replaceWith}]`;
|
|
@@ -1438,8 +1438,8 @@ var ProjectFilePrivacy = class {
|
|
|
1438
1438
|
}
|
|
1439
1439
|
if (this.values.size + this.conflicts.length > 1e4) fail("pii_mapping_limit");
|
|
1440
1440
|
}
|
|
1441
|
-
restoreText(
|
|
1442
|
-
return
|
|
1441
|
+
restoreText(text6) {
|
|
1442
|
+
return text6.replace(TOKEN, (token) => {
|
|
1443
1443
|
if (this.ambiguous.has(token)) fail("pii_mapping_ambiguous");
|
|
1444
1444
|
const mapping = this.values.get(token);
|
|
1445
1445
|
const customToken = this.options.detection?.personalDataEntries?.some((entry) => (entry.replaceWith.startsWith("[") ? entry.replaceWith : `[${entry.replaceWith}]`) === token);
|
|
@@ -1477,28 +1477,28 @@ var ProjectFilePrivacy = class {
|
|
|
1477
1477
|
this.addMappings([{ placeholder, original, type }]);
|
|
1478
1478
|
return placeholder;
|
|
1479
1479
|
}
|
|
1480
|
-
redactText(
|
|
1480
|
+
redactText(text6, enhanced = []) {
|
|
1481
1481
|
const ranges = [];
|
|
1482
|
-
const tokens = Array.from(
|
|
1482
|
+
const tokens = Array.from(text6.matchAll(TOKEN)).map((match) => ({ start: match.index, end: match.index + match[0].length }));
|
|
1483
1483
|
for (const range of tokens) {
|
|
1484
|
-
const literal =
|
|
1484
|
+
const literal = text6.slice(range.start, range.end);
|
|
1485
1485
|
if (!(this.options.preserveMappedTokens && this.values.has(literal)) && (this.values.has(literal) || GENERATED_TOKEN.test(literal) || legacyToken(literal))) ranges.push(range);
|
|
1486
1486
|
}
|
|
1487
1487
|
const overlaps = (start, end) => [...tokens, ...ranges].some((r) => start < r.end && end > r.start);
|
|
1488
1488
|
for (const mapping of Array.from(this.values.values()).sort((a, b) => b.original.length - a.original.length)) {
|
|
1489
|
-
let start =
|
|
1489
|
+
let start = text6.indexOf(mapping.original);
|
|
1490
1490
|
while (start !== -1) {
|
|
1491
1491
|
const end = start + mapping.original.length;
|
|
1492
1492
|
if (!overlaps(start, end)) ranges.push({ start, end, type: mapping.type });
|
|
1493
|
-
start =
|
|
1493
|
+
start = text6.indexOf(mapping.original, end);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
1496
|
if (this.options.enabled !== false) {
|
|
1497
|
-
for (const match of detectPII(
|
|
1497
|
+
for (const match of detectPII(text6, this.options.detection)) {
|
|
1498
1498
|
if (!overlaps(match.startIndex, match.endIndex)) ranges.push({ start: match.startIndex, end: match.endIndex, type: match.type });
|
|
1499
1499
|
}
|
|
1500
1500
|
for (const range of enhanced) {
|
|
1501
|
-
if (!Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end <= range.start || range.end >
|
|
1501
|
+
if (!Number.isInteger(range.start) || !Number.isInteger(range.end) || range.start < 0 || range.end <= range.start || range.end > text6.length) fail("pii_invalid_semantic_range");
|
|
1502
1502
|
let fragments = [{ ...range }];
|
|
1503
1503
|
for (const shield of [...tokens, ...ranges]) fragments = fragments.flatMap((part) => {
|
|
1504
1504
|
if (part.start >= shield.end || part.end <= shield.start) return [part];
|
|
@@ -1513,30 +1513,30 @@ var ProjectFilePrivacy = class {
|
|
|
1513
1513
|
let cursor = 0;
|
|
1514
1514
|
let result = "";
|
|
1515
1515
|
for (const range of ranges.sort((a, b) => a.start - b.start)) {
|
|
1516
|
-
result +=
|
|
1517
|
-
result +=
|
|
1516
|
+
result += text6.slice(cursor, range.start);
|
|
1517
|
+
result += text6.slice(range.start, range.end).split(/(\r?\n)/).map((part) => !part || /^(?:\r?\n)$/.test(part) ? part : this.token(part, range.type)).join("");
|
|
1518
1518
|
cursor = range.end;
|
|
1519
1519
|
}
|
|
1520
|
-
return result +
|
|
1520
|
+
return result + text6.slice(cursor);
|
|
1521
1521
|
}
|
|
1522
1522
|
async redactResult(value) {
|
|
1523
|
-
const
|
|
1523
|
+
const visit2 = async (item) => {
|
|
1524
1524
|
if (typeof item === "string") return this.redactText(item, this.options.enabled !== false && this.options.detectEnhanced ? await this.options.detectEnhanced(item) : []);
|
|
1525
1525
|
if (Array.isArray(item)) {
|
|
1526
1526
|
const result2 = [];
|
|
1527
|
-
for (const child of item) result2.push(await
|
|
1527
|
+
for (const child of item) result2.push(await visit2(child));
|
|
1528
1528
|
return result2;
|
|
1529
1529
|
}
|
|
1530
1530
|
if (item && typeof item === "object") {
|
|
1531
1531
|
const result2 = {};
|
|
1532
1532
|
for (const [key, child] of Object.entries(item)) {
|
|
1533
|
-
result2[key] = ["expected_base", "content_hash", "proposal_commitment"].includes(key) ? child : await
|
|
1533
|
+
result2[key] = ["expected_base", "content_hash", "proposal_commitment"].includes(key) ? child : await visit2(child);
|
|
1534
1534
|
}
|
|
1535
1535
|
return result2;
|
|
1536
1536
|
}
|
|
1537
1537
|
return item;
|
|
1538
1538
|
};
|
|
1539
|
-
const result = await
|
|
1539
|
+
const result = await visit2(value);
|
|
1540
1540
|
const save = this.savePending.catch(() => {
|
|
1541
1541
|
}).then(() => this.options.save([...Array.from(this.values.values()), ...this.conflicts]));
|
|
1542
1542
|
this.savePending = save;
|
|
@@ -1556,26 +1556,26 @@ var LABELS = {
|
|
|
1556
1556
|
private_date: { type: "OTHER", category: "birthdays" },
|
|
1557
1557
|
private_url: { type: "OTHER", category: "private_urls" }
|
|
1558
1558
|
};
|
|
1559
|
-
function convertNativePrivacyRanges(
|
|
1559
|
+
function convertNativePrivacyRanges(text6, spans, disabled = /* @__PURE__ */ new Set()) {
|
|
1560
1560
|
const offsets = /* @__PURE__ */ new Map([[0, 0]]);
|
|
1561
1561
|
let bytes2 = 0;
|
|
1562
1562
|
let units = 0;
|
|
1563
|
-
for (const character of
|
|
1563
|
+
for (const character of text6) {
|
|
1564
1564
|
if (character.length === 1 && /[\uD800-\uDFFF]/.test(character)) throw privacyError("privacy_invalid_unicode");
|
|
1565
1565
|
bytes2 += Buffer.byteLength(character);
|
|
1566
1566
|
units += character.length;
|
|
1567
1567
|
offsets.set(bytes2, units);
|
|
1568
1568
|
}
|
|
1569
|
-
const protectedRanges = codingIdentifierRanges(
|
|
1569
|
+
const protectedRanges = codingIdentifierRanges(text6);
|
|
1570
1570
|
const result = [];
|
|
1571
1571
|
for (const span of spans) {
|
|
1572
1572
|
const label3 = LABELS[span.label];
|
|
1573
1573
|
const start = offsets.get(span.start), end = offsets.get(span.end);
|
|
1574
1574
|
if (!label3 || !Number.isInteger(span.start) || !Number.isInteger(span.end) || start === void 0 || end === void 0 || end <= start) throw privacyError("privacy_invalid_semantic_range");
|
|
1575
1575
|
if (disabled.has(label3.category) || span.label === "secret" && disabled.has("api_keys")) continue;
|
|
1576
|
-
const context =
|
|
1576
|
+
const context = text6.slice(Math.max(0, start - 60), Math.min(text6.length, end + 60));
|
|
1577
1577
|
const explicitSecret = /\b(?:password|secret|credential|api[_ -]?key|token)\b/i.test(context);
|
|
1578
|
-
if (protectedRanges.some((r) => start < r.end && end > r.start) && !(span.label === "secret" && explicitSecret && !
|
|
1578
|
+
if (protectedRanges.some((r) => start < r.end && end > r.start) && !(span.label === "secret" && explicitSecret && !text6.slice(start, end).startsWith("["))) continue;
|
|
1579
1579
|
if ((span.label === "private_date" || span.label === "account_number") && /\b(?:commit|sha|hash|build|release|branch|timestamp|version)\b/i.test(context) && !/\b(?:birth|birthday|born|dob|account|iban)\b/i.test(context)) continue;
|
|
1580
1580
|
result.push({ start, end, type: label3.type });
|
|
1581
1581
|
}
|
|
@@ -1591,30 +1591,30 @@ function privacyDetectionOptions(memories) {
|
|
|
1591
1591
|
})
|
|
1592
1592
|
} };
|
|
1593
1593
|
}
|
|
1594
|
-
async function scanEnhancedText(
|
|
1594
|
+
async function scanEnhancedText(text6, scope2, disabled = /* @__PURE__ */ new Set(), progress) {
|
|
1595
1595
|
const preferences = await readPrivacyPreferences();
|
|
1596
|
-
if (!
|
|
1596
|
+
if (!text6 || !enhancedScopeEnabled(preferences, scope2)) return [];
|
|
1597
1597
|
try {
|
|
1598
1598
|
await ensurePrivacyDaemon();
|
|
1599
1599
|
const ranges = [];
|
|
1600
|
-
for (let start = 0; start <
|
|
1601
|
-
let from = Math.max(0, start - 1024), end = Math.min(
|
|
1602
|
-
if (from > 0 && /[\uDC00-\uDFFF]/.test(
|
|
1603
|
-
if (end <
|
|
1604
|
-
progress?.(start,
|
|
1605
|
-
const window =
|
|
1600
|
+
for (let start = 0; start < text6.length; start += 8192) {
|
|
1601
|
+
let from = Math.max(0, start - 1024), end = Math.min(text6.length, start + 9216);
|
|
1602
|
+
if (from > 0 && /[\uDC00-\uDFFF]/.test(text6[from])) from--;
|
|
1603
|
+
if (end < text6.length && /[\uDC00-\uDFFF]/.test(text6[end])) end++;
|
|
1604
|
+
progress?.(start, text6.length);
|
|
1605
|
+
const window = text6.slice(from, end);
|
|
1606
1606
|
const result = await privacyRpc({ op: "scan", text: window, scope: privacyProfile(), idleSeconds: preferences.idleSeconds });
|
|
1607
1607
|
if (!Array.isArray(result.spans)) throw privacyError("privacy_worker_protocol_failed");
|
|
1608
1608
|
ranges.push(...convertNativePrivacyRanges(window, result.spans, disabled).map((r) => ({ ...r, start: r.start + from, end: r.end + from })));
|
|
1609
1609
|
}
|
|
1610
|
-
progress?.(
|
|
1610
|
+
progress?.(text6.length, text6.length);
|
|
1611
1611
|
return ranges;
|
|
1612
1612
|
} catch (error) {
|
|
1613
1613
|
await stopPrivacyDaemon();
|
|
1614
1614
|
throw error;
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
async function prepareCliMessagePrivacy(
|
|
1617
|
+
async function prepareCliMessagePrivacy(text6, memories, existing = [], scope2 = { kind: "message" }, progress) {
|
|
1618
1618
|
const options = privacyDetectionOptions(memories);
|
|
1619
1619
|
let mappings = existing;
|
|
1620
1620
|
const privacy = new ProjectFilePrivacy({
|
|
@@ -1626,7 +1626,7 @@ async function prepareCliMessagePrivacy(text5, memories, existing = [], scope2 =
|
|
|
1626
1626
|
},
|
|
1627
1627
|
detectEnhanced: (value) => scanEnhancedText(value, scope2, options.detection.disabledCategories, progress)
|
|
1628
1628
|
});
|
|
1629
|
-
const message = await privacy.redactResult(
|
|
1629
|
+
const message = await privacy.redactResult(text6);
|
|
1630
1630
|
return { message, mappings: mappings.map((mapping) => ({ ...mapping, type: mapping.type ?? "OTHER" })) };
|
|
1631
1631
|
}
|
|
1632
1632
|
|
|
@@ -1646,9 +1646,9 @@ function buildMemoryRequestMessage(params) {
|
|
|
1646
1646
|
if (!params.requestId || !params.userMessageId) {
|
|
1647
1647
|
throw new Error("Memory requests require stable request and user-message identities");
|
|
1648
1648
|
}
|
|
1649
|
-
const
|
|
1649
|
+
const keys2 = Array.from(new Set(params.requestedKeys)).sort();
|
|
1650
1650
|
const categories = [];
|
|
1651
|
-
for (const key of
|
|
1651
|
+
for (const key of keys2) {
|
|
1652
1652
|
const separator = key.indexOf("-");
|
|
1653
1653
|
if (separator <= 0 || separator === key.length - 1) {
|
|
1654
1654
|
throw new Error(`Invalid memory category key: ${key}`);
|
|
@@ -1664,7 +1664,7 @@ function buildMemoryRequestMessage(params) {
|
|
|
1664
1664
|
type: REQUEST_TYPE,
|
|
1665
1665
|
user_message_id: params.userMessageId,
|
|
1666
1666
|
request_id: params.requestId,
|
|
1667
|
-
requested_keys:
|
|
1667
|
+
requested_keys: keys2,
|
|
1668
1668
|
categories,
|
|
1669
1669
|
count_semantics_version: COUNT_SEMANTICS_VERSION
|
|
1670
1670
|
};
|
|
@@ -2025,7 +2025,7 @@ async function parseOpenCodeImportBuffer(payload, sourceName = "opencode-session
|
|
|
2025
2025
|
if (role !== "user" && role !== "assistant") continue;
|
|
2026
2026
|
const parts = Array.isArray(message.parts) ? message.parts.filter((part) => Boolean(part && typeof part === "object")) : [];
|
|
2027
2027
|
const textParts = parts.filter((part) => part.type === "text" && part.ignored !== true && typeof part.text === "string");
|
|
2028
|
-
const content = textParts.map((part) => String(part.text)).filter((
|
|
2028
|
+
const content = textParts.map((part) => String(part.text)).filter((text6) => text6.trim()).join("\n");
|
|
2029
2029
|
if (content.trim()) {
|
|
2030
2030
|
const time2 = messageInfo.time && typeof messageInfo.time === "object" ? messageInfo.time : {};
|
|
2031
2031
|
messages.push({
|
|
@@ -3102,7 +3102,7 @@ function matchesProjectSearchQuery(value, request) {
|
|
|
3102
3102
|
function matchesProjectSearchGlob(path2, glob) {
|
|
3103
3103
|
if (!glob) return true;
|
|
3104
3104
|
const memo = /* @__PURE__ */ new Map();
|
|
3105
|
-
const
|
|
3105
|
+
const visit2 = (pathIndex, globIndex) => {
|
|
3106
3106
|
const key = `${pathIndex}:${globIndex}`;
|
|
3107
3107
|
const cached = memo.get(key);
|
|
3108
3108
|
if (cached !== void 0) return cached;
|
|
@@ -3110,23 +3110,23 @@ function matchesProjectSearchGlob(path2, glob) {
|
|
|
3110
3110
|
if (globIndex === glob.length) {
|
|
3111
3111
|
matched = pathIndex === path2.length;
|
|
3112
3112
|
} else if (glob.startsWith("**/", globIndex)) {
|
|
3113
|
-
matched =
|
|
3113
|
+
matched = visit2(pathIndex, globIndex + 3);
|
|
3114
3114
|
for (let index = pathIndex; !matched && index < path2.length; index += 1) {
|
|
3115
|
-
if (path2[index] === "/") matched =
|
|
3115
|
+
if (path2[index] === "/") matched = visit2(index + 1, globIndex + 3);
|
|
3116
3116
|
}
|
|
3117
3117
|
} else if (glob.startsWith("**", globIndex)) {
|
|
3118
|
-
matched =
|
|
3118
|
+
matched = visit2(pathIndex, globIndex + 2) || pathIndex < path2.length && visit2(pathIndex + 1, globIndex);
|
|
3119
3119
|
} else if (glob[globIndex] === "*") {
|
|
3120
|
-
matched =
|
|
3120
|
+
matched = visit2(pathIndex, globIndex + 1) || pathIndex < path2.length && path2[pathIndex] !== "/" && visit2(pathIndex + 1, globIndex);
|
|
3121
3121
|
} else if (glob[globIndex] === "?") {
|
|
3122
|
-
matched = pathIndex < path2.length && path2[pathIndex] !== "/" &&
|
|
3122
|
+
matched = pathIndex < path2.length && path2[pathIndex] !== "/" && visit2(pathIndex + 1, globIndex + 1);
|
|
3123
3123
|
} else {
|
|
3124
|
-
matched = pathIndex < path2.length && path2[pathIndex] === glob[globIndex] &&
|
|
3124
|
+
matched = pathIndex < path2.length && path2[pathIndex] === glob[globIndex] && visit2(pathIndex + 1, globIndex + 1);
|
|
3125
3125
|
}
|
|
3126
3126
|
memo.set(key, matched);
|
|
3127
3127
|
return matched;
|
|
3128
3128
|
};
|
|
3129
|
-
return
|
|
3129
|
+
return visit2(0, 0);
|
|
3130
3130
|
}
|
|
3131
3131
|
function isProtectedProjectReadPath(value) {
|
|
3132
3132
|
const normalized = value.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
|
|
@@ -3832,8 +3832,8 @@ async function activateCliProjectFocus(client2, projectId, chatId, teamId, activ
|
|
|
3832
3832
|
const key = await client2.decryptProjectKey(detail.project, context);
|
|
3833
3833
|
if (!settings.encrypted_settings || settings.selection_required) throw new Error("Choose this Project's write policy in Project settings before starting work.");
|
|
3834
3834
|
if (isCurrent && !isCurrent()) return;
|
|
3835
|
-
const
|
|
3836
|
-
const focus =
|
|
3835
|
+
const text6 = await decryptWithAesGcmCombined(settings.encrypted_settings, key);
|
|
3836
|
+
const focus = text6 ? JSON.parse(text6).default_focus : void 0;
|
|
3837
3837
|
if (!focus?.focus_id || typeof focus.instructions !== "string") throw new Error("The Project's default focus is unavailable.");
|
|
3838
3838
|
if (isCurrent && !isCurrent()) return;
|
|
3839
3839
|
await client2.activateProjectFocus(projectId, {
|
|
@@ -3898,7 +3898,7 @@ function registerCliProjectFileExecutor(options) {
|
|
|
3898
3898
|
key: options.chatKey,
|
|
3899
3899
|
mappings: [...history.messages.flatMap((message) => message.piiMappings ?? []), ...options.piiMappings ?? []],
|
|
3900
3900
|
...detection,
|
|
3901
|
-
detectEnhanced: (
|
|
3901
|
+
detectEnhanced: (text6) => scanEnhancedText(text6, { kind: "project", projectId: job.project_id }, detection.detection.disabledCategories),
|
|
3902
3902
|
read: async () => {
|
|
3903
3903
|
try {
|
|
3904
3904
|
return await readFile(path2, "utf8");
|
|
@@ -4351,13 +4351,13 @@ var RemoteCommandOutputAccumulator = class {
|
|
|
4351
4351
|
return { text: this.#text, coverage: "full", sequence_gap: false, upstream_truncated: false, omitted_chars: 0 };
|
|
4352
4352
|
}
|
|
4353
4353
|
const half = Math.max(0, Math.floor((MAX_COMPLETION_CHARS - OMISSION_MARKER.length) / 2));
|
|
4354
|
-
const
|
|
4354
|
+
const text6 = this.#text.length <= MAX_COMPLETION_CHARS ? this.#text : `${this.#text.slice(0, half)}${OMISSION_MARKER}${this.#text.slice(-half)}`;
|
|
4355
4355
|
return {
|
|
4356
|
-
text:
|
|
4356
|
+
text: text6,
|
|
4357
4357
|
coverage: "selected_excerpt",
|
|
4358
4358
|
sequence_gap: this.#sequenceGap,
|
|
4359
4359
|
upstream_truncated: true,
|
|
4360
|
-
omitted_chars: Math.max(0, this.#inputChars -
|
|
4360
|
+
omitted_chars: Math.max(0, this.#inputChars - text6.length + (text6.includes(OMISSION_MARKER) ? OMISSION_MARKER.length : 0))
|
|
4361
4361
|
};
|
|
4362
4362
|
}
|
|
4363
4363
|
};
|
|
@@ -5372,8 +5372,8 @@ var OpenMatesWsClient = class {
|
|
|
5372
5372
|
if (!content || typeof content !== "object") return "";
|
|
5373
5373
|
try {
|
|
5374
5374
|
const root = content;
|
|
5375
|
-
const
|
|
5376
|
-
return typeof
|
|
5375
|
+
const text6 = root.content?.[0]?.content?.[0]?.text;
|
|
5376
|
+
return typeof text6 === "string" ? text6 : "";
|
|
5377
5377
|
} catch {
|
|
5378
5378
|
return "";
|
|
5379
5379
|
}
|
|
@@ -6025,21 +6025,98 @@ function registerChatContextEvents(options) {
|
|
|
6025
6025
|
}
|
|
6026
6026
|
|
|
6027
6027
|
// src/cliJevContext.ts
|
|
6028
|
-
import {
|
|
6028
|
+
import { parseDocument as parseDocument2, isAlias, visit } from "yaml";
|
|
6029
|
+
|
|
6030
|
+
// ../projectFocusDocument.ts
|
|
6031
|
+
function invalid() {
|
|
6032
|
+
throw new Error("invalid_focus_document");
|
|
6033
|
+
}
|
|
6034
|
+
function object(value) {
|
|
6035
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return invalid();
|
|
6036
|
+
return value;
|
|
6037
|
+
}
|
|
6038
|
+
function keys(value, allowed) {
|
|
6039
|
+
if (Object.keys(value).some((key) => !allowed.includes(key))) invalid();
|
|
6040
|
+
}
|
|
6041
|
+
function text4(value, limit) {
|
|
6042
|
+
if (typeof value !== "string" || !value.trim() || value.length > limit) return invalid();
|
|
6043
|
+
return value;
|
|
6044
|
+
}
|
|
6045
|
+
function identifier3(value, canonical) {
|
|
6046
|
+
const result = text4(value, canonical ? 64 : 80);
|
|
6047
|
+
if (!(canonical ? /^[a-z][a-z0-9_-]{0,63}$/ : /^[a-zA-Z0-9_-]{1,80}$/).test(result)) invalid();
|
|
6048
|
+
return result;
|
|
6049
|
+
}
|
|
6050
|
+
function unique(ids) {
|
|
6051
|
+
if (new Set(ids).size !== ids.length) invalid();
|
|
6052
|
+
}
|
|
6053
|
+
function projectFocusDocumentFromMetadata(metadata, body) {
|
|
6054
|
+
const header2 = object(metadata);
|
|
6055
|
+
keys(header2, ["name", "title", "description", "when_to_use", "preprocessor_hint", "preprocessor-hint", "phases_version", "phases"]);
|
|
6056
|
+
const names = [header2.name, header2.title].filter((value) => value !== void 0);
|
|
6057
|
+
const hints = [header2.when_to_use, header2.preprocessor_hint, header2["preprocessor-hint"]].filter((value) => value !== void 0);
|
|
6058
|
+
if (names.length !== 1 || hints.length !== 1) invalid();
|
|
6059
|
+
const common = {
|
|
6060
|
+
name: text4(names[0], 200),
|
|
6061
|
+
description: text4(header2.description, 2e3),
|
|
6062
|
+
when_to_use: text4(hints[0], 2e3),
|
|
6063
|
+
instructions: text4(body.trim(), 64e3)
|
|
6064
|
+
};
|
|
6065
|
+
const phases = header2.phases === void 0 ? [] : header2.phases;
|
|
6066
|
+
if (!Array.isArray(phases) || phases.length > 16) invalid();
|
|
6067
|
+
if (Object.prototype.hasOwnProperty.call(header2, "phases_version")) {
|
|
6068
|
+
if (header2.phases_version !== 1 || !phases.length) invalid();
|
|
6069
|
+
const canonical = phases.map((raw) => {
|
|
6070
|
+
const phase = object(raw);
|
|
6071
|
+
keys(phase, ["id", "title", "instructions", "requirements"]);
|
|
6072
|
+
const requirements = phase.requirements;
|
|
6073
|
+
if (!Array.isArray(requirements) || !requirements.length || requirements.length > 24) invalid();
|
|
6074
|
+
const gates = requirements.map((rawRequirement) => {
|
|
6075
|
+
const requirement = object(rawRequirement);
|
|
6076
|
+
keys(requirement, ["id", "text", "type"]);
|
|
6077
|
+
if (requirement.type !== void 0 && (typeof requirement.type !== "string" || !["semantic", "user_confirmation"].includes(requirement.type))) invalid();
|
|
6078
|
+
return {
|
|
6079
|
+
id: identifier3(requirement.id, true),
|
|
6080
|
+
text: text4(requirement.text, 4e3),
|
|
6081
|
+
...requirement.type === void 0 ? {} : { type: requirement.type }
|
|
6082
|
+
};
|
|
6083
|
+
});
|
|
6084
|
+
unique(gates.map((gate) => gate.id));
|
|
6085
|
+
return {
|
|
6086
|
+
id: identifier3(phase.id, true),
|
|
6087
|
+
title: text4(phase.title, 200),
|
|
6088
|
+
instructions: text4(phase.instructions, 16e3),
|
|
6089
|
+
requirements: gates
|
|
6090
|
+
};
|
|
6091
|
+
});
|
|
6092
|
+
unique(canonical.map((phase) => phase.id));
|
|
6093
|
+
return { ...common, phases_version: 1, phases: canonical };
|
|
6094
|
+
}
|
|
6095
|
+
const legacy = phases.map((raw) => {
|
|
6096
|
+
const phase = object(raw);
|
|
6097
|
+
keys(phase, ["id", "name", "instructions"]);
|
|
6098
|
+
return { id: identifier3(phase.id, false), name: text4(phase.name, 120), instructions: text4(phase.instructions, 16e3) };
|
|
6099
|
+
});
|
|
6100
|
+
unique(legacy.map((phase) => phase.id));
|
|
6101
|
+
return { ...common, phases: legacy };
|
|
6102
|
+
}
|
|
6103
|
+
|
|
6104
|
+
// src/cliJevContext.ts
|
|
6029
6105
|
import { createHash as createHash8 } from "crypto";
|
|
6030
6106
|
function parseFocusAuthoringDocument(document) {
|
|
6031
|
-
if (document.length > 96e3) throw new Error("
|
|
6032
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n
|
|
6033
|
-
if (!match) throw new Error("
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
return {
|
|
6041
|
-
}
|
|
6042
|
-
|
|
6107
|
+
if (document.length > 96e3) throw new Error("invalid_focus_document");
|
|
6108
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(document);
|
|
6109
|
+
if (!match) throw new Error("invalid_focus_document");
|
|
6110
|
+
try {
|
|
6111
|
+
const parsed = parseDocument2(match[1], { schema: "core", uniqueKeys: true });
|
|
6112
|
+
if (parsed.errors.length) throw new Error("invalid_focus_document");
|
|
6113
|
+
visit(parsed, (_key, node) => {
|
|
6114
|
+
if (isAlias(node)) throw new Error("invalid_focus_document");
|
|
6115
|
+
});
|
|
6116
|
+
return projectFocusDocumentFromMetadata(parsed.toJS({ maxAliasCount: 0 }), match[2]);
|
|
6117
|
+
} catch {
|
|
6118
|
+
throw new Error("invalid_focus_document");
|
|
6119
|
+
}
|
|
6043
6120
|
}
|
|
6044
6121
|
async function discoverCliProjectCandidates(client2, options) {
|
|
6045
6122
|
const records = (await client2.listProjects(options)).filter((record8) => !record8.archived).slice(0, 40);
|
|
@@ -6057,7 +6134,7 @@ async function discoverCliProjectCandidates(client2, options) {
|
|
|
6057
6134
|
}));
|
|
6058
6135
|
return entries.filter((entry) => entry !== null);
|
|
6059
6136
|
}
|
|
6060
|
-
async function loadActiveCliProjectContext(client2, chatId,
|
|
6137
|
+
async function loadActiveCliProjectContext(client2, chatId, text6) {
|
|
6061
6138
|
const active = await client2.getActiveProjectFocus(chatId);
|
|
6062
6139
|
if (!active) return {};
|
|
6063
6140
|
const options = { teamId: active.team_id, personal: !active.team_id };
|
|
@@ -6113,9 +6190,9 @@ async function loadActiveCliProjectContext(client2, chatId, text5) {
|
|
|
6113
6190
|
if (title && description) candidates.push({ kind: "folder", id: folder.folder_id, title: title.slice(0, 200), description: description.slice(0, 640), when_to_use: "", revision: revision(folder) });
|
|
6114
6191
|
}
|
|
6115
6192
|
let selected = [];
|
|
6116
|
-
if (
|
|
6193
|
+
if (text6?.trim() && candidates.length) selected = await client2.selectProjectContext(
|
|
6117
6194
|
active.project_id,
|
|
6118
|
-
{ chat_id: chatId, text:
|
|
6195
|
+
{ chat_id: chatId, text: text6.slice(0, 8e3), candidates: candidates.slice(0, 24) },
|
|
6119
6196
|
options
|
|
6120
6197
|
);
|
|
6121
6198
|
const specialistId = active.specialist_focus_id?.startsWith(`project-focus:${active.project_id}:`) ? active.specialist_focus_id.split(":")[2] : active.specialist_focus_id;
|
|
@@ -6260,7 +6337,7 @@ async function collectRelatedCliTaskContext(client2, chatId, options, records, n
|
|
|
6260
6337
|
}
|
|
6261
6338
|
return candidates;
|
|
6262
6339
|
}
|
|
6263
|
-
async function prepareCliJevContext(client2, chatId, options, supplied = {},
|
|
6340
|
+
async function prepareCliJevContext(client2, chatId, options, supplied = {}, text6) {
|
|
6264
6341
|
let candidates = [];
|
|
6265
6342
|
let active = {};
|
|
6266
6343
|
let tasks = [];
|
|
@@ -6271,7 +6348,7 @@ async function prepareCliJevContext(client2, chatId, options, supplied = {}, tex
|
|
|
6271
6348
|
candidates = value;
|
|
6272
6349
|
}).catch(() => {
|
|
6273
6350
|
}),
|
|
6274
|
-
loadActiveCliProjectContext(client2, chatId,
|
|
6351
|
+
loadActiveCliProjectContext(client2, chatId, text6).then((value) => {
|
|
6275
6352
|
active = value;
|
|
6276
6353
|
}).catch(() => {
|
|
6277
6354
|
}),
|
|
@@ -6476,8 +6553,8 @@ async function startCliProjectAuthoring(client2, recommendation, history) {
|
|
|
6476
6553
|
const key = await client2.decryptProjectKey(detail.project, options);
|
|
6477
6554
|
for (const item of detail.items.filter((item2) => item2.item_type === "workflow" && !item2.deleted_target_state)) {
|
|
6478
6555
|
if (await decryptWithAesGcmCombined(item.target_id_encrypted, key) !== recommendation.target_id) continue;
|
|
6479
|
-
const
|
|
6480
|
-
const metadata =
|
|
6556
|
+
const text6 = item.encrypted_metadata ? await decryptWithAesGcmCombined(item.encrypted_metadata, key) : null;
|
|
6557
|
+
const metadata = text6 ? JSON.parse(text6) : {};
|
|
6481
6558
|
if (metadata.remote_workflow_file && typeof metadata.remote_workflow_file === "object") remoteBinding = metadata.remote_workflow_file;
|
|
6482
6559
|
break;
|
|
6483
6560
|
}
|
|
@@ -7151,8 +7228,8 @@ function parseDelimitedLine(line, delimiter) {
|
|
|
7151
7228
|
cells2.push(current);
|
|
7152
7229
|
return cells2;
|
|
7153
7230
|
}
|
|
7154
|
-
function delimitedTextToMarkdownTable(
|
|
7155
|
-
const rows2 =
|
|
7231
|
+
function delimitedTextToMarkdownTable(text6, delimiter) {
|
|
7232
|
+
const rows2 = text6.split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.length > 0).map((line) => parseDelimitedLine(line, delimiter));
|
|
7156
7233
|
if (rows2.length === 0) return "";
|
|
7157
7234
|
const maxCols = Math.max(...rows2.map((row) => row.length));
|
|
7158
7235
|
const normalized = rows2.map((row) => {
|
|
@@ -7199,7 +7276,7 @@ async function docxBufferToHtml(buffer) {
|
|
|
7199
7276
|
const zip = await JSZip2.loadAsync(buffer);
|
|
7200
7277
|
const documentXml = await zip.file("word/document.xml")?.async("string");
|
|
7201
7278
|
if (!documentXml) return "";
|
|
7202
|
-
const paragraphs = getXmlBlocks(documentXml, "p").map(getTextFromDocxParagraph).map((
|
|
7279
|
+
const paragraphs = getXmlBlocks(documentXml, "p").map(getTextFromDocxParagraph).map((text6) => text6.trim()).filter(Boolean);
|
|
7203
7280
|
return paragraphs.map((paragraph) => `<p>${escapeHtml(paragraph)}</p>`).join("\n");
|
|
7204
7281
|
}
|
|
7205
7282
|
function columnLettersToIndex(letters) {
|
|
@@ -8038,8 +8115,8 @@ function splitLongParagraph(paragraph) {
|
|
|
8038
8115
|
if (remainder) chunks.push(remainder);
|
|
8039
8116
|
return chunks;
|
|
8040
8117
|
}
|
|
8041
|
-
function fallback(
|
|
8042
|
-
if (!language.toLowerCase().startsWith("de")) return
|
|
8118
|
+
function fallback(text6, language) {
|
|
8119
|
+
if (!language.toLowerCase().startsWith("de")) return text6;
|
|
8043
8120
|
const german = {
|
|
8044
8121
|
"Search results are available.": "Suchergebnisse sind verf\xFCgbar.",
|
|
8045
8122
|
"I used the News Search skill.": "Ich habe die News-Suche verwendet.",
|
|
@@ -8048,7 +8125,7 @@ function fallback(text5, language) {
|
|
|
8048
8125
|
"A code example is available.": "Ein Codebeispiel ist verf\xFCgbar.",
|
|
8049
8126
|
"A table is available.": "Eine Tabelle ist verf\xFCgbar."
|
|
8050
8127
|
};
|
|
8051
|
-
return german[
|
|
8128
|
+
return german[text6] ?? text6;
|
|
8052
8129
|
}
|
|
8053
8130
|
function projectFence(markdown, language) {
|
|
8054
8131
|
const body = markdown.replace(/^```[^\n]*\n|\n?```$/g, "").trim();
|
|
@@ -8130,8 +8207,8 @@ function rejectProtonCredentialFlags(argsOrFlags) {
|
|
|
8130
8207
|
throw new Error(`${rejected.split("=")[0]} is not allowed. Bridge credentials must be read privately from Proton Bridge or a hidden prompt.`);
|
|
8131
8208
|
}
|
|
8132
8209
|
}
|
|
8133
|
-
function redactProtonBridgeSecrets(
|
|
8134
|
-
return
|
|
8210
|
+
function redactProtonBridgeSecrets(text6) {
|
|
8211
|
+
return text6.replace(CREDENTIAL_VALUE_RE, "$1<redacted>");
|
|
8135
8212
|
}
|
|
8136
8213
|
function containsCredentialLikeField(value) {
|
|
8137
8214
|
return containsCredentialLikeKey(value);
|
|
@@ -8528,7 +8605,7 @@ async function searchProtonBridgeImap(credentials, arguments_) {
|
|
|
8528
8605
|
const limit = clampLimit(arguments_.limit);
|
|
8529
8606
|
const imap = await openTextSocket(credentials.imapHost, credentials.imapPort, IMAP_COMMAND_TIMEOUT_MS);
|
|
8530
8607
|
try {
|
|
8531
|
-
await imap.readUntil((
|
|
8608
|
+
await imap.readUntil((text6) => /^\* OK/im.test(text6));
|
|
8532
8609
|
await imap.command(`LOGIN ${quoteImap(credentials.imapUsername)} ${quoteImap(credentials.imapPassword)}`);
|
|
8533
8610
|
await imap.command(`SELECT ${quoteImap(mailbox)}`);
|
|
8534
8611
|
const searchResponse = await imap.command(buildImapSearchCommand({ query, startDate, endDate }));
|
|
@@ -8576,22 +8653,22 @@ async function sendProtonBridgeSmtp(credentials, payload) {
|
|
|
8576
8653
|
const messageId = `<om-${randomUUID7()}@local.openmates>`;
|
|
8577
8654
|
const smtp = await openTextSocket(credentials.smtpHost, credentials.smtpPort, SMTP_COMMAND_TIMEOUT_MS);
|
|
8578
8655
|
try {
|
|
8579
|
-
await smtp.readUntil((
|
|
8580
|
-
await smtp.rawCommand("EHLO openmates.local", (
|
|
8656
|
+
await smtp.readUntil((text6) => /^220[ -]/m.test(text6));
|
|
8657
|
+
await smtp.rawCommand("EHLO openmates.local", (text6) => /^250\s/m.test(text6), /^250[ -]/m);
|
|
8581
8658
|
const auth = Buffer.from(`\0${credentials.smtpUsername || credentials.imapUsername}\0${credentials.smtpPassword || credentials.imapPassword}`).toString("base64");
|
|
8582
8659
|
try {
|
|
8583
|
-
await smtp.rawCommand(`AUTH PLAIN ${auth}`, (
|
|
8660
|
+
await smtp.rawCommand(`AUTH PLAIN ${auth}`, (text6) => /^235[ -]/m.test(text6), /^235[ -]/m);
|
|
8584
8661
|
} catch {
|
|
8585
8662
|
throw new Error("Local SMTP authentication failed.");
|
|
8586
8663
|
}
|
|
8587
|
-
await smtp.rawCommand(`MAIL FROM:<${from}>`, (
|
|
8664
|
+
await smtp.rawCommand(`MAIL FROM:<${from}>`, (text6) => /^250[ -]/m.test(text6), /^250[ -]/m);
|
|
8588
8665
|
for (const recipient of to) {
|
|
8589
|
-
await smtp.rawCommand(`RCPT TO:<${recipient}>`, (
|
|
8666
|
+
await smtp.rawCommand(`RCPT TO:<${recipient}>`, (text6) => /^250[ -]/m.test(text6), /^250[ -]/m);
|
|
8590
8667
|
}
|
|
8591
|
-
await smtp.rawCommand("DATA", (
|
|
8668
|
+
await smtp.rawCommand("DATA", (text6) => /^354[ -]/m.test(text6), /^354[ -]/m);
|
|
8592
8669
|
await smtp.rawCommand(`${buildSmtpMessage({ from, to, subject, bodyText, messageId })}\r
|
|
8593
|
-
.`, (
|
|
8594
|
-
await smtp.rawCommand("QUIT", (
|
|
8670
|
+
.`, (text6) => /^250[ -]/m.test(text6), /^250[ -]/m);
|
|
8671
|
+
await smtp.rawCommand("QUIT", (text6) => /^221[ -]/m.test(text6), /^221[ -]/m).catch(() => void 0);
|
|
8595
8672
|
return { provider: PROTON_BRIDGE_PROVIDER_ID, message_id: messageId, delivered: true };
|
|
8596
8673
|
} finally {
|
|
8597
8674
|
smtp.close();
|
|
@@ -8703,7 +8780,7 @@ async function openTextSocket(host, port, timeoutMs) {
|
|
|
8703
8780
|
buffer = "";
|
|
8704
8781
|
socket.write(`${tag} ${command}\r
|
|
8705
8782
|
`);
|
|
8706
|
-
const response = await waitForSocketText(socket, () => buffer, (
|
|
8783
|
+
const response = await waitForSocketText(socket, () => buffer, (text6) => marker.test(text6), timeoutMs);
|
|
8707
8784
|
if (expected && !expected.test(response)) {
|
|
8708
8785
|
throw new Error(`Local mail command failed: ${redactProtonBridgeSecrets(response.split(/\r?\n/).slice(-2).join(" "))}`);
|
|
8709
8786
|
}
|
|
@@ -8729,8 +8806,8 @@ async function waitForSocketText(socket, getBuffer, done, timeoutMs) {
|
|
|
8729
8806
|
return await new Promise((resolve17, reject) => {
|
|
8730
8807
|
const timer = setTimeout(() => cleanup(() => reject(new Error("Timed out waiting for local mail server response."))), timeoutMs);
|
|
8731
8808
|
const check = () => {
|
|
8732
|
-
const
|
|
8733
|
-
if (done(
|
|
8809
|
+
const text6 = getBuffer();
|
|
8810
|
+
if (done(text6)) cleanup(() => resolve17(text6));
|
|
8734
8811
|
};
|
|
8735
8812
|
const onData = () => check();
|
|
8736
8813
|
const onError = (error) => cleanup(() => reject(error));
|
|
@@ -8809,8 +8886,8 @@ function splitBridgeInfoSections(output) {
|
|
|
8809
8886
|
}
|
|
8810
8887
|
return sections;
|
|
8811
8888
|
}
|
|
8812
|
-
function firstValue(map, ...
|
|
8813
|
-
for (const key of
|
|
8889
|
+
function firstValue(map, ...keys2) {
|
|
8890
|
+
for (const key of keys2) {
|
|
8814
8891
|
const value = map.get(normalizeKey(key));
|
|
8815
8892
|
if (value) return value;
|
|
8816
8893
|
}
|
|
@@ -8907,8 +8984,8 @@ async function promptHidden(prompt) {
|
|
|
8907
8984
|
return await new Promise((resolve17, reject) => {
|
|
8908
8985
|
let value = "";
|
|
8909
8986
|
const onData = (chunk) => {
|
|
8910
|
-
const
|
|
8911
|
-
for (const char of
|
|
8987
|
+
const text6 = chunk.toString("utf8");
|
|
8988
|
+
for (const char of text6) {
|
|
8912
8989
|
if (char === "") {
|
|
8913
8990
|
cleanup();
|
|
8914
8991
|
reject(new Error("Bridge credential prompt cancelled."));
|
|
@@ -10610,8 +10687,8 @@ var MATE_NAMES = {
|
|
|
10610
10687
|
general_knowledge: "George",
|
|
10611
10688
|
onboarding_support: "Suki"
|
|
10612
10689
|
};
|
|
10613
|
-
function stripLegacySuggestionPrefix(
|
|
10614
|
-
return
|
|
10690
|
+
function stripLegacySuggestionPrefix(text6) {
|
|
10691
|
+
return text6.replace(/^\s*\[[^\]]+\]\s*/, "").trim();
|
|
10615
10692
|
}
|
|
10616
10693
|
var CLOUD_API_URL = "https://api.openmates.org";
|
|
10617
10694
|
var DEFAULT_API_URL = process.env.OPENMATES_API_URL ?? CLOUD_API_URL;
|
|
@@ -14314,7 +14391,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
14314
14391
|
return types;
|
|
14315
14392
|
};
|
|
14316
14393
|
const existingTypes = await verifiedKeyTypes(keyPage.data?.embed_keys ?? []);
|
|
14317
|
-
const
|
|
14394
|
+
const keys2 = [
|
|
14318
14395
|
{
|
|
14319
14396
|
hashed_embed_id: hashedKeySubject,
|
|
14320
14397
|
key_type: "master",
|
|
@@ -14332,7 +14409,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
14332
14409
|
created_at: now
|
|
14333
14410
|
}
|
|
14334
14411
|
].filter((key) => !existingTypes.has(key.key_type));
|
|
14335
|
-
if (
|
|
14412
|
+
if (keys2.length > 0) {
|
|
14336
14413
|
const requestId = randomUUID9();
|
|
14337
14414
|
const receipt = ws.waitForMessage("store_embed_keys_confirmed", (value) => value.request_id === requestId, 3e4);
|
|
14338
14415
|
void receipt.catch(() => {
|
|
@@ -14340,10 +14417,10 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
14340
14417
|
await ws.sendAsync("store_embed_keys", {
|
|
14341
14418
|
request_id: requestId,
|
|
14342
14419
|
recovery_record_id: output.record_id,
|
|
14343
|
-
keys
|
|
14420
|
+
keys: keys2
|
|
14344
14421
|
});
|
|
14345
14422
|
const result2 = (await receipt).payload;
|
|
14346
|
-
if (result2.failed_count !== 0 || result2.created_count !==
|
|
14423
|
+
if (result2.failed_count !== 0 || result2.created_count !== keys2.length || result2.requested_count !== keys2.length) {
|
|
14347
14424
|
throw new Error("Recovery embed key wrappers were not exactly confirmed.");
|
|
14348
14425
|
}
|
|
14349
14426
|
const durable = await this.http.get(
|
|
@@ -16034,7 +16111,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
16034
16111
|
embedKey
|
|
16035
16112
|
);
|
|
16036
16113
|
const encryptedTextPreview = embed.text_preview ? await encryptWithAesGcmCombined(embed.text_preview, embedKey) : void 0;
|
|
16037
|
-
const
|
|
16114
|
+
const keys2 = !isChild ? [
|
|
16038
16115
|
{
|
|
16039
16116
|
hashed_embed_id: hashedEmbedId,
|
|
16040
16117
|
key_type: "master",
|
|
@@ -16087,7 +16164,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
16087
16164
|
updated_at: updatedAt
|
|
16088
16165
|
});
|
|
16089
16166
|
await storeConfirmed;
|
|
16090
|
-
if (
|
|
16167
|
+
if (keys2.length > 0) {
|
|
16091
16168
|
const keysRequestId = randomUUID9();
|
|
16092
16169
|
const keysConfirmed = params.ws.waitForMessage(
|
|
16093
16170
|
"store_embed_keys_confirmed",
|
|
@@ -16097,9 +16174,9 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
16097
16174
|
},
|
|
16098
16175
|
3e4
|
|
16099
16176
|
);
|
|
16100
|
-
await params.ws.sendAsync("store_embed_keys", { request_id: keysRequestId, keys });
|
|
16177
|
+
await params.ws.sendAsync("store_embed_keys", { request_id: keysRequestId, keys: keys2 });
|
|
16101
16178
|
const keysReceipt = (await keysConfirmed).payload;
|
|
16102
|
-
if (keysReceipt.failed_count !== 0 || keysReceipt.created_count !==
|
|
16179
|
+
if (keysReceipt.failed_count !== 0 || keysReceipt.created_count !== keys2.length) {
|
|
16103
16180
|
throw new Error(`Embed ${embed.embed_id} key wrappers were not durably stored.`);
|
|
16104
16181
|
}
|
|
16105
16182
|
}
|
|
@@ -17166,11 +17243,11 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
17166
17243
|
}
|
|
17167
17244
|
return response.data.events ?? [];
|
|
17168
17245
|
}
|
|
17169
|
-
async followUpWorkflowInput(sessionId,
|
|
17246
|
+
async followUpWorkflowInput(sessionId, text6) {
|
|
17170
17247
|
this.requireSession();
|
|
17171
17248
|
const response = await this.http.post(
|
|
17172
17249
|
`/v1/workflows/input/${encodeURIComponent(sessionId)}/follow-up`,
|
|
17173
|
-
{ text:
|
|
17250
|
+
{ text: text6 },
|
|
17174
17251
|
this.getCliRequestHeaders()
|
|
17175
17252
|
);
|
|
17176
17253
|
if (!response.ok || !response.data.session) {
|
|
@@ -30806,8 +30883,8 @@ var OpenMatesWorkflows = class {
|
|
|
30806
30883
|
const response = await this.client.get(`/v1/workflows/input/${encodeURIComponent(sessionId)}/events?after_event_id=${encodeURIComponent(String(afterEventId))}`);
|
|
30807
30884
|
return response.events ?? [];
|
|
30808
30885
|
}
|
|
30809
|
-
async followUpInput(sessionId,
|
|
30810
|
-
const response = await this.client.request(`/v1/workflows/input/${encodeURIComponent(sessionId)}/follow-up`, { text:
|
|
30886
|
+
async followUpInput(sessionId, text6) {
|
|
30887
|
+
const response = await this.client.request(`/v1/workflows/input/${encodeURIComponent(sessionId)}/follow-up`, { text: text6 });
|
|
30811
30888
|
if (!response.session) throw new OpenMatesApiError(500, { detail: "Workflow input response missing session" });
|
|
30812
30889
|
return response.session;
|
|
30813
30890
|
}
|
|
@@ -31131,8 +31208,8 @@ var OpenMatesEmbeds = class {
|
|
|
31131
31208
|
}
|
|
31132
31209
|
async share(embedId, options = {}) {
|
|
31133
31210
|
const shown = await this.show(embedId);
|
|
31134
|
-
const
|
|
31135
|
-
const embedKey = await this.client.resolveEmbedKeyForShare(
|
|
31211
|
+
const keys2 = Array.isArray(shown.embed_keys) ? shown.embed_keys : [];
|
|
31212
|
+
const embedKey = await this.client.resolveEmbedKeyForShare(keys2, embedId);
|
|
31136
31213
|
if (!embedKey) throw new OpenMatesConfigError("Unable to resolve embed key for share link");
|
|
31137
31214
|
const blob = await generateEmbedShareBlob(embedId, embedKey, options.expires ?? 0, options.password);
|
|
31138
31215
|
return { url: buildEmbedShareUrl(this.client.webOrigin(), embedId, blob) };
|
|
@@ -31552,7 +31629,7 @@ import { fileURLToPath as fileURLToPath4 } from "url";
|
|
|
31552
31629
|
import { basename as basename9, dirname as dirname17, join as join28 } from "path";
|
|
31553
31630
|
import { createHash as createHash29, randomBytes as randomBytes13, randomUUID as randomUUID23 } from "crypto";
|
|
31554
31631
|
import { arch as arch2, platform as platform2 } from "os";
|
|
31555
|
-
import { parse as
|
|
31632
|
+
import { parse as parseYaml, parseDocument as parseYamlDocument, stringify as stringifyYaml } from "yaml";
|
|
31556
31633
|
|
|
31557
31634
|
// ../workflowFile.ts
|
|
31558
31635
|
var WORKFLOW_FILE_MAX_BYTES = 1048576;
|
|
@@ -31630,15 +31707,15 @@ var CREDENTIAL_SUFFIXES = [
|
|
|
31630
31707
|
function record4(value) {
|
|
31631
31708
|
return value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
31632
31709
|
}
|
|
31633
|
-
function onlyKeys(value,
|
|
31710
|
+
function onlyKeys(value, keys2, path2) {
|
|
31634
31711
|
for (const key of Object.keys(value)) {
|
|
31635
|
-
if (!
|
|
31712
|
+
if (!keys2.includes(key)) throw new Error(`Unsupported Workflow file field: ${path2}.${key}.`);
|
|
31636
31713
|
}
|
|
31637
31714
|
}
|
|
31638
31715
|
function assertPortable(value) {
|
|
31639
31716
|
let remaining = 5e4;
|
|
31640
31717
|
const active = /* @__PURE__ */ new Set();
|
|
31641
|
-
function
|
|
31718
|
+
function visit2(item, path2, depth) {
|
|
31642
31719
|
if (--remaining < 0 || depth > 64) throw new Error("Workflow file is too complex.");
|
|
31643
31720
|
if (typeof item === "number" && !Number.isFinite(item)) throw new Error("Workflow file contains an invalid number.");
|
|
31644
31721
|
if (item === null || ["string", "boolean", "number"].includes(typeof item)) return;
|
|
@@ -31646,32 +31723,32 @@ function assertPortable(value) {
|
|
|
31646
31723
|
if (active.has(item)) throw new Error("Workflow file contains a circular reference.");
|
|
31647
31724
|
active.add(item);
|
|
31648
31725
|
if (Array.isArray(item)) {
|
|
31649
|
-
item.forEach((child, i) =>
|
|
31726
|
+
item.forEach((child, i) => visit2(child, `${path2}[${i}]`, depth + 1));
|
|
31650
31727
|
} else {
|
|
31651
31728
|
for (const [key, child] of Object.entries(item)) {
|
|
31652
31729
|
const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
31653
31730
|
if (["__proto__", "constructor", "prototype"].includes(key) || FORBIDDEN_KEYS.has(normalized) || CREDENTIAL_SUFFIXES.some((suffix) => normalized.endsWith(suffix))) {
|
|
31654
31731
|
throw new Error(`Workflow file contains an account-specific or private field at ${path2}.${key}.`);
|
|
31655
31732
|
}
|
|
31656
|
-
|
|
31733
|
+
visit2(child, `${path2}.${key}`, depth + 1);
|
|
31657
31734
|
}
|
|
31658
31735
|
}
|
|
31659
31736
|
active.delete(item);
|
|
31660
31737
|
}
|
|
31661
|
-
|
|
31738
|
+
visit2(value, "$", 0);
|
|
31662
31739
|
}
|
|
31663
31740
|
function remapGraph(graph, ids) {
|
|
31664
31741
|
const escaped = Array.from(ids.keys()).sort((a, b) => b.length - a.length).map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
31665
31742
|
const references = escaped.length ? new RegExp(`(\\$nodes\\.|\\{\\{\\s*steps\\.|\\$items\\.|\\{\\{\\s*items\\.)(${escaped.join("|")})(?=[.}\\s]|$)`, "g") : null;
|
|
31666
|
-
function
|
|
31743
|
+
function visit2(value) {
|
|
31667
31744
|
if (typeof value === "string") return references ? value.replace(references, (_match, prefix, id) => prefix + ids.get(id)) : value;
|
|
31668
|
-
if (Array.isArray(value)) return value.map((item) =>
|
|
31669
|
-
if (record4(value)) return Object.fromEntries(Object.entries(value).map(([key, child]) => [key,
|
|
31745
|
+
if (Array.isArray(value)) return value.map((item) => visit2(item));
|
|
31746
|
+
if (record4(value)) return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, visit2(child)]));
|
|
31670
31747
|
return value;
|
|
31671
31748
|
}
|
|
31672
|
-
const mapped =
|
|
31749
|
+
const mapped = visit2(graph);
|
|
31673
31750
|
if (graph.ui_layout) mapped.ui_layout = Object.fromEntries(
|
|
31674
|
-
Object.entries(graph.ui_layout).map(([key, child]) => [ids.get(key) ?? key,
|
|
31751
|
+
Object.entries(graph.ui_layout).map(([key, child]) => [ids.get(key) ?? key, visit2(child)])
|
|
31675
31752
|
);
|
|
31676
31753
|
mapped.trigger_node_id = graph.trigger_node_id ? ids.get(graph.trigger_node_id) ?? graph.trigger_node_id : null;
|
|
31677
31754
|
mapped.nodes.forEach((node, i) => {
|
|
@@ -32077,27 +32154,27 @@ var SecretRegistry = class {
|
|
|
32077
32154
|
textsToAdd.push(entry.textToHide);
|
|
32078
32155
|
}
|
|
32079
32156
|
if (entry.additionalTexts) {
|
|
32080
|
-
for (const
|
|
32081
|
-
if (
|
|
32082
|
-
textsToAdd.push(
|
|
32157
|
+
for (const text6 of entry.additionalTexts) {
|
|
32158
|
+
if (text6 && text6.trim().length > 0) {
|
|
32159
|
+
textsToAdd.push(text6);
|
|
32083
32160
|
}
|
|
32084
32161
|
}
|
|
32085
32162
|
}
|
|
32086
|
-
for (const
|
|
32163
|
+
for (const text6 of textsToAdd) {
|
|
32087
32164
|
const placeholder = entry.replaceWith.startsWith("[") ? entry.replaceWith : `[${entry.replaceWith}]`;
|
|
32088
32165
|
const regEntry = {
|
|
32089
|
-
value:
|
|
32166
|
+
value: text6,
|
|
32090
32167
|
token: placeholder,
|
|
32091
32168
|
source: "settings",
|
|
32092
32169
|
name: entry.id,
|
|
32093
32170
|
type: "PERSONAL_DATA",
|
|
32094
|
-
length:
|
|
32171
|
+
length: text6.length
|
|
32095
32172
|
};
|
|
32096
|
-
this.entries.set(
|
|
32097
|
-
this.usedPlaceholders.set(placeholder,
|
|
32098
|
-
const lower =
|
|
32099
|
-
if (lower !==
|
|
32100
|
-
this.variantToOriginal.set(lower,
|
|
32173
|
+
this.entries.set(text6, regEntry);
|
|
32174
|
+
this.usedPlaceholders.set(placeholder, text6);
|
|
32175
|
+
const lower = text6.toLowerCase();
|
|
32176
|
+
if (lower !== text6) {
|
|
32177
|
+
this.variantToOriginal.set(lower, text6);
|
|
32101
32178
|
}
|
|
32102
32179
|
}
|
|
32103
32180
|
this.automaton = null;
|
|
@@ -32151,12 +32228,12 @@ var SecretRegistry = class {
|
|
|
32151
32228
|
* @param text Text to scan
|
|
32152
32229
|
* @returns Array of secret mappings for all matches found
|
|
32153
32230
|
*/
|
|
32154
|
-
findAll(
|
|
32231
|
+
findAll(text6) {
|
|
32155
32232
|
if (this.entries.size === 0) return [];
|
|
32156
32233
|
if (!this.automaton) {
|
|
32157
32234
|
this.buildAutomaton();
|
|
32158
32235
|
}
|
|
32159
|
-
const results = this.automaton.search(
|
|
32236
|
+
const results = this.automaton.search(text6);
|
|
32160
32237
|
const mappings = [];
|
|
32161
32238
|
const coveredRanges = [];
|
|
32162
32239
|
const sortedResults = [];
|
|
@@ -32361,17 +32438,17 @@ var SecretScanner = class {
|
|
|
32361
32438
|
* @param text Text to scan and redact
|
|
32362
32439
|
* @returns Object with redacted text and mappings for restoration
|
|
32363
32440
|
*/
|
|
32364
|
-
redact(
|
|
32365
|
-
if (!
|
|
32441
|
+
redact(text6) {
|
|
32442
|
+
if (!text6) return { redacted: text6, mappings: [] };
|
|
32366
32443
|
const allMappings = [];
|
|
32367
32444
|
const coveredRanges = [];
|
|
32368
|
-
const urlExclusionZones = getUrlExclusionZones(
|
|
32369
|
-
const identifierRanges = codingIdentifierRanges(
|
|
32445
|
+
const urlExclusionZones = getUrlExclusionZones(text6);
|
|
32446
|
+
const identifierRanges = codingIdentifierRanges(text6);
|
|
32370
32447
|
if (this.options.enableRegistryDetection && this.registry.size > 0) {
|
|
32371
|
-
const registryMappings = this.registry.findAll(
|
|
32448
|
+
const registryMappings = this.registry.findAll(text6);
|
|
32372
32449
|
for (const mapping of registryMappings) {
|
|
32373
32450
|
let searchFrom = 0;
|
|
32374
|
-
const searchText =
|
|
32451
|
+
const searchText = text6.toLowerCase();
|
|
32375
32452
|
const matchLower = mapping.original.toLowerCase();
|
|
32376
32453
|
while (searchFrom < searchText.length) {
|
|
32377
32454
|
const idx = searchText.indexOf(matchLower, searchFrom);
|
|
@@ -32387,7 +32464,7 @@ var SecretScanner = class {
|
|
|
32387
32464
|
for (const pattern of [...SECRET_PATTERNS, ...GENERAL_PII_PATTERNS]) {
|
|
32388
32465
|
pattern.regex.lastIndex = 0;
|
|
32389
32466
|
let match;
|
|
32390
|
-
while ((match = pattern.regex.exec(
|
|
32467
|
+
while ((match = pattern.regex.exec(text6)) !== null) {
|
|
32391
32468
|
const matchText = match[0];
|
|
32392
32469
|
const startIndex = match.index;
|
|
32393
32470
|
const endIndex = startIndex + matchText.length;
|
|
@@ -32418,7 +32495,7 @@ var SecretScanner = class {
|
|
|
32418
32495
|
}
|
|
32419
32496
|
}
|
|
32420
32497
|
}
|
|
32421
|
-
let redacted =
|
|
32498
|
+
let redacted = text6;
|
|
32422
32499
|
const sortedMappings = [...allMappings].sort(
|
|
32423
32500
|
(a, b) => b.original.length - a.original.length
|
|
32424
32501
|
);
|
|
@@ -32447,9 +32524,9 @@ var SecretScanner = class {
|
|
|
32447
32524
|
* @param mappings Mappings from a previous redact() call
|
|
32448
32525
|
* @returns Text with placeholders replaced by original values
|
|
32449
32526
|
*/
|
|
32450
|
-
restore(
|
|
32451
|
-
if (!
|
|
32452
|
-
let result =
|
|
32527
|
+
restore(text6, mappings) {
|
|
32528
|
+
if (!text6 || !mappings || mappings.length === 0) return text6;
|
|
32529
|
+
let result = text6;
|
|
32453
32530
|
for (const mapping of mappings) {
|
|
32454
32531
|
result = result.split(mapping.placeholder).join(mapping.original);
|
|
32455
32532
|
}
|
|
@@ -32468,11 +32545,11 @@ var SecretScanner = class {
|
|
|
32468
32545
|
function escapeRegExp2(string3) {
|
|
32469
32546
|
return string3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
32470
32547
|
}
|
|
32471
|
-
function getUrlExclusionZones(
|
|
32548
|
+
function getUrlExclusionZones(text6) {
|
|
32472
32549
|
const urlExclusionRegex = /https?:\/\/[^\s]+/g;
|
|
32473
32550
|
const zones = [];
|
|
32474
32551
|
let match;
|
|
32475
|
-
while ((match = urlExclusionRegex.exec(
|
|
32552
|
+
while ((match = urlExclusionRegex.exec(text6)) !== null) {
|
|
32476
32553
|
zones.push({ start: match.index, end: match.index + match[0].length });
|
|
32477
32554
|
}
|
|
32478
32555
|
return zones;
|
|
@@ -32549,18 +32626,18 @@ var OutputRedactor = class {
|
|
|
32549
32626
|
* @param text Text to scan
|
|
32550
32627
|
* @returns Redacted text with placeholders
|
|
32551
32628
|
*/
|
|
32552
|
-
redact(
|
|
32553
|
-
return this.redactWithMappings(
|
|
32629
|
+
redact(text6) {
|
|
32630
|
+
return this.redactWithMappings(text6).redacted;
|
|
32554
32631
|
}
|
|
32555
32632
|
/**
|
|
32556
32633
|
* Redact and return both redacted text and mappings.
|
|
32557
32634
|
* Used when we need to store mappings alongside message data.
|
|
32558
32635
|
*/
|
|
32559
|
-
redactWithMappings(
|
|
32560
|
-
if (!
|
|
32561
|
-
return { redacted:
|
|
32636
|
+
redactWithMappings(text6) {
|
|
32637
|
+
if (!text6 || !this.initialized || !this.privacyEnabled) {
|
|
32638
|
+
return { redacted: text6, mappings: [] };
|
|
32562
32639
|
}
|
|
32563
|
-
const result = this.scanner.redact(
|
|
32640
|
+
const result = this.scanner.redact(text6);
|
|
32564
32641
|
const excluded = result.mappings.filter((m) => this.disabledCategories.has(PII_TYPE_TO_CATEGORY[m.type] ?? ""));
|
|
32565
32642
|
if (excluded.length) {
|
|
32566
32643
|
result.redacted = this.scanner.restore(result.redacted, excluded);
|
|
@@ -32575,9 +32652,9 @@ var OutputRedactor = class {
|
|
|
32575
32652
|
* Restore placeholders back to original values.
|
|
32576
32653
|
* Only uses mappings from this session (never from external sources).
|
|
32577
32654
|
*/
|
|
32578
|
-
restore(
|
|
32579
|
-
if (!
|
|
32580
|
-
return this.scanner.restore(
|
|
32655
|
+
restore(text6) {
|
|
32656
|
+
if (!text6 || this.sessionMappings.size === 0) return text6;
|
|
32657
|
+
return this.scanner.restore(text6, Array.from(this.sessionMappings.values()));
|
|
32581
32658
|
}
|
|
32582
32659
|
/** Mappings accumulated while preparing attachments and this message. */
|
|
32583
32660
|
getMappings() {
|
|
@@ -32636,8 +32713,8 @@ function createWebsiteEmbed(url) {
|
|
|
32636
32713
|
status: "finished"
|
|
32637
32714
|
};
|
|
32638
32715
|
}
|
|
32639
|
-
function replaceUrlsInText(
|
|
32640
|
-
return
|
|
32716
|
+
function replaceUrlsInText(text6, embeds) {
|
|
32717
|
+
return text6.replace(URL_PATTERN, (rawUrl) => {
|
|
32641
32718
|
const { url, suffix } = trimTrailingUrlPunctuation(rawUrl);
|
|
32642
32719
|
if (!url) return rawUrl;
|
|
32643
32720
|
try {
|
|
@@ -33637,12 +33714,12 @@ function renderAudioTranscribePreview(c, ln) {
|
|
|
33637
33714
|
const language = str(c.language) ?? "";
|
|
33638
33715
|
if (duration) ln(`\x1B[2mDuration: ${duration}\x1B[0m`);
|
|
33639
33716
|
if (language) ln(`\x1B[2mLanguage: ${language}\x1B[0m`);
|
|
33640
|
-
const
|
|
33641
|
-
if (
|
|
33717
|
+
const text6 = str(c.text) ?? str(c.transcript) ?? "";
|
|
33718
|
+
if (text6) ln(trunc(text6, 60));
|
|
33642
33719
|
}
|
|
33643
33720
|
function renderAudioTranscribeFullscreen(c) {
|
|
33644
|
-
const
|
|
33645
|
-
if (
|
|
33721
|
+
const text6 = str(c.text) ?? str(c.transcript) ?? "";
|
|
33722
|
+
if (text6) console.log(text6);
|
|
33646
33723
|
else console.log("No transcript available.");
|
|
33647
33724
|
}
|
|
33648
33725
|
function renderByDirectType(embed, c, ln) {
|
|
@@ -33875,8 +33952,8 @@ function renderDirectTypeFullscreen(embed, c) {
|
|
|
33875
33952
|
|
|
33876
33953
|
`);
|
|
33877
33954
|
if (html) {
|
|
33878
|
-
const
|
|
33879
|
-
console.log(
|
|
33955
|
+
const text6 = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
33956
|
+
console.log(text6);
|
|
33880
33957
|
}
|
|
33881
33958
|
break;
|
|
33882
33959
|
}
|
|
@@ -33887,8 +33964,8 @@ function renderDirectTypeFullscreen(embed, c) {
|
|
|
33887
33964
|
|
|
33888
33965
|
`);
|
|
33889
33966
|
if (html) {
|
|
33890
|
-
const
|
|
33891
|
-
console.log(
|
|
33967
|
+
const text6 = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
33968
|
+
console.log(text6);
|
|
33892
33969
|
}
|
|
33893
33970
|
break;
|
|
33894
33971
|
}
|
|
@@ -34039,18 +34116,18 @@ function mindMapOutline(document, maxNodes = 100) {
|
|
|
34039
34116
|
}
|
|
34040
34117
|
const lines = [];
|
|
34041
34118
|
const visited = /* @__PURE__ */ new Set();
|
|
34042
|
-
const
|
|
34119
|
+
const visit2 = (nodeId, depth) => {
|
|
34043
34120
|
if (visited.size >= maxNodes || visited.has(nodeId)) return;
|
|
34044
34121
|
const node = nodesById.get(nodeId);
|
|
34045
34122
|
if (!node) return;
|
|
34046
34123
|
visited.add(nodeId);
|
|
34047
34124
|
lines.push(`${" ".repeat(depth)}- ${node.label}`);
|
|
34048
|
-
for (const childId of node.children ?? [])
|
|
34125
|
+
for (const childId of node.children ?? []) visit2(childId, depth + 1);
|
|
34049
34126
|
};
|
|
34050
|
-
|
|
34127
|
+
visit2(document.rootId, 0);
|
|
34051
34128
|
for (const node of document.nodes) {
|
|
34052
34129
|
if (visited.size >= maxNodes) break;
|
|
34053
|
-
if (!visited.has(node.id))
|
|
34130
|
+
if (!visited.has(node.id)) visit2(node.id, 0);
|
|
34054
34131
|
}
|
|
34055
34132
|
return lines.join("\n");
|
|
34056
34133
|
}
|
|
@@ -34435,13 +34512,13 @@ function unsetEnvValue(content, key) {
|
|
|
34435
34512
|
}).join("\n").replace(/\n*$/, "")}
|
|
34436
34513
|
`;
|
|
34437
34514
|
}
|
|
34438
|
-
function
|
|
34515
|
+
function unique2(items) {
|
|
34439
34516
|
return [...new Set(items.map((item) => item.trim()).filter(Boolean))];
|
|
34440
34517
|
}
|
|
34441
34518
|
function csv(value) {
|
|
34442
34519
|
if (value === void 0) return [];
|
|
34443
|
-
if (Array.isArray(value)) return
|
|
34444
|
-
return
|
|
34520
|
+
if (Array.isArray(value)) return unique2(value.flatMap((item) => item.split(",")));
|
|
34521
|
+
return unique2(value.split(","));
|
|
34445
34522
|
}
|
|
34446
34523
|
function parseServerRole(value) {
|
|
34447
34524
|
if (!value) return "core";
|
|
@@ -34515,7 +34592,7 @@ function planServerRuntime(input) {
|
|
|
34515
34592
|
const profileServices = role === "core" ? [...CORE_OBSERVABILITY_BY_PROFILE[coreProfile]] : [];
|
|
34516
34593
|
if (role === "core" && input.withAlerts) profileServices.push("alertmanager");
|
|
34517
34594
|
const webappServices = input.includeWebapp === false ? [] : ["webapp"];
|
|
34518
|
-
const defaultServices = role === "core" ?
|
|
34595
|
+
const defaultServices = role === "core" ? unique2([...definition.requiredServices, ...CORE_WORKER_SERVICES, "admin-sidecar", ...profileServices, ...webappServices]) : unique2([...definition.requiredServices, ...definition.optionalServices]);
|
|
34519
34596
|
return {
|
|
34520
34597
|
role,
|
|
34521
34598
|
profile,
|
|
@@ -34898,7 +34975,7 @@ import { createHash as createHash16 } from "crypto";
|
|
|
34898
34975
|
import { accessSync, constants as constants2, existsSync as existsSync9, mkdirSync as mkdirSync9, mkdtempSync, readFileSync as readFileSync10, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
34899
34976
|
import { tmpdir } from "os";
|
|
34900
34977
|
import { dirname as dirname7, join as join12 } from "path";
|
|
34901
|
-
var hash2 = (
|
|
34978
|
+
var hash2 = (text6) => createHash16("sha256").update(text6).digest("hex");
|
|
34902
34979
|
function resolveCaddyProfile(role, explicit, previous) {
|
|
34903
34980
|
if (explicit === void 0) return previous ?? "self-host";
|
|
34904
34981
|
if (role !== "upload" || explicit !== "official-upload") throw new Error("caddy_profile_unsupported");
|
|
@@ -40016,8 +40093,8 @@ ${entry.category}:`);
|
|
|
40016
40093
|
if (action === "edit") {
|
|
40017
40094
|
const category = rest[1];
|
|
40018
40095
|
if (category) {
|
|
40019
|
-
const
|
|
40020
|
-
console.error(
|
|
40096
|
+
const keys2 = entries.filter((entry) => entry.category === category).map((entry) => entry.key);
|
|
40097
|
+
console.error(keys2.length ? `Focused ${category} keys: ${keys2.join(", ")}` : `No existing ${category} keys found; opening canonical .env.`);
|
|
40021
40098
|
}
|
|
40022
40099
|
const backupPath = backupEnvFile(installPath);
|
|
40023
40100
|
if (backupPath) console.error(`Backup: ${backupPath}`);
|
|
@@ -40327,10 +40404,10 @@ async function buildCodeRunRequestsFromFlags(flags) {
|
|
|
40327
40404
|
for (const url of toList(flags.url)) {
|
|
40328
40405
|
const response = await fetch(url);
|
|
40329
40406
|
if (!response.ok) throw new Error(`Failed to download Code Run URL ${redactUrl(url)} (HTTP ${response.status})`);
|
|
40330
|
-
const
|
|
40407
|
+
const text6 = await response.text();
|
|
40331
40408
|
const urlPath = new URL(url).pathname;
|
|
40332
40409
|
const sandboxPath = normalizeCodeRunPath(entry || basename3(urlPath) || "main.txt");
|
|
40333
|
-
const buffer = Buffer.from(
|
|
40410
|
+
const buffer = Buffer.from(text6, "utf8");
|
|
40334
40411
|
addFile({
|
|
40335
40412
|
path: sandboxPath,
|
|
40336
40413
|
content_base64: buffer.toString("base64"),
|
|
@@ -40340,9 +40417,9 @@ async function buildCodeRunRequestsFromFlags(flags) {
|
|
|
40340
40417
|
}, buffer.byteLength);
|
|
40341
40418
|
}
|
|
40342
40419
|
if (flags.repo) {
|
|
40343
|
-
await addGithubRepoFiles(flags.repo, toList(flags.include), async (path2,
|
|
40420
|
+
await addGithubRepoFiles(flags.repo, toList(flags.include), async (path2, text6) => {
|
|
40344
40421
|
const sandboxPath = normalizeCodeRunPath(path2);
|
|
40345
|
-
const buffer = Buffer.from(
|
|
40422
|
+
const buffer = Buffer.from(text6, "utf8");
|
|
40346
40423
|
addFile({
|
|
40347
40424
|
path: sandboxPath,
|
|
40348
40425
|
content_base64: buffer.toString("base64"),
|
|
@@ -57970,8 +58047,8 @@ function decodeEmbedContent(content) {
|
|
|
57970
58047
|
}
|
|
57971
58048
|
return parseFlatToonFields(content);
|
|
57972
58049
|
}
|
|
57973
|
-
function stringField3(record8,
|
|
57974
|
-
for (const key of
|
|
58050
|
+
function stringField3(record8, keys2) {
|
|
58051
|
+
for (const key of keys2) {
|
|
57975
58052
|
const value = cleanString(record8[key]);
|
|
57976
58053
|
if (value) return value;
|
|
57977
58054
|
}
|
|
@@ -84359,8 +84436,8 @@ function parseSuites(value) {
|
|
|
84359
84436
|
const suites = value.split(",").map((suite) => suite.trim()).filter(Boolean);
|
|
84360
84437
|
if (suites.includes("all")) return ["quick", "extensive"];
|
|
84361
84438
|
const allowed = /* @__PURE__ */ new Set(["quick", "extensive"]);
|
|
84362
|
-
const
|
|
84363
|
-
if (
|
|
84439
|
+
const invalid2 = suites.filter((suite) => !allowed.has(suite));
|
|
84440
|
+
if (invalid2.length > 0 || suites.length === 0) {
|
|
84364
84441
|
throw new Error("Invalid --suite. Use quick, extensive, or all.");
|
|
84365
84442
|
}
|
|
84366
84443
|
return [...new Set(suites)];
|
|
@@ -84933,13 +85010,13 @@ function parseJudgment(answer) {
|
|
|
84933
85010
|
return { score: null, reason: null };
|
|
84934
85011
|
}
|
|
84935
85012
|
}
|
|
84936
|
-
function extractJsonObject(
|
|
84937
|
-
const fenced =
|
|
85013
|
+
function extractJsonObject(text6) {
|
|
85014
|
+
const fenced = text6.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
|
|
84938
85015
|
if (fenced) return fenced[1];
|
|
84939
|
-
const start =
|
|
84940
|
-
const end =
|
|
85016
|
+
const start = text6.indexOf("{");
|
|
85017
|
+
const end = text6.lastIndexOf("}");
|
|
84941
85018
|
if (start === -1 || end === -1 || end <= start) return null;
|
|
84942
|
-
return
|
|
85019
|
+
return text6.slice(start, end + 1);
|
|
84943
85020
|
}
|
|
84944
85021
|
function loadPricingForModels(models) {
|
|
84945
85022
|
const availablePricing = loadProviderPricing();
|
|
@@ -84968,21 +85045,21 @@ function loadProviderPricing() {
|
|
|
84968
85045
|
for (const fileName of readdirSync6(providersDir)) {
|
|
84969
85046
|
if (!fileName.endsWith(".yml")) continue;
|
|
84970
85047
|
const filePath = join16(providersDir, fileName);
|
|
84971
|
-
const
|
|
84972
|
-
const provider = parseProviderId(
|
|
84973
|
-
for (const modelPricing of parseModelPricing(
|
|
85048
|
+
const text6 = readFileSync13(filePath, "utf-8");
|
|
85049
|
+
const provider = parseProviderId(text6) ?? fileName.replace(/\.yml$/, "");
|
|
85050
|
+
for (const modelPricing of parseModelPricing(text6, provider)) {
|
|
84974
85051
|
pricing.set(`${modelPricing.provider}/${modelPricing.modelId}`, modelPricing);
|
|
84975
85052
|
pricing.set(modelPricing.modelId, modelPricing);
|
|
84976
85053
|
}
|
|
84977
85054
|
}
|
|
84978
85055
|
return pricing;
|
|
84979
85056
|
}
|
|
84980
|
-
function parseProviderId(
|
|
84981
|
-
const match =
|
|
85057
|
+
function parseProviderId(text6) {
|
|
85058
|
+
const match = text6.match(/^provider_id:\s*["']?([^"'\n]+)["']?/m);
|
|
84982
85059
|
return match?.[1]?.trim() ?? null;
|
|
84983
85060
|
}
|
|
84984
|
-
function parseModelPricing(
|
|
84985
|
-
const lines =
|
|
85061
|
+
function parseModelPricing(text6, provider) {
|
|
85062
|
+
const lines = text6.split("\n");
|
|
84986
85063
|
const results = [];
|
|
84987
85064
|
let modelId = null;
|
|
84988
85065
|
let inModel = false;
|
|
@@ -85544,10 +85621,10 @@ var TuiTerminal = class {
|
|
|
85544
85621
|
const tail = rows2.length < this.height ? `\x1B[${rows2.length + 1};1H\x1B[J` : "";
|
|
85545
85622
|
this.output.write(`\x1B[?2026h${body}${tail}\x1B[?2026l`);
|
|
85546
85623
|
}
|
|
85547
|
-
receiveInput(
|
|
85624
|
+
receiveInput(text6) {
|
|
85548
85625
|
if (this.inputTimer) clearTimeout(this.inputTimer);
|
|
85549
85626
|
this.inputTimer = null;
|
|
85550
|
-
this.pendingInput +=
|
|
85627
|
+
this.pendingInput += text6;
|
|
85551
85628
|
const marker = this.paste ? "\x1B[201~" : "\x1B[200~";
|
|
85552
85629
|
const found = this.pendingInput.indexOf(marker);
|
|
85553
85630
|
if (found >= 0) {
|
|
@@ -85575,10 +85652,10 @@ var TuiTerminal = class {
|
|
|
85575
85652
|
}, 30);
|
|
85576
85653
|
}
|
|
85577
85654
|
/** Consume SGR mouse reports without letting clicks become composer text. */
|
|
85578
|
-
dispatchInput(
|
|
85655
|
+
dispatchInput(text6) {
|
|
85579
85656
|
if (this.mouseTimer) clearTimeout(this.mouseTimer);
|
|
85580
85657
|
this.mouseTimer = null;
|
|
85581
|
-
const input = this.pendingMouse +
|
|
85658
|
+
const input = this.pendingMouse + text6;
|
|
85582
85659
|
this.pendingMouse = "";
|
|
85583
85660
|
let offset = 0;
|
|
85584
85661
|
while (offset < input.length) {
|
|
@@ -85977,25 +86054,25 @@ function wrapCells(value, width) {
|
|
|
85977
86054
|
width = Math.max(1, width);
|
|
85978
86055
|
const result = [];
|
|
85979
86056
|
for (const line of terminalText(value).split("\n")) {
|
|
85980
|
-
let
|
|
86057
|
+
let text6 = "", used = 0;
|
|
85981
86058
|
for (const { segment } of segments.segment(line)) {
|
|
85982
86059
|
const size = graphemeWidth(segment);
|
|
85983
86060
|
if (size > width) {
|
|
85984
|
-
if (
|
|
86061
|
+
if (text6) result.push(text6);
|
|
85985
86062
|
result.push("?");
|
|
85986
|
-
|
|
86063
|
+
text6 = "";
|
|
85987
86064
|
used = 0;
|
|
85988
86065
|
continue;
|
|
85989
86066
|
}
|
|
85990
86067
|
if (used + size > width) {
|
|
85991
|
-
result.push(
|
|
85992
|
-
|
|
86068
|
+
result.push(text6);
|
|
86069
|
+
text6 = "";
|
|
85993
86070
|
used = 0;
|
|
85994
86071
|
}
|
|
85995
|
-
|
|
86072
|
+
text6 += segment;
|
|
85996
86073
|
used += size;
|
|
85997
86074
|
}
|
|
85998
|
-
result.push(
|
|
86075
|
+
result.push(text6);
|
|
85999
86076
|
}
|
|
86000
86077
|
return result;
|
|
86001
86078
|
}
|
|
@@ -86649,8 +86726,8 @@ var NODE_FIELDS = {
|
|
|
86649
86726
|
custom_code: ["code"]
|
|
86650
86727
|
};
|
|
86651
86728
|
function compact(value, max = 80) {
|
|
86652
|
-
const
|
|
86653
|
-
const oneLine3 =
|
|
86729
|
+
const text6 = typeof value === "string" ? value : Array.isArray(value) ? value.map((item) => compact(item, max)).join(", ") : value && typeof value === "object" ? Object.entries(value).map(([key, item]) => `${key.replaceAll("_", " ")}: ${compact(item, max)}`).join(" \xB7 ") : String(value);
|
|
86730
|
+
const oneLine3 = text6.replace(/\s+/g, " ");
|
|
86654
86731
|
return truncateCells(oneLine3, max);
|
|
86655
86732
|
}
|
|
86656
86733
|
function label2(node) {
|
|
@@ -86845,7 +86922,7 @@ function buildWorkflowNodeForm(workflow, node, kind = "workflow-node") {
|
|
|
86845
86922
|
}
|
|
86846
86923
|
return [key];
|
|
86847
86924
|
});
|
|
86848
|
-
const
|
|
86925
|
+
const keys2 = [.../* @__PURE__ */ new Set([...schemaKeys, ...currentKeys])];
|
|
86849
86926
|
return {
|
|
86850
86927
|
kind,
|
|
86851
86928
|
title: `Edit ${label2(node)}`,
|
|
@@ -86853,7 +86930,7 @@ function buildWorkflowNodeForm(workflow, node, kind = "workflow-node") {
|
|
|
86853
86930
|
fieldIndex: 0,
|
|
86854
86931
|
fields: [
|
|
86855
86932
|
{ name: "title", label: "Node title", value: node.title ?? "" },
|
|
86856
|
-
...
|
|
86933
|
+
...keys2.map((key) => {
|
|
86857
86934
|
const value = valueAt(config, key);
|
|
86858
86935
|
return { name: `config.${key}`, label: key.replaceAll("_", " "), value: fieldValue(value), multiline: typeof value === "object" || /(?:message|body|prompt|code)$/i.test(key) };
|
|
86859
86936
|
})
|
|
@@ -87218,8 +87295,8 @@ function tuiChatSidebarRows(state) {
|
|
|
87218
87295
|
group.push(chat);
|
|
87219
87296
|
groups2.set(key, group);
|
|
87220
87297
|
}
|
|
87221
|
-
const
|
|
87222
|
-
for (const key of
|
|
87298
|
+
const keys2 = [...CHAT_TIME_GROUPS.filter((key) => groups2.has(key)), ...[...groups2.keys()].filter((key) => !CHAT_TIME_GROUPS.some((standard) => standard === key))];
|
|
87299
|
+
for (const key of keys2) {
|
|
87223
87300
|
const label3 = { today: "Today", yesterday: "Yesterday", previous_7_days: "Previous 7 days", previous_30_days: "Previous 30 days" }[key] ?? new Date(Number(key.split("_")[1]), Number(key.split("_")[2]) - 1).toLocaleDateString("en", { month: "long", year: "numeric" });
|
|
87224
87301
|
rows2.push({ kind: "section", label: label3 });
|
|
87225
87302
|
rows2.push(...groups2.get(key).map((chat) => ({
|
|
@@ -87413,7 +87490,7 @@ function renderWorkspaceFrame(state, rawWidth, rawHeight, body, options = {}) {
|
|
|
87413
87490
|
const title = state.activeChat?.title && state.workspace === "chats" ? ` \xB7 ${state.activeChat.title}` : "";
|
|
87414
87491
|
const nav = contentWidth >= 90 ? `OpenMates ${labels}${title}` : `OpenMates [${titleCase(state.workspace)}] ${state.sidebarOpen ? "Sidebar open" : "Ctrl+B sidebar"}${title}`;
|
|
87415
87492
|
const inputWidth = Math.max(1, contentWidth - 6);
|
|
87416
|
-
const inputLines = state.input.split("\n").flatMap((
|
|
87493
|
+
const inputLines = state.input.split("\n").flatMap((text6) => wrapCells(text6, inputWidth));
|
|
87417
87494
|
const showComposer = state.workspace !== "apps" || state.focus === "composer" || Boolean(state.input);
|
|
87418
87495
|
const composerRows = showComposer ? Math.min(3, Math.max(1, inputLines.length)) : 0;
|
|
87419
87496
|
const bodyHeight = Math.max(1, height - 2 - (showComposer ? composerRows + 3 : 1));
|
|
@@ -87468,8 +87545,8 @@ function renderWorkspaceFrame(state, rawWidth, rawHeight, body, options = {}) {
|
|
|
87468
87545
|
let remaining = span;
|
|
87469
87546
|
rendered = "";
|
|
87470
87547
|
for (const part of style.spans) {
|
|
87471
|
-
const
|
|
87472
|
-
rendered += part.background ? backgroundLine(
|
|
87548
|
+
const text6 = truncateCells(terminalText(part.text).replace(/\n/g, " "), remaining), size = cells(text6);
|
|
87549
|
+
rendered += part.background ? backgroundLine(text6, size, part.background, mode, part.bold) : text6;
|
|
87473
87550
|
remaining -= size;
|
|
87474
87551
|
if (!remaining) break;
|
|
87475
87552
|
}
|
|
@@ -87486,12 +87563,12 @@ function renderWorkspaceFrame(state, rawWidth, rawHeight, body, options = {}) {
|
|
|
87486
87563
|
const hintColor = state.focus === "composer" ? "#a0a0a0" : "#ff553b";
|
|
87487
87564
|
const composer = [];
|
|
87488
87565
|
if (showComposer) {
|
|
87489
|
-
const inputRows = inputLines.slice(-composerRows).map((
|
|
87490
|
-
if (contentWidth < 6) composer.push(...inputRows.map((
|
|
87566
|
+
const inputRows = inputLines.slice(-composerRows).map((text6, i) => `${i ? " " : "> "}${text6 || (!state.input ? placeholder : "")}`);
|
|
87567
|
+
if (contentWidth < 6) composer.push(...inputRows.map((text6) => place(padCells(text6, contentWidth))), place(foreground(padCells(hint, contentWidth), hintColor, mode)), place(" ".repeat(contentWidth)), place(" ".repeat(contentWidth)));
|
|
87491
87568
|
else {
|
|
87492
87569
|
const edge = (left, right) => place(foreground(left + line.repeat(contentWidth - 2) + right, "#6b6b6b", mode));
|
|
87493
|
-
const inputRow = (
|
|
87494
|
-
composer.push(edge(ascii ? "+" : "\u256D", ascii ? "+" : "\u256E"), ...inputRows.map((
|
|
87570
|
+
const inputRow = (text6, color) => place(foreground(vertical, "#6b6b6b", mode) + " " + foreground(padCells(text6, contentWidth - 4), color ?? "#e6e6e6", mode) + " " + foreground(vertical, "#6b6b6b", mode));
|
|
87571
|
+
composer.push(edge(ascii ? "+" : "\u256D", ascii ? "+" : "\u256E"), ...inputRows.map((text6) => inputRow(text6)), inputRow(hint, hintColor), edge(ascii ? "+" : "\u2570", ascii ? "+" : "\u256F"));
|
|
87495
87572
|
}
|
|
87496
87573
|
}
|
|
87497
87574
|
const frame = [
|
|
@@ -87543,8 +87620,8 @@ function renderCardCarousel(cards, width, selectedIndex, focused) {
|
|
|
87543
87620
|
return { text: spans.map((span) => span.text).join(""), spans };
|
|
87544
87621
|
});
|
|
87545
87622
|
}
|
|
87546
|
-
function centeredCarouselText(
|
|
87547
|
-
const value = truncateCells(
|
|
87623
|
+
function centeredCarouselText(text6, width) {
|
|
87624
|
+
const value = truncateCells(text6, width);
|
|
87548
87625
|
return " ".repeat(Math.max(0, Math.floor((width - cells(value)) / 2))) + value;
|
|
87549
87626
|
}
|
|
87550
87627
|
|
|
@@ -87824,7 +87901,7 @@ function homeHeader(state, width, height) {
|
|
|
87824
87901
|
const title = inspiration?.feature?.title || inspiration?.title || "Daily inspiration";
|
|
87825
87902
|
const banner = [centered2(`DAILY INSPIRATION ${state.focus === "inspiration" ? "\u2039 Enter open \u203A" : "\u2039 Ctrl+O explore \u203A"}`, width), "", ...parts.map((line) => centered2(line, width)), centered2(title, width)];
|
|
87826
87903
|
while (banner.length < rows2) banner.push("");
|
|
87827
|
-
banner.forEach((
|
|
87904
|
+
banner.forEach((text6) => result.push({ text: text6, background: gradient.start }));
|
|
87828
87905
|
result.push("", { text: centered2(state.workspace === "apps" ? prompts.apps : state.username ? `Hey ${state.username}!` : "Hey there!", width), bold: true });
|
|
87829
87906
|
if (state.workspace !== "chats" || !homeChatItems(state).length) result.push({ text: centered2(state.workspace === "apps" ? "Use your apps directly and return to saved results." : prompts[state.workspace], width), color: "#cfcfcf" });
|
|
87830
87907
|
result.push("");
|
|
@@ -87860,14 +87937,14 @@ function renderHomeChatCards(state, width, height) {
|
|
|
87860
87937
|
import { randomBytes as randomBytes10, randomUUID as randomUUID18 } from "crypto";
|
|
87861
87938
|
|
|
87862
87939
|
// ../ui/src/components/apps/appsSkillFormUtils.ts
|
|
87863
|
-
var
|
|
87940
|
+
var object2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
87864
87941
|
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
87865
87942
|
var pathParts = (path2) => path2.split(".").filter(Boolean).map((part) => part.endsWith("[]") ? part.slice(0, -2) : part);
|
|
87866
87943
|
function resolveSkillSchema(schema, root, seen = /* @__PURE__ */ new Set()) {
|
|
87867
87944
|
if (schema.$ref) {
|
|
87868
87945
|
const reference = schema.$ref;
|
|
87869
87946
|
if (!reference.startsWith("#/") || seen.has(reference)) return schema;
|
|
87870
|
-
const resolved = reference.slice(2).split("/").reduce((value, part) =>
|
|
87947
|
+
const resolved = reference.slice(2).split("/").reduce((value, part) => object2(value)[part.replace(/~1/g, "/").replace(/~0/g, "~")], root);
|
|
87871
87948
|
if (!resolved || typeof resolved !== "object") return schema;
|
|
87872
87949
|
return resolveSkillSchema({ ...resolved, ...schema, $ref: void 0 }, root, /* @__PURE__ */ new Set([...Array.from(seen), reference]));
|
|
87873
87950
|
}
|
|
@@ -87881,7 +87958,7 @@ function resolveSkillSchema(schema, root, seen = /* @__PURE__ */ new Set()) {
|
|
|
87881
87958
|
function getSkillPath(input, path2) {
|
|
87882
87959
|
let cursor = input;
|
|
87883
87960
|
for (const part of path2.split(".").filter(Boolean)) {
|
|
87884
|
-
cursor =
|
|
87961
|
+
cursor = object2(cursor)[part.replace(/\[\]$/, "")];
|
|
87885
87962
|
if (part.endsWith("[]")) cursor = Array.isArray(cursor) ? cursor[0] : void 0;
|
|
87886
87963
|
}
|
|
87887
87964
|
return cursor;
|
|
@@ -87892,7 +87969,7 @@ function setSkillPath(input, path2, value) {
|
|
|
87892
87969
|
if (index === parts.length) return value;
|
|
87893
87970
|
const part = parts[index];
|
|
87894
87971
|
const key = part.replace(/\[\]$/, "");
|
|
87895
|
-
const parent = { ...
|
|
87972
|
+
const parent = { ...object2(current) };
|
|
87896
87973
|
if (part.endsWith("[]")) {
|
|
87897
87974
|
const entries = Array.isArray(parent[key]) ? [...parent[key]] : [];
|
|
87898
87975
|
entries[0] = update(entries[0], index + 1);
|
|
@@ -87915,17 +87992,17 @@ function prepareSkillInput(schema, input, timezone, now = /* @__PURE__ */ new Da
|
|
|
87915
87992
|
const isoDate = (ordinal) => new Date(ordinal * 864e5).toISOString().slice(0, 10);
|
|
87916
87993
|
function walk(node, value) {
|
|
87917
87994
|
const resolved = resolveSkillSchema(node, schema);
|
|
87918
|
-
const token =
|
|
87995
|
+
const token = object2(value).$date;
|
|
87919
87996
|
if (typeof token === "string") {
|
|
87920
87997
|
const weekday = (new Date(today * 864e5).getUTCDay() + 6) % 7;
|
|
87921
87998
|
const ordinal = token === "today" || token === "today_end" || token === "next_seven_days_start" ? today : token === "next_seven_days_end" ? today + 6 : token === "next_week_start" ? today + 7 - weekday : token === "next_week_end" ? today + 13 - weekday : null;
|
|
87922
87999
|
if (ordinal === null) return value;
|
|
87923
88000
|
const date = isoDate(ordinal);
|
|
87924
|
-
return
|
|
88001
|
+
return object2(value).format === "datetime" || resolved.format === "date-time" ? `${date}T${token.endsWith("_end") ? "23:59:59" : "00:00:00"}[${timezone}]` : date;
|
|
87925
88002
|
}
|
|
87926
88003
|
if (resolved.type === "array" && Array.isArray(value)) return value.map((item) => walk(resolved.items ?? {}, item));
|
|
87927
88004
|
if ((resolved.type === "object" || resolved.properties) && value && typeof value === "object" && !Array.isArray(value)) {
|
|
87928
|
-
const prepared = { ...
|
|
88005
|
+
const prepared = { ...object2(value) };
|
|
87929
88006
|
for (const [name, child] of Object.entries(resolved.properties ?? {})) {
|
|
87930
88007
|
if (own(prepared, name)) prepared[name] = walk(child, prepared[name]);
|
|
87931
88008
|
}
|
|
@@ -87958,7 +88035,7 @@ function validateSkillInput(schema, input) {
|
|
|
87958
88035
|
issues.push({ path: path2, code: "type" });
|
|
87959
88036
|
return;
|
|
87960
88037
|
}
|
|
87961
|
-
for (const [name, child] of Object.entries(field.properties ?? {})) walk(child,
|
|
88038
|
+
for (const [name, child] of Object.entries(field.properties ?? {})) walk(child, object2(value)[name], path2 ? `${path2}.${name}` : name, (field.required ?? []).includes(name));
|
|
87962
88039
|
} else if (field.type === "array") {
|
|
87963
88040
|
if (!Array.isArray(value)) {
|
|
87964
88041
|
issues.push({ path: path2, code: "type" });
|
|
@@ -88505,21 +88582,21 @@ function embedPreview(embedId, type, content, appId, skillId, action, width) {
|
|
|
88505
88582
|
}
|
|
88506
88583
|
function readableFields(value, width) {
|
|
88507
88584
|
const lines = [];
|
|
88508
|
-
function
|
|
88585
|
+
function visit2(label3, item, indent) {
|
|
88509
88586
|
if (Array.isArray(item)) {
|
|
88510
88587
|
lines.push(`${indent}${label3} (${item.length})`);
|
|
88511
|
-
item.forEach((entry, index) =>
|
|
88588
|
+
item.forEach((entry, index) => visit2(`${index + 1}.`, entry, `${indent} `));
|
|
88512
88589
|
} else if (item && typeof item === "object") {
|
|
88513
88590
|
lines.push(`${indent}${label3}`);
|
|
88514
|
-
for (const [key, entry] of Object.entries(item))
|
|
88591
|
+
for (const [key, entry] of Object.entries(item)) visit2(readableLabel(key), entry, `${indent} `);
|
|
88515
88592
|
} else {
|
|
88516
|
-
const
|
|
88517
|
-
const [first = "", ...rest] =
|
|
88593
|
+
const text6 = item === null ? "None" : typeof item === "boolean" ? item ? "Yes" : "No" : String(item);
|
|
88594
|
+
const [first = "", ...rest] = text6.split("\n");
|
|
88518
88595
|
lines.push(`${indent}${label3} ${first}`);
|
|
88519
88596
|
lines.push(...rest.map((line) => `${indent} ${line}`));
|
|
88520
88597
|
}
|
|
88521
88598
|
}
|
|
88522
|
-
for (const [key, item] of Object.entries(value))
|
|
88599
|
+
for (const [key, item] of Object.entries(value)) visit2(`${readableLabel(key)}:`, item, "");
|
|
88523
88600
|
return lines.flatMap((line) => textLines(line, width));
|
|
88524
88601
|
}
|
|
88525
88602
|
function readableLabel(key) {
|
|
@@ -88714,7 +88791,7 @@ function renderTuiFrame(state, width, height, options = {}) {
|
|
|
88714
88791
|
return renderWorkspaceFrame(state, width, height, renderBody(state, bodyWidth, height), { ...options, stickyRows, headerRows: state.screen === "chat" || state.screen === "example" ? renderChatHeader(state, bodyWidth).length : void 0 });
|
|
88715
88792
|
}
|
|
88716
88793
|
function coloredHero(lines, rows2, gradient = PRIMARY_GRADIENT) {
|
|
88717
|
-
return lines.map((
|
|
88794
|
+
return lines.map((text6, index) => index < rows2 ? { text: text6, background: gradient.start } : text6);
|
|
88718
88795
|
}
|
|
88719
88796
|
var blueHero = (lines, rows2) => coloredHero(lines, rows2);
|
|
88720
88797
|
function homeCards(lines, width, gradients) {
|
|
@@ -88726,7 +88803,7 @@ function homeCards(lines, width, gradients) {
|
|
|
88726
88803
|
}
|
|
88727
88804
|
return groups.filter((group) => group.length).flatMap((group, index) => {
|
|
88728
88805
|
const cardWidth = Math.min(width, Math.max(...group.map(cells))), inset = Math.max(0, Math.floor((width - cardWidth) / 2));
|
|
88729
|
-
return [...group.map((
|
|
88806
|
+
return [...group.map((text6) => ({ text: text6, background: (gradients[index] ?? PRIMARY_GRADIENT).start, inset })), ""];
|
|
88730
88807
|
});
|
|
88731
88808
|
}
|
|
88732
88809
|
function renderBody(state, width, height) {
|
|
@@ -89080,9 +89157,9 @@ function required(value) {
|
|
|
89080
89157
|
return value;
|
|
89081
89158
|
}
|
|
89082
89159
|
function authoringReplacementPatch(path2, original, content) {
|
|
89083
|
-
const lines = (
|
|
89084
|
-
if (!
|
|
89085
|
-
const parts =
|
|
89160
|
+
const lines = (text6, prefix) => {
|
|
89161
|
+
if (!text6) return { count: 0, rows: [] };
|
|
89162
|
+
const parts = text6.split("\n");
|
|
89086
89163
|
const newline = parts.at(-1) === "";
|
|
89087
89164
|
if (newline) parts.pop();
|
|
89088
89165
|
const rows2 = parts.map((line) => prefix + line);
|
|
@@ -89187,8 +89264,8 @@ async function persistCliProjectAuthoringJob(client2, job, approvedDigest) {
|
|
|
89187
89264
|
for (const row of detail.items) {
|
|
89188
89265
|
if (!["embed", "upload"].includes(row.item_type) || row.deleted_target_state) continue;
|
|
89189
89266
|
const target = await decryptWithAesGcmCombined(row.target_id_encrypted, projectKey);
|
|
89190
|
-
const
|
|
89191
|
-
const meta =
|
|
89267
|
+
const text6 = row.encrypted_metadata ? await decryptWithAesGcmCombined(row.encrypted_metadata, projectKey) : null;
|
|
89268
|
+
const meta = text6 ? record6(JSON.parse(text6)) : {};
|
|
89192
89269
|
const filePath = meta.path ?? meta.file_path ?? meta.filename ?? meta.display_path;
|
|
89193
89270
|
if (target && typeof filePath === "string") files.push({ embedId: target, path: filePath });
|
|
89194
89271
|
}
|
|
@@ -89869,8 +89946,8 @@ async function handleWorkspaceCommand(context, command) {
|
|
|
89869
89946
|
if (request !== state.routeVersion) return true;
|
|
89870
89947
|
state.detailTitle = embed.textPreview || (embed.appId ? `${embed.appId}${embed.skillId ? `/${embed.skillId}` : ""}` : embed.type?.replaceAll("_", " ")) || "Embed";
|
|
89871
89948
|
const body = embed.content;
|
|
89872
|
-
const
|
|
89873
|
-
state.detailLines = typeof
|
|
89949
|
+
const text6 = ["code", "markdown", "content", "text", "transcript"].map((key) => body?.[key]).find((value) => typeof value === "string");
|
|
89950
|
+
state.detailLines = typeof text6 === "string" ? text6.split("\n") : formatEmbedPreviewLines(embed, 100);
|
|
89874
89951
|
}
|
|
89875
89952
|
render();
|
|
89876
89953
|
return true;
|
|
@@ -90369,10 +90446,10 @@ async function handleWorkspaceKey(context, chunk, key) {
|
|
|
90369
90446
|
state.filter = "";
|
|
90370
90447
|
}
|
|
90371
90448
|
} else if (file) {
|
|
90372
|
-
const
|
|
90449
|
+
const text6 = await readTuiProjectFile(context.client, project, file);
|
|
90373
90450
|
if (request === state.routeVersion && state.activeProject?.id === project.id) {
|
|
90374
90451
|
state.detailTitle = file.name;
|
|
90375
|
-
state.detailLines =
|
|
90452
|
+
state.detailLines = text6.split("\n");
|
|
90376
90453
|
state.screen = "embed";
|
|
90377
90454
|
state.scrollOffset = 0;
|
|
90378
90455
|
}
|
|
@@ -90457,9 +90534,9 @@ async function handleWorkspaceKey(context, chunk, key) {
|
|
|
90457
90534
|
return true;
|
|
90458
90535
|
}
|
|
90459
90536
|
if (key.name === "return" && state.screen === "chats" && state.input.trim()) {
|
|
90460
|
-
const
|
|
90537
|
+
const text6 = state.input.trim();
|
|
90461
90538
|
newChat(state);
|
|
90462
|
-
await context.send(
|
|
90539
|
+
await context.send(text6);
|
|
90463
90540
|
return true;
|
|
90464
90541
|
}
|
|
90465
90542
|
const cursor = state.inputCursor ?? state.input.length;
|
|
@@ -90501,9 +90578,9 @@ async function handleWorkspaceKey(context, chunk, key) {
|
|
|
90501
90578
|
return true;
|
|
90502
90579
|
}
|
|
90503
90580
|
if (key.name === "paste" || !key.ctrl && !key.meta && chunk && chunk >= " ") {
|
|
90504
|
-
const
|
|
90505
|
-
state.input = state.input.slice(0, cursor) +
|
|
90506
|
-
state.inputCursor = cursor +
|
|
90581
|
+
const text6 = terminalText(chunk);
|
|
90582
|
+
state.input = state.input.slice(0, cursor) + text6 + state.input.slice(cursor);
|
|
90583
|
+
state.inputCursor = cursor + text6.length;
|
|
90507
90584
|
rememberDraft(state);
|
|
90508
90585
|
render();
|
|
90509
90586
|
return true;
|
|
@@ -90884,13 +90961,13 @@ async function handleEnter(params) {
|
|
|
90884
90961
|
render();
|
|
90885
90962
|
return;
|
|
90886
90963
|
}
|
|
90887
|
-
const
|
|
90888
|
-
if (!
|
|
90889
|
-
if (
|
|
90890
|
-
await handleCommand({ command:
|
|
90964
|
+
const text6 = state.input.trim();
|
|
90965
|
+
if (!text6) return;
|
|
90966
|
+
if (text6.startsWith("/")) {
|
|
90967
|
+
await handleCommand({ command: text6, state, client: client2, terminal, render, finish });
|
|
90891
90968
|
return;
|
|
90892
90969
|
}
|
|
90893
|
-
await sendTuiMessage({ message:
|
|
90970
|
+
await sendTuiMessage({ message: text6, state, client: client2, render });
|
|
90894
90971
|
}
|
|
90895
90972
|
async function handleCommand(params) {
|
|
90896
90973
|
const { command, state, client: client2, terminal, render, finish } = params;
|
|
@@ -95138,11 +95215,11 @@ function validateSummary(value) {
|
|
|
95138
95215
|
if (item.protocol_version !== 1) throw new Error("Invalid remote command protocol version");
|
|
95139
95216
|
return {
|
|
95140
95217
|
protocol_version: 1,
|
|
95141
|
-
execution_id:
|
|
95142
|
-
chat_id:
|
|
95143
|
-
project_id:
|
|
95144
|
-
source_id:
|
|
95145
|
-
state:
|
|
95218
|
+
execution_id: identifier4(item.execution_id, "execution_id"),
|
|
95219
|
+
chat_id: identifier4(item.chat_id, "chat_id"),
|
|
95220
|
+
project_id: identifier4(item.project_id, "project_id"),
|
|
95221
|
+
source_id: identifier4(item.source_id, "source_id"),
|
|
95222
|
+
state: text5(item.state, "state"),
|
|
95146
95223
|
last_sequence: integer3(item.last_sequence ?? -1, "last_sequence", -1),
|
|
95147
95224
|
lease_expires_at: integer3(item.lease_expires_at ?? 0, "lease_expires_at", 0)
|
|
95148
95225
|
};
|
|
@@ -95154,16 +95231,16 @@ function validateClaimedRequest(value, summary, binding, sourceSessionId) {
|
|
|
95154
95231
|
return {
|
|
95155
95232
|
...item,
|
|
95156
95233
|
protocol_version: 1,
|
|
95157
|
-
execution_id:
|
|
95158
|
-
chat_id:
|
|
95159
|
-
project_id:
|
|
95160
|
-
source_id:
|
|
95161
|
-
state:
|
|
95162
|
-
encrypted_request:
|
|
95163
|
-
request_digest:
|
|
95234
|
+
execution_id: identifier4(item.execution_id, "execution_id"),
|
|
95235
|
+
chat_id: identifier4(item.chat_id, "chat_id"),
|
|
95236
|
+
project_id: identifier4(item.project_id, "project_id"),
|
|
95237
|
+
source_id: identifier4(item.source_id, "source_id"),
|
|
95238
|
+
state: text5(item.state, "state"),
|
|
95239
|
+
encrypted_request: text5(item.encrypted_request, "encrypted_request"),
|
|
95240
|
+
request_digest: text5(item.request_digest, "request_digest"),
|
|
95164
95241
|
approval,
|
|
95165
95242
|
key_epoch: integer3(item.key_epoch, "key_epoch", 1),
|
|
95166
|
-
lease_token:
|
|
95243
|
+
lease_token: text5(item.lease_token, "lease_token"),
|
|
95167
95244
|
lease_generation: integer3(item.lease_generation, "lease_generation", 1),
|
|
95168
95245
|
lease_expires_at: integer3(item.lease_expires_at, "lease_expires_at", 1),
|
|
95169
95246
|
last_sequence: integer3(item.last_sequence ?? -1, "last_sequence", -1),
|
|
@@ -95176,7 +95253,7 @@ function validateLeaseResponse(value, executionId) {
|
|
|
95176
95253
|
return {
|
|
95177
95254
|
...item,
|
|
95178
95255
|
execution_id: executionId,
|
|
95179
|
-
lease_token:
|
|
95256
|
+
lease_token: text5(item.lease_token, "lease_token"),
|
|
95180
95257
|
lease_generation: integer3(item.lease_generation, "lease_generation", 1),
|
|
95181
95258
|
lease_expires_at: integer3(item.lease_expires_at, "lease_expires_at", 1),
|
|
95182
95259
|
last_sequence: integer3(item.last_sequence ?? -1, "last_sequence", -1),
|
|
@@ -95191,10 +95268,10 @@ function parsePortableRequest(plaintext) {
|
|
|
95191
95268
|
const policy = parsePolicy(item.policy);
|
|
95192
95269
|
const request = {
|
|
95193
95270
|
protocol_version: 1,
|
|
95194
|
-
execution_id:
|
|
95195
|
-
chat_id:
|
|
95196
|
-
project_id:
|
|
95197
|
-
source_id:
|
|
95271
|
+
execution_id: identifier4(item.execution_id, "execution_id"),
|
|
95272
|
+
chat_id: identifier4(item.chat_id, "chat_id"),
|
|
95273
|
+
project_id: identifier4(item.project_id, "project_id"),
|
|
95274
|
+
source_id: identifier4(item.source_id, "source_id"),
|
|
95198
95275
|
policy,
|
|
95199
95276
|
approval: parseApproval(item.approval)
|
|
95200
95277
|
};
|
|
@@ -95220,12 +95297,12 @@ function parsePolicy(value) {
|
|
|
95220
95297
|
if (!Array.isArray(policy.credential_profiles) || policy.credential_profiles.some((item) => typeof item !== "string")) throw new Error("Invalid credential profiles");
|
|
95221
95298
|
return {
|
|
95222
95299
|
argv: [...policy.argv],
|
|
95223
|
-
cwd:
|
|
95300
|
+
cwd: text5(policy.cwd, "cwd"),
|
|
95224
95301
|
mode: oneOf3(policy.mode, ["foreground", "background"], "mode"),
|
|
95225
95302
|
source_access: oneOf3(policy.source_access, ["read_only", "read_write"], "source_access"),
|
|
95226
95303
|
deadline_ms: integer3(policy.deadline_ms, "deadline_ms", 100),
|
|
95227
95304
|
writable_profiles: [...policy.writable_profiles],
|
|
95228
|
-
network_profile: policy.network_profile === null ? null :
|
|
95305
|
+
network_profile: policy.network_profile === null ? null : text5(policy.network_profile, "network_profile"),
|
|
95229
95306
|
credential_profiles: [...policy.credential_profiles]
|
|
95230
95307
|
};
|
|
95231
95308
|
}
|
|
@@ -95239,7 +95316,7 @@ function parseApproval(value) {
|
|
|
95239
95316
|
if (approval.kind !== "preset" || typeof approval.definition_digest !== "string" || !/^[a-f0-9]{64}$/i.test(approval.definition_digest)) throw new Error("Invalid preset approval");
|
|
95240
95317
|
return {
|
|
95241
95318
|
kind: "preset",
|
|
95242
|
-
preset_id:
|
|
95319
|
+
preset_id: identifier4(approval.preset_id, "preset_id"),
|
|
95243
95320
|
definition_digest: approval.definition_digest
|
|
95244
95321
|
};
|
|
95245
95322
|
}
|
|
@@ -95254,16 +95331,16 @@ function validateTrustedGrants(value) {
|
|
|
95254
95331
|
}
|
|
95255
95332
|
const result = {
|
|
95256
95333
|
writable_targets: value.writable_targets.map((item) => ({
|
|
95257
|
-
profile_id:
|
|
95258
|
-
host_path:
|
|
95334
|
+
profile_id: identifier4(item.profile_id, "writable profile"),
|
|
95335
|
+
host_path: text5(item.host_path, "writable host path")
|
|
95259
95336
|
})),
|
|
95260
95337
|
network_profiles: value.network_profiles.map((item) => {
|
|
95261
95338
|
if (!Array.isArray(item.destinations) || item.destinations.some((destination) => typeof destination !== "string")) {
|
|
95262
95339
|
throw new RemoteCommandError("resource_not_granted", "Trusted network grant is invalid");
|
|
95263
95340
|
}
|
|
95264
95341
|
return {
|
|
95265
|
-
profile_id:
|
|
95266
|
-
destinations: item.destinations.map((destination) =>
|
|
95342
|
+
profile_id: identifier4(item.profile_id, "network profile"),
|
|
95343
|
+
destinations: item.destinations.map((destination) => text5(destination, "network destination"))
|
|
95267
95344
|
};
|
|
95268
95345
|
}),
|
|
95269
95346
|
credential_profiles: value.credential_profiles.map((item) => {
|
|
@@ -95271,7 +95348,7 @@ function validateTrustedGrants(value) {
|
|
|
95271
95348
|
throw new RemoteCommandError("credential_unavailable", "Trusted credential grant is invalid");
|
|
95272
95349
|
}
|
|
95273
95350
|
return {
|
|
95274
|
-
profile_id:
|
|
95351
|
+
profile_id: identifier4(item.profile_id, "credential profile"),
|
|
95275
95352
|
environment: { ...item.environment }
|
|
95276
95353
|
};
|
|
95277
95354
|
})
|
|
@@ -95347,14 +95424,14 @@ function record7(value, context) {
|
|
|
95347
95424
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid ${context}`);
|
|
95348
95425
|
return value;
|
|
95349
95426
|
}
|
|
95350
|
-
function exactKeys2(value,
|
|
95351
|
-
if (Object.keys(value).length !==
|
|
95427
|
+
function exactKeys2(value, keys2) {
|
|
95428
|
+
if (Object.keys(value).length !== keys2.length || Object.keys(value).some((key) => !keys2.includes(key))) throw new Error("Remote command request contains unexpected fields");
|
|
95352
95429
|
}
|
|
95353
|
-
function
|
|
95430
|
+
function identifier4(value, context) {
|
|
95354
95431
|
if (typeof value !== "string" || !IDENTIFIER3.test(value)) throw new Error(`Invalid ${context}`);
|
|
95355
95432
|
return value;
|
|
95356
95433
|
}
|
|
95357
|
-
function
|
|
95434
|
+
function text5(value, context) {
|
|
95358
95435
|
if (typeof value !== "string" || !value || value.length > 1048576 || value.includes("\0")) throw new Error(`Invalid ${context}`);
|
|
95359
95436
|
return value;
|
|
95360
95437
|
}
|
|
@@ -95436,7 +95513,7 @@ function resolveRemoteAccessRoots(pathFlag, cwd = process.cwd()) {
|
|
|
95436
95513
|
function discoverRemoteAccessRepositories(roots) {
|
|
95437
95514
|
const repositoryRoots = /* @__PURE__ */ new Set();
|
|
95438
95515
|
const permissionDenied = [];
|
|
95439
|
-
const
|
|
95516
|
+
const visit2 = (directory, approvedRoot) => {
|
|
95440
95517
|
let entries;
|
|
95441
95518
|
try {
|
|
95442
95519
|
entries = readdirSync12(directory, { withFileTypes: true });
|
|
@@ -95453,10 +95530,10 @@ function discoverRemoteAccessRepositories(roots) {
|
|
|
95453
95530
|
}
|
|
95454
95531
|
for (const entry of entries) {
|
|
95455
95532
|
if (entry.name === ".git" || entry.isSymbolicLink() || !entry.isDirectory()) continue;
|
|
95456
|
-
|
|
95533
|
+
visit2(join25(directory, entry.name), approvedRoot);
|
|
95457
95534
|
}
|
|
95458
95535
|
};
|
|
95459
|
-
for (const root of roots)
|
|
95536
|
+
for (const root of roots) visit2(root, root);
|
|
95460
95537
|
return {
|
|
95461
95538
|
repositories: [...repositoryRoots].sort().map((rootPath) => ({ rootPath, displayName: rootPath.split(/[\\/]/).filter(Boolean).pop() ?? rootPath })),
|
|
95462
95539
|
permissionDenied: permissionDenied.sort()
|
|
@@ -97178,15 +97255,15 @@ function validateWorkRecoveryDocument(value) {
|
|
|
97178
97255
|
}
|
|
97179
97256
|
const visiting = /* @__PURE__ */ new Set();
|
|
97180
97257
|
const visited = /* @__PURE__ */ new Set();
|
|
97181
|
-
const
|
|
97258
|
+
const visit2 = (node) => {
|
|
97182
97259
|
if (visiting.has(node)) throw new Error(`Work recovery dependency cycle includes ${node}.`);
|
|
97183
97260
|
if (visited.has(node)) return;
|
|
97184
97261
|
visiting.add(node);
|
|
97185
|
-
for (const next of graph.get(node) ?? [])
|
|
97262
|
+
for (const next of graph.get(node) ?? []) visit2(next);
|
|
97186
97263
|
visiting.delete(node);
|
|
97187
97264
|
visited.add(node);
|
|
97188
97265
|
};
|
|
97189
|
-
for (const node of graph.keys())
|
|
97266
|
+
for (const node of graph.keys()) visit2(node);
|
|
97190
97267
|
}
|
|
97191
97268
|
function findRecoveryConflicts(document, projectId, current) {
|
|
97192
97269
|
if (document.project.project_id !== projectId) return [{ kind: "plan", id: document.project.project_id, reason: "wrong_project" }];
|
|
@@ -99364,10 +99441,10 @@ async function handlePlans(client2, subcommand, rest, flags, redactor) {
|
|
|
99364
99441
|
else console.log(`Plan success criterion updated: ${updated.criterion_id}`);
|
|
99365
99442
|
return;
|
|
99366
99443
|
}
|
|
99367
|
-
const
|
|
99444
|
+
const text6 = requiredStringFlag(flags.text ?? rest.slice(2).join(" "), "--text <criterion>");
|
|
99368
99445
|
const criterion = await buildCreatePlanCriterionInput(plan, masterKey, {
|
|
99369
99446
|
criterionId: typeof flags.id === "string" ? flags.id : void 0,
|
|
99370
|
-
text:
|
|
99447
|
+
text: text6,
|
|
99371
99448
|
type: typeof flags.type === "string" ? flags.type : void 0,
|
|
99372
99449
|
status: typeof flags.status === "string" ? flags.status : void 0,
|
|
99373
99450
|
required: flags.required === true ? true : flags.optional === true ? false : void 0,
|
|
@@ -99642,7 +99719,7 @@ async function handleWorkRecovery(client2, subcommand, rest, flags) {
|
|
|
99642
99719
|
if (subcommand === "validate" || subcommand === "restore") {
|
|
99643
99720
|
const path2 = requiredStringFlag(flags.file ?? rest[0], "--file <projection.yml>");
|
|
99644
99721
|
if (!existsSync24(path2)) throw new Error(`Recovery projection does not exist: ${path2}`);
|
|
99645
|
-
const document =
|
|
99722
|
+
const document = parseYaml(readFileSync22(path2, "utf8"));
|
|
99646
99723
|
validateWorkRecoveryDocument(document);
|
|
99647
99724
|
if (subcommand === "validate") {
|
|
99648
99725
|
if (flags.json === true) printJson2({ valid: true });
|
|
@@ -101130,8 +101207,8 @@ function taskAssignFlag(flags) {
|
|
|
101130
101207
|
return typeof flags.assign === "string" ? flags.assign : typeof flags.assignee === "string" ? flags.assignee : void 0;
|
|
101131
101208
|
}
|
|
101132
101209
|
function labelFlags(flags, ...names) {
|
|
101133
|
-
const
|
|
101134
|
-
return normalizeLabels(
|
|
101210
|
+
const keys2 = names.length > 0 ? names : ["label", "labels", "tag", "tags"];
|
|
101211
|
+
return normalizeLabels(keys2.flatMap((key) => splitCsvFlag(flags[key])));
|
|
101135
101212
|
}
|
|
101136
101213
|
async function handleRemoteAccess(client2, subcommand, rest, flags) {
|
|
101137
101214
|
if (!subcommand || subcommand === "help" || flags.help === true) {
|
|
@@ -101540,11 +101617,11 @@ async function handleIdeaBucket(client2, subcommand, rest, flags) {
|
|
|
101540
101617
|
return;
|
|
101541
101618
|
}
|
|
101542
101619
|
if (subcommand === "add") {
|
|
101543
|
-
const
|
|
101544
|
-
if (!
|
|
101620
|
+
const text6 = rest.join(" ").trim();
|
|
101621
|
+
if (!text6) throw new Error("Missing IdeaBucket text for add.");
|
|
101545
101622
|
const scheduledSendAt = typeof flags["scheduled-at"] === "string" ? parseUnixSecondsFlag(flags["scheduled-at"], "--scheduled-at") : void 0;
|
|
101546
101623
|
printJson2(await client2.addIdeaBucketText({
|
|
101547
|
-
text:
|
|
101624
|
+
text: text6,
|
|
101548
101625
|
chatId: typeof flags.chat === "string" ? flags.chat : void 0,
|
|
101549
101626
|
bucketId: typeof flags.bucket === "string" ? flags.bucket : void 0,
|
|
101550
101627
|
scheduledSendAt,
|
|
@@ -101638,11 +101715,11 @@ function renderRemoteCommandEvent(event) {
|
|
|
101638
101715
|
if (event.event_kind === "output") {
|
|
101639
101716
|
const raw = typeof event.payload.text === "string" ? event.payload.text : "";
|
|
101640
101717
|
const limit = 24e3;
|
|
101641
|
-
const
|
|
101718
|
+
const text6 = escapeTerminalControls(raw.slice(0, limit));
|
|
101642
101719
|
const omitted = raw.length > limit ? `
|
|
101643
101720
|
[${raw.length - limit} characters omitted from this display]` : "";
|
|
101644
101721
|
return `Unreviewed command output (inert) ${identity2}:
|
|
101645
|
-
${
|
|
101722
|
+
${text6}${omitted}`;
|
|
101646
101723
|
}
|
|
101647
101724
|
if (event.event_kind === "output_truncated") {
|
|
101648
101725
|
return `Command output was truncated upstream (${identity2}); displayed output does not cover the full process transcript.`;
|
|
@@ -101656,9 +101733,9 @@ ${text5}${omitted}`;
|
|
|
101656
101733
|
var EXPLICIT_PROJECT_MENTION = /@project:([A-Za-z0-9](?:[A-Za-z0-9_-]|\.(?=[A-Za-z0-9]))*)/gi;
|
|
101657
101734
|
function extractExplicitProjectMentions(message) {
|
|
101658
101735
|
const matches2 = Array.from(message.matchAll(EXPLICIT_PROJECT_MENTION), (match) => match[1]);
|
|
101659
|
-
const
|
|
101660
|
-
for (const target of matches2)
|
|
101661
|
-
return [...
|
|
101736
|
+
const unique3 = /* @__PURE__ */ new Map();
|
|
101737
|
+
for (const target of matches2) unique3.set(target.toLocaleLowerCase("en-US"), target);
|
|
101738
|
+
return [...unique3.values()];
|
|
101662
101739
|
}
|
|
101663
101740
|
async function resolveExplicitChatProject(client2, masterKey, message, flags, context) {
|
|
101664
101741
|
const mentions = extractExplicitProjectMentions(message);
|
|
@@ -102321,19 +102398,19 @@ ${deleted}/${resolved.length} chat(s) deleted.`);
|
|
|
102321
102398
|
if (embed.type === "app_skill_use" && embed.appId === "videos" && (embed.skillId === "get_transcript" || embed.skillId === "get-transcript") && embed.content) {
|
|
102322
102399
|
const results = embed.content.results ?? embed.content.data ?? [];
|
|
102323
102400
|
if (Array.isArray(results) && results.length > 0) {
|
|
102324
|
-
let
|
|
102401
|
+
let text6 = "";
|
|
102325
102402
|
for (const r of results) {
|
|
102326
102403
|
const meta = r.metadata;
|
|
102327
|
-
if (meta?.title)
|
|
102404
|
+
if (meta?.title) text6 += `# ${meta.title}
|
|
102328
102405
|
|
|
102329
102406
|
`;
|
|
102330
|
-
if (r.url)
|
|
102407
|
+
if (r.url) text6 += `Source: ${r.url}
|
|
102331
102408
|
|
|
102332
102409
|
`;
|
|
102333
|
-
|
|
102410
|
+
text6 += String(
|
|
102334
102411
|
r.transcript ?? r.formatted_transcript ?? r.text ?? r.content ?? ""
|
|
102335
102412
|
);
|
|
102336
|
-
|
|
102413
|
+
text6 += "\n\n---\n\n";
|
|
102337
102414
|
}
|
|
102338
102415
|
let fname = `${eid.slice(0, 8)}_transcript.md`;
|
|
102339
102416
|
const firstMeta = results[0]?.metadata;
|
|
@@ -102343,7 +102420,7 @@ ${deleted}/${resolved.length} chat(s) deleted.`);
|
|
|
102343
102420
|
transcriptEmbeds.push({
|
|
102344
102421
|
embedId: eid,
|
|
102345
102422
|
filename: fname,
|
|
102346
|
-
content:
|
|
102423
|
+
content: text6
|
|
102347
102424
|
});
|
|
102348
102425
|
}
|
|
102349
102426
|
}
|
|
@@ -103026,8 +103103,8 @@ async function syncCliBoundWorkflowFiles(client2, workflow, flags) {
|
|
|
103026
103103
|
const contents = await client2.listProjectItems(project.projectId, context);
|
|
103027
103104
|
for (const item of contents.items.filter((item2) => item2.item_type === "workflow")) {
|
|
103028
103105
|
if (await decryptOptionalProjectField2(item.target_id_encrypted, project.projectKey) !== workflow.id) continue;
|
|
103029
|
-
const
|
|
103030
|
-
const metadata =
|
|
103106
|
+
const text6 = await decryptOptionalProjectField2(item.encrypted_metadata, project.projectKey);
|
|
103107
|
+
const metadata = text6 ? JSON.parse(text6) : {};
|
|
103031
103108
|
const binding = metadata.remote_workflow_file;
|
|
103032
103109
|
if (!binding) continue;
|
|
103033
103110
|
const source = (await client2.listProjectSources(project.projectId, context)).find((item2) => item2.source_id === binding.source_id);
|
|
@@ -103317,10 +103394,10 @@ async function handleWorkflows(client2, subcommand, rest, flags, redactor) {
|
|
|
103317
103394
|
return;
|
|
103318
103395
|
}
|
|
103319
103396
|
if (subcommand === "input") {
|
|
103320
|
-
const
|
|
103321
|
-
if (!
|
|
103397
|
+
const text6 = typeof flags.text === "string" ? flags.text : rest.join(" ").trim();
|
|
103398
|
+
if (!text6) throw new Error('Missing workflow input text. Example: openmates workflows ask "alert me if it rains"');
|
|
103322
103399
|
const session = await client2.startWorkflowInput({
|
|
103323
|
-
text:
|
|
103400
|
+
text: text6,
|
|
103324
103401
|
selectedWorkflowId: typeof flags["workflow-id"] === "string" ? flags["workflow-id"] : void 0,
|
|
103325
103402
|
selectedProjectId: typeof flags["project-id"] === "string" ? flags["project-id"] : void 0,
|
|
103326
103403
|
timezone: typeof flags.timezone === "string" ? flags.timezone : Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
@@ -103367,9 +103444,9 @@ async function handleWorkflows(client2, subcommand, rest, flags, redactor) {
|
|
|
103367
103444
|
}
|
|
103368
103445
|
if (subcommand === "input-follow-up") {
|
|
103369
103446
|
const sessionId = rest[0];
|
|
103370
|
-
const
|
|
103371
|
-
if (!sessionId || !
|
|
103372
|
-
const session = await client2.followUpWorkflowInput(sessionId,
|
|
103447
|
+
const text6 = typeof flags.text === "string" ? flags.text : rest.slice(1).join(" ").trim();
|
|
103448
|
+
if (!sessionId || !text6) throw new Error('Missing session ID or text. Example: openmates workflows input-follow-up <session-id> "make it weekdays only"');
|
|
103449
|
+
const session = await client2.followUpWorkflowInput(sessionId, text6);
|
|
103373
103450
|
if (flags.json === true) {
|
|
103374
103451
|
printJson2(session);
|
|
103375
103452
|
} else {
|
|
@@ -104562,10 +104639,10 @@ async function streamCodeRunToTerminal(url, jsonMode) {
|
|
|
104562
104639
|
const payload = message.payload ?? {};
|
|
104563
104640
|
if (message.type === "code_run_event") {
|
|
104564
104641
|
const kind = String(payload.kind ?? "status");
|
|
104565
|
-
const
|
|
104642
|
+
const text6 = String(payload.text ?? "");
|
|
104566
104643
|
if (!jsonMode) {
|
|
104567
|
-
if (kind === "stdout") process.stdout.write(
|
|
104568
|
-
else process.stderr.write(
|
|
104644
|
+
if (kind === "stdout") process.stdout.write(text6);
|
|
104645
|
+
else process.stderr.write(text6);
|
|
104569
104646
|
}
|
|
104570
104647
|
} else if (message.type === "code_run_update") {
|
|
104571
104648
|
lastStatus = { ...lastStatus, ...payload };
|
|
@@ -105354,8 +105431,8 @@ function parseChatImportPayload(raw) {
|
|
|
105354
105431
|
return parsed;
|
|
105355
105432
|
}
|
|
105356
105433
|
if (parsed && typeof parsed === "object") {
|
|
105357
|
-
const
|
|
105358
|
-
if (
|
|
105434
|
+
const object3 = parsed;
|
|
105435
|
+
if (object3.chat || object3.messages) return { chats: [normalizeImportedChat(object3)] };
|
|
105359
105436
|
}
|
|
105360
105437
|
throw new Error("JSON import must contain a chats array, a chat object, or messages.");
|
|
105361
105438
|
}
|
|
@@ -107038,8 +107115,8 @@ function resolveApiKey(flags) {
|
|
|
107038
107115
|
function printJson2(value) {
|
|
107039
107116
|
console.log(JSON.stringify(value, null, 2));
|
|
107040
107117
|
}
|
|
107041
|
-
function header(
|
|
107042
|
-
process.stdout.write(`\x1B[1m${
|
|
107118
|
+
function header(text6) {
|
|
107119
|
+
process.stdout.write(`\x1B[1m${text6}\x1B[0m
|
|
107043
107120
|
`);
|
|
107044
107121
|
}
|
|
107045
107122
|
function kv(key, value, keyWidth = 16) {
|
|
@@ -107805,15 +107882,15 @@ async function acceptChatTaskProposals(client2, chatId, proposals, fallbackText)
|
|
|
107805
107882
|
}
|
|
107806
107883
|
return accepted;
|
|
107807
107884
|
}
|
|
107808
|
-
function buildTaskProposalFallbackText(
|
|
107885
|
+
function buildTaskProposalFallbackText(text6) {
|
|
107809
107886
|
const seen = /* @__PURE__ */ new Set();
|
|
107810
|
-
const bulletLines =
|
|
107887
|
+
const bulletLines = text6.split("\n").map((line) => line.trim()).filter((line) => /^[-*•]\s+/.test(line)).map((line) => line.replace(/^([-*•]\s*)\[[ xX]\]\s*/, "$1")).filter((line) => {
|
|
107811
107888
|
const key = line.replace(/^[-*•]\s+/, "").trim().toLowerCase();
|
|
107812
107889
|
if (seen.has(key)) return false;
|
|
107813
107890
|
seen.add(key);
|
|
107814
107891
|
return true;
|
|
107815
107892
|
});
|
|
107816
|
-
return bulletLines.length > 0 ? bulletLines.join("\n") :
|
|
107893
|
+
return bulletLines.length > 0 ? bulletLines.join("\n") : text6;
|
|
107817
107894
|
}
|
|
107818
107895
|
function printIncognitoNoHistoryNotice(json) {
|
|
107819
107896
|
const message = "Incognito chats are not stored. There is no incognito history to show or clear.";
|
|
@@ -107847,8 +107924,8 @@ function renderEmbedFromMeta(embedId, meta) {
|
|
|
107847
107924
|
process.stdout.write(`\x1B[2m\u2514\u2500 openmates embeds show ${shortId}\x1B[0m
|
|
107848
107925
|
`);
|
|
107849
107926
|
}
|
|
107850
|
-
async function renderMessageText(
|
|
107851
|
-
const lines =
|
|
107927
|
+
async function renderMessageText(text6, embedRefIndex, client2) {
|
|
107928
|
+
const lines = text6.split("\n");
|
|
107852
107929
|
const outputLines = [];
|
|
107853
107930
|
for (const line of lines) {
|
|
107854
107931
|
const blockMatch = line.match(/^\s*\[!?\]\(embed:([^)]+)\)\s*$/);
|
|
@@ -108272,8 +108349,8 @@ No example chats are linked to ${label3} yet.`);
|
|
|
108272
108349
|
console.log(`All examples: openmates apps examples ${appId}${skillId ? ` ${skillId}` : ""}`);
|
|
108273
108350
|
}
|
|
108274
108351
|
}
|
|
108275
|
-
function wrapText(
|
|
108276
|
-
const words =
|
|
108352
|
+
function wrapText(text6, width) {
|
|
108353
|
+
const words = text6.split(" ");
|
|
108277
108354
|
const lines = [];
|
|
108278
108355
|
let current = "";
|
|
108279
108356
|
for (const w of words) {
|