@lazehq/cli 0.1.125 → 0.1.126
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/laze.mjs +47 -15
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -36960,7 +36960,7 @@ function shadowedLinkLineOf({ shadow }) {
|
|
|
36960
36960
|
}
|
|
36961
36961
|
|
|
36962
36962
|
// src/rules/cli-version.rules.ts
|
|
36963
|
-
var STAMPED = "0.1.
|
|
36963
|
+
var STAMPED = "0.1.126";
|
|
36964
36964
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
36965
36965
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
36966
36966
|
}
|
|
@@ -61533,13 +61533,19 @@ var scrubVaultEventTextsInputSchemaDefinition = external_exports.object({
|
|
|
61533
61533
|
session: external_exports.object({ agentId: external_exports.string().min(1), channelId: external_exports.string() }).optional()
|
|
61534
61534
|
});
|
|
61535
61535
|
var VAULT_SESSION_SCRUB_MAX_LINES = 200;
|
|
61536
|
-
var VAULT_SESSION_SCRUB_MAX_LINE =
|
|
61536
|
+
var VAULT_SESSION_SCRUB_MAX_LINE = 64e3;
|
|
61537
|
+
var VAULT_SESSION_SCRUB_MAX_TEXT = 256e3;
|
|
61538
|
+
var vaultSessionScrubTextsSchemaDefinition = external_exports.array(external_exports.string().max(VAULT_SESSION_SCRUB_MAX_LINE)).max(VAULT_SESSION_SCRUB_MAX_LINES).refine(
|
|
61539
|
+
(texts) => texts.reduce((total, text3) => total + text3.length, 0) <= VAULT_SESSION_SCRUB_MAX_TEXT,
|
|
61540
|
+
{ message: `At most ${VAULT_SESSION_SCRUB_MAX_TEXT} characters of session lines per request` }
|
|
61541
|
+
);
|
|
61542
|
+
var vaultSessionScrubTextsSchema = vaultSessionScrubTextsSchemaDefinition;
|
|
61537
61543
|
var scrubSessionTextsInputSchemaDefinition = external_exports.object({
|
|
61538
61544
|
workspaceId: external_exports.string().min(1),
|
|
61539
61545
|
agentId: external_exports.string().min(1),
|
|
61540
61546
|
/** The agent module's view of the agent: its reach follows its owner. */
|
|
61541
61547
|
owner: external_exports.object({ agentKind: external_exports.enum(["personal", "team"]), ownerUserId: external_exports.string().min(1) }),
|
|
61542
|
-
texts:
|
|
61548
|
+
texts: vaultSessionScrubTextsSchema
|
|
61543
61549
|
});
|
|
61544
61550
|
var hideVaultNamesInputSchemaDefinition = external_exports.object({
|
|
61545
61551
|
workspaceId: external_exports.string().min(1),
|
|
@@ -71854,7 +71860,7 @@ var agentVaultReleaseStatusInputSchemaDefinition = external_exports.object({
|
|
|
71854
71860
|
channelId: external_exports.string().min(1).max(80).nullable().default(null)
|
|
71855
71861
|
});
|
|
71856
71862
|
var agentSessionScrubInputSchemaDefinition = external_exports.object({
|
|
71857
|
-
texts:
|
|
71863
|
+
texts: vaultSessionScrubTextsSchema
|
|
71858
71864
|
});
|
|
71859
71865
|
var agentSessionScrubbedSchemaDefinition = external_exports.object({
|
|
71860
71866
|
texts: external_exports.array(external_exports.string()),
|
|
@@ -79997,9 +80003,10 @@ import { dirname as dirname15, join as join20 } from "node:path";
|
|
|
79997
80003
|
// src/rules/session-scrub.rules.ts
|
|
79998
80004
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
79999
80005
|
var SESSION_SCRUB_BATCH_LINES = 200;
|
|
80000
|
-
var SESSION_SCRUB_BATCH_BYTES =
|
|
80006
|
+
var SESSION_SCRUB_BATCH_BYTES = VAULT_SESSION_SCRUB_MAX_TEXT;
|
|
80001
80007
|
var SESSION_SCRUB_MAX_BATCHES = 8;
|
|
80002
|
-
var
|
|
80008
|
+
var SESSION_SCRUB_READ_BYTES = SESSION_SCRUB_BATCH_BYTES * SESSION_SCRUB_MAX_BATCHES;
|
|
80009
|
+
var SESSION_SCRUB_MAX_LINE = VAULT_SESSION_SCRUB_MAX_LINE;
|
|
80003
80010
|
function completeLinesOf({ chunk, from }) {
|
|
80004
80011
|
const lines2 = [];
|
|
80005
80012
|
let start2 = 0;
|
|
@@ -80096,6 +80103,19 @@ async function writeBack({ file: file4, rewrites }) {
|
|
|
80096
80103
|
await file4.truncate(first.line.at + out.length);
|
|
80097
80104
|
return moved;
|
|
80098
80105
|
}
|
|
80106
|
+
async function pastLongLine({
|
|
80107
|
+
file: file4,
|
|
80108
|
+
from,
|
|
80109
|
+
size
|
|
80110
|
+
}) {
|
|
80111
|
+
const chunk = Buffer3.alloc(SESSION_SCRUB_READ_BYTES);
|
|
80112
|
+
for (let at8 = from; at8 < size; at8 += chunk.length) {
|
|
80113
|
+
const { bytesRead } = await file4.read(chunk, 0, chunk.length, at8);
|
|
80114
|
+
const newline = chunk.subarray(0, bytesRead).indexOf(10);
|
|
80115
|
+
if (newline !== -1) return at8 + newline + 1;
|
|
80116
|
+
}
|
|
80117
|
+
return from;
|
|
80118
|
+
}
|
|
80099
80119
|
async function scrubOwnSession({
|
|
80100
80120
|
context,
|
|
80101
80121
|
client,
|
|
@@ -80107,27 +80127,39 @@ async function scrubOwnSession({
|
|
|
80107
80127
|
const size = (await file4.stat()).size;
|
|
80108
80128
|
const saved3 = await offsetOf({ path: statePath2 });
|
|
80109
80129
|
const from = saved3 > size ? 0 : saved3;
|
|
80110
|
-
const chunk = Buffer3.alloc(size - from);
|
|
80130
|
+
const chunk = Buffer3.alloc(Math.min(size - from, SESSION_SCRUB_READ_BYTES));
|
|
80111
80131
|
await file4.read(chunk, 0, chunk.length, from);
|
|
80112
80132
|
const complete = completeLinesOf({ chunk, from });
|
|
80113
80133
|
const { lines: lines2 } = complete;
|
|
80134
|
+
if (lines2.length === 0 && chunk.length === SESSION_SCRUB_READ_BYTES) {
|
|
80135
|
+
await keepOffset({ path: statePath2, offset: await pastLongLine({ file: file4, from, size }) });
|
|
80136
|
+
return { lines: 0 };
|
|
80137
|
+
}
|
|
80114
80138
|
const rewrites = [];
|
|
80115
80139
|
const batches = batchesOf({ lines: lines2 });
|
|
80116
80140
|
let reached = from;
|
|
80141
|
+
let failure2;
|
|
80117
80142
|
for (const batch2 of batches.slice(0, SESSION_SCRUB_MAX_BATCHES)) {
|
|
80118
|
-
|
|
80119
|
-
|
|
80120
|
-
|
|
80121
|
-
|
|
80122
|
-
|
|
80123
|
-
|
|
80124
|
-
|
|
80143
|
+
try {
|
|
80144
|
+
const answer6 = await client.post("/api/agents/me/vault/session-scrub", {
|
|
80145
|
+
texts: batch2.map((line) => line.text)
|
|
80146
|
+
});
|
|
80147
|
+
batch2.forEach((line, index) => {
|
|
80148
|
+
const text3 = rewriteOf({ before: line.text, after: answer6.texts[index] ?? line.text });
|
|
80149
|
+
if (text3 !== void 0) rewrites.push({ line, text: text3 });
|
|
80150
|
+
});
|
|
80151
|
+
} catch (error63) {
|
|
80152
|
+
failure2 = error63;
|
|
80153
|
+
break;
|
|
80154
|
+
}
|
|
80125
80155
|
const last = batch2.at(-1);
|
|
80126
80156
|
if (last) reached = last.at + last.bytes + 1;
|
|
80127
80157
|
}
|
|
80128
|
-
const
|
|
80158
|
+
const whole = failure2 === void 0 && batches.length <= SESSION_SCRUB_MAX_BATCHES;
|
|
80159
|
+
const end = whole ? complete.end : reached;
|
|
80129
80160
|
const moved = await writeBack({ file: file4, rewrites });
|
|
80130
80161
|
await keepOffset({ path: statePath2, offset: end + moved });
|
|
80162
|
+
if (failure2 !== void 0) throw failure2;
|
|
80131
80163
|
return { lines: rewrites.length };
|
|
80132
80164
|
} finally {
|
|
80133
80165
|
await file4.close();
|
package/package.json
CHANGED