@lazehq/cli 0.1.87 → 0.1.89
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 +121 -59
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -36892,14 +36892,12 @@ async function repairDamagedStateFiles() {
|
|
|
36892
36892
|
}
|
|
36893
36893
|
var LOCK_STALE_MS = 5e3;
|
|
36894
36894
|
var nowMs = () => nowInstant().epochMilliseconds;
|
|
36895
|
-
var LOCK_WAIT_MS = 3e3;
|
|
36896
36895
|
async function withStateLock({
|
|
36897
36896
|
path,
|
|
36898
36897
|
work
|
|
36899
36898
|
}) {
|
|
36900
36899
|
const lock = `${path}.lock`;
|
|
36901
36900
|
await mkdir(dirname(lock), { recursive: true, mode: 448 });
|
|
36902
|
-
const deadline = nowMs() + LOCK_WAIT_MS;
|
|
36903
36901
|
for (; ; ) {
|
|
36904
36902
|
const handle = await open(lock, "wx", 384).catch((error63) => {
|
|
36905
36903
|
if (error63.code === "EEXIST") return void 0;
|
|
@@ -36913,7 +36911,7 @@ async function withStateLock({
|
|
|
36913
36911
|
(info) => nowMs() - info.mtimeMs,
|
|
36914
36912
|
() => 0
|
|
36915
36913
|
);
|
|
36916
|
-
if (since > LOCK_STALE_MS
|
|
36914
|
+
if (since > LOCK_STALE_MS) await rm(lock, { force: true });
|
|
36917
36915
|
else await new Promise((resolve26) => setTimeout(resolve26, 15 + Math.random() * 20));
|
|
36918
36916
|
}
|
|
36919
36917
|
try {
|
|
@@ -36945,8 +36943,24 @@ var ConfigStore = class _ConfigStore {
|
|
|
36945
36943
|
}
|
|
36946
36944
|
return { ...EMPTY, ...read4.value };
|
|
36947
36945
|
}
|
|
36946
|
+
/** Applies `change` to the newest config under the lock; undefined from it writes nothing. */
|
|
36947
|
+
async update(change2) {
|
|
36948
|
+
return withStateLock({
|
|
36949
|
+
path: this.path,
|
|
36950
|
+
work: async () => {
|
|
36951
|
+
const { config: config2, result: result2 } = change2(await this.read());
|
|
36952
|
+
if (config2) await writeStateJson({ path: this.path, value: config2, pretty: true });
|
|
36953
|
+
return result2;
|
|
36954
|
+
}
|
|
36955
|
+
});
|
|
36956
|
+
}
|
|
36957
|
+
/** Sets the profile used outside bound folders. */
|
|
36958
|
+
async setCurrent({ name: name3 }) {
|
|
36959
|
+
await this.update((config2) => ({ config: { ...config2, current: name3 }, result: void 0 }));
|
|
36960
|
+
}
|
|
36961
|
+
/** Replaces the whole config; for tests and first setup, where nothing else writes. */
|
|
36948
36962
|
async write(config2) {
|
|
36949
|
-
await
|
|
36963
|
+
await this.update(() => ({ config: config2, result: void 0 }));
|
|
36950
36964
|
}
|
|
36951
36965
|
async saveProfile({
|
|
36952
36966
|
name: name3,
|
|
@@ -36954,32 +36968,37 @@ var ConfigStore = class _ConfigStore {
|
|
|
36954
36968
|
bindDirectory,
|
|
36955
36969
|
onlyThere = false
|
|
36956
36970
|
}) {
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
|
|
36971
|
+
await this.update((config2) => ({
|
|
36972
|
+
result: void 0,
|
|
36973
|
+
config: {
|
|
36974
|
+
...config2,
|
|
36975
|
+
current: bindDirectory && (onlyThere || config2.current) ? config2.current : name3,
|
|
36976
|
+
profiles: { ...config2.profiles, [name3]: profile },
|
|
36977
|
+
bindings: bindDirectory ? { ...config2.bindings, [resolve(bindDirectory)]: name3 } : config2.bindings
|
|
36978
|
+
}
|
|
36979
|
+
}));
|
|
36964
36980
|
}
|
|
36965
36981
|
/** Keeps a profile beside the others: never the current one, bound to no folder. */
|
|
36966
36982
|
async keepProfile({ name: name3, profile }) {
|
|
36967
|
-
|
|
36968
|
-
|
|
36983
|
+
await this.update((config2) => ({
|
|
36984
|
+
result: void 0,
|
|
36985
|
+
config: { ...config2, profiles: { ...config2.profiles, [name3]: profile } }
|
|
36986
|
+
}));
|
|
36969
36987
|
}
|
|
36970
36988
|
/** Binds a harness session to a profile, so its hooks use it whatever the folder says. */
|
|
36971
36989
|
async bindSession({ session, profile }) {
|
|
36972
|
-
|
|
36973
|
-
|
|
36990
|
+
await this.update((config2) => ({
|
|
36991
|
+
result: void 0,
|
|
36992
|
+
config: { ...config2, sessions: { ...config2.sessions, [session]: profile } }
|
|
36993
|
+
}));
|
|
36974
36994
|
}
|
|
36975
36995
|
/** Keeps a profile's agent name in step with Laze; a missing or unchanged profile stays. */
|
|
36976
36996
|
async renameProfileAgent({ name: name3, agentName }) {
|
|
36977
|
-
|
|
36978
|
-
|
|
36979
|
-
|
|
36980
|
-
|
|
36981
|
-
...config2,
|
|
36982
|
-
profiles: { ...config2.profiles, [name3]: { ...profile, name: agentName } }
|
|
36997
|
+
await this.update((config2) => {
|
|
36998
|
+
const profile = config2.profiles[name3];
|
|
36999
|
+
if (!profile || profile.name === agentName) return { result: void 0 };
|
|
37000
|
+
const profiles2 = { ...config2.profiles, [name3]: { ...profile, name: agentName } };
|
|
37001
|
+
return { result: void 0, config: { ...config2, profiles: profiles2 } };
|
|
36983
37002
|
});
|
|
36984
37003
|
}
|
|
36985
37004
|
/** Sets or clears how the connect service delivers to a profile; false when there is none. */
|
|
@@ -36987,43 +37006,48 @@ var ConfigStore = class _ConfigStore {
|
|
|
36987
37006
|
name: name3,
|
|
36988
37007
|
delivery
|
|
36989
37008
|
}) {
|
|
36990
|
-
|
|
36991
|
-
|
|
36992
|
-
|
|
36993
|
-
|
|
36994
|
-
|
|
36995
|
-
|
|
36996
|
-
|
|
37009
|
+
return this.update((config2) => {
|
|
37010
|
+
const profile = config2.profiles[name3];
|
|
37011
|
+
if (!profile) return { result: false };
|
|
37012
|
+
const { delivery: _old, ...rest } = profile;
|
|
37013
|
+
const updated = delivery ? { ...rest, delivery } : rest;
|
|
37014
|
+
return {
|
|
37015
|
+
result: true,
|
|
37016
|
+
config: { ...config2, profiles: { ...config2.profiles, [name3]: updated } }
|
|
37017
|
+
};
|
|
37018
|
+
});
|
|
36997
37019
|
}
|
|
36998
37020
|
/** Marks a profile migrated; false when there is none. */
|
|
36999
37021
|
async markMigrated({ name: name3, migrated }) {
|
|
37000
|
-
|
|
37001
|
-
|
|
37002
|
-
|
|
37003
|
-
|
|
37004
|
-
...config2,
|
|
37005
|
-
profiles: { ...config2.profiles, [name3]: { ...profile, migrated } }
|
|
37022
|
+
return this.update((config2) => {
|
|
37023
|
+
const profile = config2.profiles[name3];
|
|
37024
|
+
if (!profile) return { result: false };
|
|
37025
|
+
const profiles2 = { ...config2.profiles, [name3]: { ...profile, migrated } };
|
|
37026
|
+
return { result: true, config: { ...config2, profiles: profiles2 } };
|
|
37006
37027
|
});
|
|
37007
|
-
return true;
|
|
37008
37028
|
}
|
|
37009
37029
|
async removeProfile({ name: name3 }) {
|
|
37010
|
-
|
|
37011
|
-
|
|
37012
|
-
|
|
37013
|
-
|
|
37014
|
-
);
|
|
37015
|
-
const bindings = Object.fromEntries(
|
|
37016
|
-
Object.entries(config2.bindings).filter(([, bound]) => bound !== name3)
|
|
37017
|
-
);
|
|
37018
|
-
const sessions = Object.fromEntries(
|
|
37019
|
-
Object.entries(config2.sessions ?? {}).filter(([, bound]) => bound !== name3)
|
|
37020
|
-
);
|
|
37021
|
-
const usable = Object.keys(profiles2).find((key) => profiles2[key]?.kind !== "request");
|
|
37022
|
-
const current3 = config2.current === name3 ? usable : config2.current;
|
|
37023
|
-
await this.write({ current: current3, profiles: profiles2, bindings, sessions });
|
|
37024
|
-
return true;
|
|
37030
|
+
return this.update((config2) => {
|
|
37031
|
+
const removed = withoutProfile({ config: config2, name: name3 });
|
|
37032
|
+
return removed ? { result: true, config: removed } : { result: false };
|
|
37033
|
+
});
|
|
37025
37034
|
}
|
|
37026
37035
|
};
|
|
37036
|
+
function withoutProfile({ config: config2, name: name3 }) {
|
|
37037
|
+
if (!config2.profiles[name3]) return void 0;
|
|
37038
|
+
const profiles2 = Object.fromEntries(
|
|
37039
|
+
Object.entries(config2.profiles).filter(([key]) => key !== name3)
|
|
37040
|
+
);
|
|
37041
|
+
const bindings = Object.fromEntries(
|
|
37042
|
+
Object.entries(config2.bindings).filter(([, bound]) => bound !== name3)
|
|
37043
|
+
);
|
|
37044
|
+
const sessions = Object.fromEntries(
|
|
37045
|
+
Object.entries(config2.sessions ?? {}).filter(([, bound]) => bound !== name3)
|
|
37046
|
+
);
|
|
37047
|
+
const usable = Object.keys(profiles2).find((key) => profiles2[key]?.kind !== "request");
|
|
37048
|
+
const current3 = config2.current === name3 ? usable : config2.current;
|
|
37049
|
+
return { current: current3, profiles: profiles2, bindings, sessions };
|
|
37050
|
+
}
|
|
37027
37051
|
function chooseProfile({
|
|
37028
37052
|
config: config2,
|
|
37029
37053
|
flag: flag2,
|
|
@@ -37130,7 +37154,7 @@ function flagText({
|
|
|
37130
37154
|
}
|
|
37131
37155
|
|
|
37132
37156
|
// src/rules/cli-version.rules.ts
|
|
37133
|
-
var STAMPED = "0.1.
|
|
37157
|
+
var STAMPED = "0.1.89";
|
|
37134
37158
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
37135
37159
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
37136
37160
|
}
|
|
@@ -70243,10 +70267,11 @@ async function reportMachine({
|
|
|
70243
70267
|
if (!host2) return;
|
|
70244
70268
|
const stamp = createHash("sha256").update(`${token2}:${host2}`).digest("hex");
|
|
70245
70269
|
const path = statePathOf({ context, kind: "machine", profile });
|
|
70246
|
-
|
|
70270
|
+
const noted = await readFile3(path, "utf8").catch(() => "");
|
|
70271
|
+
if (noted === JSON.stringify(stamp) || noted === stamp) return;
|
|
70247
70272
|
try {
|
|
70248
70273
|
await client.post("/api/agents/me/machine", { host: host2 });
|
|
70249
|
-
await writeStateText({ path, text: stamp });
|
|
70274
|
+
await writeStateText({ path, text: JSON.stringify(stamp) });
|
|
70250
70275
|
} catch {
|
|
70251
70276
|
return;
|
|
70252
70277
|
}
|
|
@@ -71654,6 +71679,8 @@ var slackConfig = Config.define((c) => ({
|
|
|
71654
71679
|
),
|
|
71655
71680
|
/** How long a delivery's timestamp may be old before its signature counts as replayed. */
|
|
71656
71681
|
signatureMaxAgeSeconds: c.env("SLACK_SIGNATURE_MAX_AGE_SECONDS", positiveInt4.default(300)),
|
|
71682
|
+
/** The progress board's alerts folder; unset, the missed-events card is only logged. */
|
|
71683
|
+
opsAlertDir: c.env("SLACK_OPS_ALERT_DIR", external_exports.string().min(1).optional()),
|
|
71657
71684
|
/** The longest wait between two Socket Mode reconnects. */
|
|
71658
71685
|
reconnectMaxSeconds: c.env("SLACK_RECONNECT_MAX_SECONDS", positiveInt4.default(30))
|
|
71659
71686
|
}));
|
|
@@ -74857,7 +74884,8 @@ async function installLaunchd({ context }) {
|
|
|
74857
74884
|
}
|
|
74858
74885
|
async function installDetached({ context }) {
|
|
74859
74886
|
const log = logPathOf({ context });
|
|
74860
|
-
const
|
|
74887
|
+
const argv = runArgvOf({ context });
|
|
74888
|
+
const pid = context.processes.spawnDetached({ argv, logPath: log, orphan: true });
|
|
74861
74889
|
return { manager: "detached", name: serviceNameOf({ context }), pid, log };
|
|
74862
74890
|
}
|
|
74863
74891
|
async function managerOf({ context }) {
|
|
@@ -75741,7 +75769,7 @@ function cliLineOf({
|
|
|
75741
75769
|
}
|
|
75742
75770
|
var SKILL = `---
|
|
75743
75771
|
name: laze
|
|
75744
|
-
description: Work in a Laze workspace as an agent - read your inbox, reply to messages, post in channels
|
|
75772
|
+
description: Work in a Laze workspace as an agent - read your inbox, reply to messages, post in channels, search history and build Laze apps (also called artifacts) with the laze CLI. Use when a Laze message reaches you, or someone in Laze asks you to post, reply, look something up or make an artifact, page, dashboard or deck.
|
|
75745
75773
|
---
|
|
75746
75774
|
|
|
75747
75775
|
# Laze
|
|
@@ -75831,6 +75859,10 @@ open cards by title and ranks them for them alone.
|
|
|
75831
75859
|
|
|
75832
75860
|
## Apps
|
|
75833
75861
|
|
|
75862
|
+
Apps are also called artifacts. When someone in Laze asks for an artifact, a page, a dashboard, a
|
|
75863
|
+
deck or a mock, build a Laze app and post it in the conversation, not a claude.ai artifact, unless
|
|
75864
|
+
the person asks for that specifically.
|
|
75865
|
+
|
|
75834
75866
|
Asked for an app (a tracker, a CRM, a dashboard, a page that explains something), read the full
|
|
75835
75867
|
guide first: https://laze.so/docs/agents/apps.md. The short version:
|
|
75836
75868
|
|
|
@@ -79686,6 +79718,7 @@ var deleteAppUserByKeyInputSchemaDefinition = deleteAppUserInputSchema.omit(byKe
|
|
|
79686
79718
|
var appListByKeyQuerySchemaDefinition = external_exports.object({ archived: external_exports.enum(["true"]).optional() });
|
|
79687
79719
|
|
|
79688
79720
|
// ../../modules/app/contract/src/app.cli.ts
|
|
79721
|
+
var APP_ARTIFACT_RULE = "Apps are also called artifacts. When someone in Laze asks for an artifact, a page, a dashboard, a deck or a mock, build a Laze app and post it in the conversation, not a claude.ai artifact, unless the person asks for that specifically.";
|
|
79689
79722
|
var APP_MANIFEST_FILE = "laze.app.json";
|
|
79690
79723
|
var appManifestSchemaDefinition = external_exports.object({
|
|
79691
79724
|
app: external_exports.object({ id: external_exports.string().min(1), name: external_exports.string(), slug: appSlugSchema }),
|
|
@@ -80864,6 +80897,8 @@ async function connectedTurnTokenOf({
|
|
|
80864
80897
|
|
|
80865
80898
|
// src/services/app-commands.service.ts
|
|
80866
80899
|
var USAGE5 = `Usage: laze app <command>. The app comes from ${APP_MANIFEST_FILE} in the folder, or --app <id|slug>.
|
|
80900
|
+
${APP_ARTIFACT_RULE}
|
|
80901
|
+
${APP_ARTIFACT_RULE}
|
|
80867
80902
|
|
|
80868
80903
|
${appCliCommands.map((entry) => ` ${entry.command} ${entry.arguments.join(" ")}
|
|
80869
80904
|
${entry.summary}`).join("\n")}`;
|
|
@@ -89855,7 +89890,7 @@ async function switchTo({ context, args }) {
|
|
|
89855
89890
|
`Not signed in to ${target.name} on this machine: run laze login --profile <name> and pick ${target.name} when you approve it.`
|
|
89856
89891
|
);
|
|
89857
89892
|
}
|
|
89858
|
-
await context.store.
|
|
89893
|
+
await context.store.setCurrent({ name: chosen });
|
|
89859
89894
|
print7({
|
|
89860
89895
|
context,
|
|
89861
89896
|
args,
|
|
@@ -99587,6 +99622,7 @@ var HELP = `laze: work in a Laze workspace from your terminal or your agent.
|
|
|
99587
99622
|
laze wiki list|get|put|search|history|mv|rm the workspace wiki
|
|
99588
99623
|
laze skill list|install|show|pull|rm|update|pin|unpin your agent's skills and the catalogue
|
|
99589
99624
|
laze app create <name> ... build an app from scratch (--template slides for a deck), push, revert
|
|
99625
|
+
apps are also called artifacts: asked for an artifact, page, dashboard, deck or mock, build a Laze app
|
|
99590
99626
|
laze app every laze app command, with its flags
|
|
99591
99627
|
laze agents list | laze agents status <name> the workspace's agents and their context
|
|
99592
99628
|
laze agents show <name> [--json] an agent's profile: kind, how it runs, intelligence
|
|
@@ -100235,8 +100271,8 @@ function machineProofFetch({
|
|
|
100235
100271
|
}
|
|
100236
100272
|
|
|
100237
100273
|
// src/services/processes.service.ts
|
|
100238
|
-
import { execFile as execFile3, spawn as spawn4 } from "node:child_process";
|
|
100239
|
-
import { mkdirSync, openSync } from "node:fs";
|
|
100274
|
+
import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
|
|
100275
|
+
import { closeSync, mkdirSync, openSync } from "node:fs";
|
|
100240
100276
|
import { readFile as readFile37, readlink } from "node:fs/promises";
|
|
100241
100277
|
import { dirname as dirname25 } from "node:path";
|
|
100242
100278
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -100274,9 +100310,35 @@ async function cwdOf(pid) {
|
|
|
100274
100310
|
const line = listed?.stdout.split("\n").find((each) => each.startsWith("n"));
|
|
100275
100311
|
return line ? line.slice(1) : void 0;
|
|
100276
100312
|
}
|
|
100277
|
-
|
|
100313
|
+
var ORPHAN_SCRIPT = [
|
|
100314
|
+
"if command -v setsid >/dev/null 2>&1; then",
|
|
100315
|
+
' setsid "$@" </dev/null >&3 2>&3 &',
|
|
100316
|
+
"else",
|
|
100317
|
+
' "$@" </dev/null >&3 2>&3 &',
|
|
100318
|
+
"fi",
|
|
100319
|
+
'echo "$!"'
|
|
100320
|
+
].join("\n");
|
|
100321
|
+
function spawnOrphan({ argv, log }) {
|
|
100322
|
+
const shell = spawnSync("sh", ["-c", ORPHAN_SCRIPT, "sh", ...argv], {
|
|
100323
|
+
stdio: ["ignore", "pipe", "ignore", log],
|
|
100324
|
+
encoding: "utf8"
|
|
100325
|
+
});
|
|
100326
|
+
return Number(shell.stdout.trim()) || 0;
|
|
100327
|
+
}
|
|
100328
|
+
function spawnDetached({
|
|
100329
|
+
argv,
|
|
100330
|
+
logPath,
|
|
100331
|
+
orphan = false
|
|
100332
|
+
}) {
|
|
100278
100333
|
mkdirSync(dirname25(logPath), { recursive: true, mode: 448 });
|
|
100279
100334
|
const log = openSync(logPath, "a", 384);
|
|
100335
|
+
if (orphan) {
|
|
100336
|
+
try {
|
|
100337
|
+
return spawnOrphan({ argv, log });
|
|
100338
|
+
} finally {
|
|
100339
|
+
closeSync(log);
|
|
100340
|
+
}
|
|
100341
|
+
}
|
|
100280
100342
|
const [program = "", ...rest] = argv;
|
|
100281
100343
|
const child = spawn4(program, rest, { detached: true, stdio: ["ignore", log, log] });
|
|
100282
100344
|
child.unref();
|
package/package.json
CHANGED