@lazehq/cli 0.1.88 → 0.1.90
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 +445 -198
- package/package.json +1 -1
package/dist/laze.mjs
CHANGED
|
@@ -37026,6 +37026,23 @@ var ConfigStore = class _ConfigStore {
|
|
|
37026
37026
|
return { result: true, config: { ...config2, profiles: profiles2 } };
|
|
37027
37027
|
});
|
|
37028
37028
|
}
|
|
37029
|
+
/**
|
|
37030
|
+
* Marks the profile's key refused, or clears it, only while the profile still holds `token`;
|
|
37031
|
+
* true when that changed whether the profile is marked.
|
|
37032
|
+
*/
|
|
37033
|
+
async markRefused({
|
|
37034
|
+
name: name3,
|
|
37035
|
+
token: token2,
|
|
37036
|
+
refused
|
|
37037
|
+
}) {
|
|
37038
|
+
return this.update((config2) => {
|
|
37039
|
+
const profile = config2.profiles[name3];
|
|
37040
|
+
if (profile?.token !== token2) return { result: false };
|
|
37041
|
+
const { refused: old, ...rest } = profile;
|
|
37042
|
+
const profiles2 = { ...config2.profiles, [name3]: refused ? { ...rest, refused } : rest };
|
|
37043
|
+
return { result: !old !== !refused, config: { ...config2, profiles: profiles2 } };
|
|
37044
|
+
});
|
|
37045
|
+
}
|
|
37029
37046
|
async removeProfile({ name: name3 }) {
|
|
37030
37047
|
return this.update((config2) => {
|
|
37031
37048
|
const removed = withoutProfile({ config: config2, name: name3 });
|
|
@@ -37154,11 +37171,21 @@ function flagText({
|
|
|
37154
37171
|
}
|
|
37155
37172
|
|
|
37156
37173
|
// src/rules/cli-version.rules.ts
|
|
37157
|
-
var STAMPED = "0.1.
|
|
37174
|
+
var STAMPED = "0.1.90";
|
|
37158
37175
|
function cliVersionOf({ stamped = STAMPED } = {}) {
|
|
37159
37176
|
return stamped.startsWith("__") ? "dev" : stamped;
|
|
37160
37177
|
}
|
|
37161
37178
|
|
|
37179
|
+
// src/rules/refusal-format.rules.ts
|
|
37180
|
+
function refusalText({ code, message: message2 }) {
|
|
37181
|
+
const sentence = message2.trim().replace(/[.!]*$/, ".");
|
|
37182
|
+
return `${code}: ${sentence}`;
|
|
37183
|
+
}
|
|
37184
|
+
function refusalLine({ code, message: message2 }) {
|
|
37185
|
+
return `laze: ${refusalText({ code, message: message2 })}
|
|
37186
|
+
`;
|
|
37187
|
+
}
|
|
37188
|
+
|
|
37162
37189
|
// src/services/cli-context.ts
|
|
37163
37190
|
var CliUsageError = class extends Error {
|
|
37164
37191
|
constructor(message2) {
|
|
@@ -37174,6 +37201,13 @@ var ProfileMigratedError = class extends Error {
|
|
|
37174
37201
|
}
|
|
37175
37202
|
profile;
|
|
37176
37203
|
};
|
|
37204
|
+
var ProfileRefusedError = class extends ProfileMigratedError {
|
|
37205
|
+
constructor(profile) {
|
|
37206
|
+
super(profile);
|
|
37207
|
+
this.message = `Laze refused the key of profile "${profile}".`;
|
|
37208
|
+
this.name = "ProfileRefusedError";
|
|
37209
|
+
}
|
|
37210
|
+
};
|
|
37177
37211
|
|
|
37178
37212
|
// src/services/session.service.ts
|
|
37179
37213
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
@@ -62374,7 +62408,13 @@ var mirrorSourceSchema = external_exports.enum([
|
|
|
62374
62408
|
"laze"
|
|
62375
62409
|
]);
|
|
62376
62410
|
var mirrorDeliverySchema = external_exports.enum(["waiting", "failed"]);
|
|
62377
|
-
var mirrorDeliveryStateSchema = external_exports.enum([
|
|
62411
|
+
var mirrorDeliveryStateSchema = external_exports.enum([
|
|
62412
|
+
"waiting",
|
|
62413
|
+
"waking",
|
|
62414
|
+
"failed",
|
|
62415
|
+
"edit_kept",
|
|
62416
|
+
"reaction_kept"
|
|
62417
|
+
]);
|
|
62378
62418
|
var messageOriginSchemaDefinition = external_exports.object({
|
|
62379
62419
|
source: mirrorSourceSchema,
|
|
62380
62420
|
/** The message's key at the source, unique in the workspace (e.g. `slack:T1:C1:1792.0001`). */
|
|
@@ -62777,6 +62817,10 @@ var messageSchemaDefinition = external_exports.object({
|
|
|
62777
62817
|
mirrorDelivery: mirrorDeliverySchema.nullable().optional(),
|
|
62778
62818
|
/** Set when the source would not take the last edit of this sent message: it is only in Laze. */
|
|
62779
62819
|
mirrorEditKept: external_exports.boolean().optional(),
|
|
62820
|
+
/** Set when the source would not take a reaction made in Laze: it is only in Laze. */
|
|
62821
|
+
mirrorReactionKept: external_exports.boolean().optional(),
|
|
62822
|
+
/** Set beside a waiting delivery while the computer that sends it is waking up. */
|
|
62823
|
+
mirrorDeliveryWaking: external_exports.boolean().optional(),
|
|
62780
62824
|
/** A thread reply also sent to its conversation: it shows in the thread and the channel. */
|
|
62781
62825
|
alsoInChannel: external_exports.boolean().optional(),
|
|
62782
62826
|
/** For a reply also sent to the channel: its root's text, for the "replied to a thread" line. */
|
|
@@ -63948,7 +63992,7 @@ var chatConversationsTrpc = defineTrpcContract("chat").query("overview", { mirro
|
|
|
63948
63992
|
var chatChannelRolesTrpc = defineTrpcContract("chat").mutation("setChannelRole").withInput(setChannelRoleInputSchema).withOutput(conversationSchema).mutation("extendChannel").withInput(extendChannelInputSchema).withOutput(conversationSchema).build();
|
|
63949
63993
|
var chatMessagesTrpc = defineTrpcContract("chat").query("history", { mirrored: historyMirror }).withInput(historyInputSchema).withOutput(historyPageSchema).query("thread").withInput(messageInputSchema).withOutput(threadSchema).query("message").withInput(messageInputSchema).withOutput(messageSchema).mutation("post").withInput(postMessageInputSchema).withOutput(messageSchema).mutation("forward").withInput(forwardMessageInputSchema).withOutput(messageSchema).mutation("addMentioned").withInput(addMentionedInputSchema).withOutput(messageSchema).mutation("edit").withInput(editMessageInputSchema).withOutput(messageSchema).mutation("delete").withInput(messageInputSchema).withOutput(messageSchema).mutation("remove").withInput(messageInputSchema).withOutput(messageSchema).mutation("react").withInput(reactInputSchema).withOutput(messageSchema).mutation("signalTyping").withInput(signalTypingInputSchema).withOutput(external_exports.object({ sent: external_exports.literal(true) })).mutation("markRead").withInput(markReadInputSchema).withOutput(external_exports.object({ lastReadSeq: external_exports.number().int().nonnegative() })).mutation("markUnread").withInput(markUnreadInputSchema).withOutput(external_exports.object({ lastReadSeq: external_exports.number().int().nonnegative() })).query("search").withInput(searchInputSchema).withOutput(searchResultSchema).build();
|
|
63950
63994
|
var chatFilesTrpc = defineTrpcContract("chat").mutation("startUpload").withInput(startUploadInputSchema).withOutput(uploadTicketSchema).mutation("completeUpload").withInput(completeUploadInputSchema).withOutput(attachmentSchema).mutation("transcribeVoiceSegment").withInput(transcribeVoiceSegmentInputSchema).withOutput(voiceSegmentTextSchema).mutation("abortUpload").withInput(fileInputSchema).withOutput(external_exports.object({ aborted: external_exports.literal(true) })).query("fileLink").withInput(fileLinkInputSchema).withOutput(fileLinkSchema).query("channelFiles").withInput(channelFilesInputSchema).withOutput(channelFilesSchema).mutation("renameAttachment").withInput(renameAttachmentInputSchema).withOutput(attachmentSchema).mutation("hideUnfurl").withInput(hideUnfurlInputSchema).withOutput(messageSchema).query("unfurlImage").withInput(unfurlImageInputSchema).withOutput(fileLinkSchema).query("searchGifs").withInput(searchGifsInputSchema).withOutput(gifResultsSchema).build();
|
|
63951
|
-
var chatFollowingTrpc = defineTrpcContract("chat").mutation("setNotify").withInput(setNotifyInputSchema).withOutput(conversationSummarySchema).mutation("hideConversation").withInput(channelInputSchema).withOutput(external_exports.object({ hidden: external_exports.literal(true) })).mutation("followThread").withInput(followThreadInputSchema).withOutput(threadFollowSchema).query("threadFollow").withInput(messageInputSchema).withOutput(threadFollowSchema).query("threads", { mirrored: threadsMirror }).withInput(threadsInputSchema).withOutput(threadsPageSchema).query("threadsUnread").withInput(workspaceInputSchema).withOutput(threadsUnreadSchema).query("notificationCount").withInput(workspaceInputSchema).withOutput(external_exports.object({ count: external_exports.number().int().nonnegative() })).mutation("markThreadRead").withInput(messageInputSchema).withOutput(external_exports.object({ read: external_exports.literal(true) })).mutation("pin").withInput(pinMessageInputSchema).withOutput(messageSchema).query("pins").withInput(channelInputSchema).withOutput(pinsPageSchema).query("saved").withInput(savedInputSchema).withOutput(savedPageSchema).query("savedMarks").withInput(workspaceInputSchema).withOutput(savedMarksSchema).mutation("saveMessage").withInput(saveMessageInputSchema).withOutput(savedStatusSchema).mutation("markSavedDone").withInput(markSavedDoneInputSchema).withOutput(savedStatusSchema).mutation("setReminder").withInput(setReminderInputSchema).withOutput(savedStatusSchema).query("activity").withInput(activityInputSchema).withOutput(activityPageSchema).mutation("markActivityRead").withInput(markActivityReadInputSchema).withOutput(external_exports.object({ read: external_exports.literal(true) })).build();
|
|
63995
|
+
var chatFollowingTrpc = defineTrpcContract("chat").mutation("setNotify").withInput(setNotifyInputSchema).withOutput(conversationSummarySchema).mutation("hideConversation").withInput(channelInputSchema).withOutput(external_exports.object({ hidden: external_exports.literal(true) })).mutation("followThread").withInput(followThreadInputSchema).withOutput(threadFollowSchema).query("threadFollow").withInput(messageInputSchema).withOutput(threadFollowSchema).query("threads", { mirrored: threadsMirror }).withInput(threadsInputSchema).withOutput(threadsPageSchema).query("threadsUnread").withInput(workspaceInputSchema).withOutput(threadsUnreadSchema).query("notificationCount").withInput(workspaceInputSchema).withOutput(external_exports.object({ count: external_exports.number().int().nonnegative() })).mutation("markThreadRead").withInput(messageInputSchema).withOutput(external_exports.object({ read: external_exports.literal(true) })).mutation("pin").withInput(pinMessageInputSchema).withOutput(messageSchema).mutation("retryMirrorDelivery").withInput(messageInputSchema).withOutput(external_exports.object({ retried: external_exports.boolean() })).query("pins").withInput(channelInputSchema).withOutput(pinsPageSchema).query("saved").withInput(savedInputSchema).withOutput(savedPageSchema).query("savedMarks").withInput(workspaceInputSchema).withOutput(savedMarksSchema).mutation("saveMessage").withInput(saveMessageInputSchema).withOutput(savedStatusSchema).mutation("markSavedDone").withInput(markSavedDoneInputSchema).withOutput(savedStatusSchema).mutation("setReminder").withInput(setReminderInputSchema).withOutput(savedStatusSchema).query("activity").withInput(activityInputSchema).withOutput(activityPageSchema).mutation("markActivityRead").withInput(markActivityReadInputSchema).withOutput(external_exports.object({ read: external_exports.literal(true) })).build();
|
|
63952
63996
|
var chatSessionTrpc = defineTrpcContract("chat").mutation("realtimeToken").withInput(workspaceInputSchema).withOutput(realtimeTokenSchema).query("drafts").withInput(workspaceInputSchema).withOutput(draftListSchema).mutation("saveDraft").withInput(saveDraftInputSchema).withOutput(draftSavedSchema).mutation("deleteDraft").withInput(deleteDraftInputSchema).withOutput(draftSavedSchema).query("sent").withInput(listSentInputSchema).withOutput(sentPageSchema).query("sidebarLayout").withInput(workspaceInputSchema).withOutput(sidebarLayoutSchema).mutation("editSidebar").withInput(editSidebarInputSchema).withOutput(sidebarLayoutSchema).query("readerPreferences").withInput(workspaceInputSchema).withOutput(readerPreferencesSchema).mutation("setReaderPreferences").withInput(setReaderPreferencesInputSchema).withOutput(readerPreferencesSchema).mutation("star").withInput(starInputSchema).withOutput(starStatusSchema).query("starred").withInput(workspaceInputSchema).withOutput(starredListSchema).mutation("scrubSecrets").withInput(scrubChatInputSchema).withOutput(chatScrubReportSchema).mutation("restoreScrubbed").withInput(messageInputSchema).withOutput(messageSchema).build();
|
|
63953
63997
|
var chatScheduledTrpc = defineTrpcContract("chat").mutation("scheduleMessage").withInput(scheduleMessageInputSchema).withOutput(scheduledMessageSchema).query("scheduled").withInput(listScheduledInputSchema).withOutput(scheduledListSchema).mutation("editScheduled").withInput(editScheduledInputSchema).withOutput(scheduledMessageSchema).mutation("sendScheduledNow").withInput(scheduledInputSchema).withOutput(scheduledMessageSchema).mutation("cancelScheduled").withInput(scheduledInputSchema).withOutput(scheduledMessageSchema).build();
|
|
63954
63998
|
var chatPresenceTrpc = defineTrpcContract("chat").mutation("heartbeat").withInput(workspaceInputSchema).withOutput(heartbeatSchema).query("presence").withInput(workspaceInputSchema).withOutput(presenceListSchema).mutation("setStatus").withInput(setStatusInputSchema).withOutput(personPresenceSchema).mutation("clearStatus").withInput(workspaceInputSchema).withOutput(personPresenceSchema).mutation("setAway").withInput(setAwayInputSchema).withOutput(personPresenceSchema).build();
|
|
@@ -65117,6 +65161,13 @@ var harnessModelSchemaDefinition = external_exports.object({
|
|
|
65117
65161
|
defaultEffort: external_exports.string().max(40).nullable().default(null)
|
|
65118
65162
|
});
|
|
65119
65163
|
var harnessModelSchema = harnessModelSchemaDefinition;
|
|
65164
|
+
var pickupTimingSchema = external_exports.object({
|
|
65165
|
+
messageId: external_exports.string().min(1),
|
|
65166
|
+
beganMs: external_exports.number().int().nonnegative(),
|
|
65167
|
+
notesMs: external_exports.number().int().nonnegative(),
|
|
65168
|
+
sessionMs: external_exports.number().int().nonnegative(),
|
|
65169
|
+
queuedMs: external_exports.number().int().nonnegative()
|
|
65170
|
+
});
|
|
65120
65171
|
var lazeAgentEventSchemaDefinition = external_exports.discriminatedUnion("type", [
|
|
65121
65172
|
external_exports.object({
|
|
65122
65173
|
type: external_exports.literal("harness_started"),
|
|
@@ -65131,7 +65182,9 @@ var lazeAgentEventSchemaDefinition = external_exports.discriminatedUnion("type",
|
|
|
65131
65182
|
type: external_exports.literal("turn_started"),
|
|
65132
65183
|
turnId: external_exports.string().min(1),
|
|
65133
65184
|
/** The Laze messages this turn answers; none for a turn the harness started on its own. */
|
|
65134
|
-
messageIds: external_exports.array(external_exports.string().min(1)).optional()
|
|
65185
|
+
messageIds: external_exports.array(external_exports.string().min(1)).optional(),
|
|
65186
|
+
/** How the supervisor spent the time from each message's arrival to this turn (ADR-201). */
|
|
65187
|
+
pickup: external_exports.array(pickupTimingSchema).max(50).optional()
|
|
65135
65188
|
}),
|
|
65136
65189
|
/** Sent to a host that (re)connects mid-turn: the turn it missed the start of, still running. */
|
|
65137
65190
|
external_exports.object({
|
|
@@ -65388,11 +65441,15 @@ var deliverMessageInputSchemaDefinition = external_exports.object({
|
|
|
65388
65441
|
attempt: external_exports.number().int().min(2).optional(),
|
|
65389
65442
|
/** The vault turn of the person who asked; the CLI presents it on vault calls. */
|
|
65390
65443
|
turnToken: external_exports.string().min(1).optional(),
|
|
65444
|
+
/** A personal agent's own turn, for its owner: what a turn the agent starts itself presents. */
|
|
65445
|
+
ownTurnToken: external_exports.string().min(1).optional(),
|
|
65391
65446
|
/** The thread the message is in; a turn joins only messages of one channel and thread. */
|
|
65392
65447
|
threadRootId: external_exports.string().min(1).optional(),
|
|
65393
65448
|
/** Files staged in the sandbox before the turn; the text lists their paths. */
|
|
65394
65449
|
files: external_exports.array(deliveredFileSchema).max(DELIVERED_FILES_MAX_COUNT).default([]),
|
|
65395
|
-
session: turnSessionSchema.optional()
|
|
65450
|
+
session: turnSessionSchema.optional(),
|
|
65451
|
+
/** When the message was posted (epoch ms), for its pickup trace; never sent to the supervisor. */
|
|
65452
|
+
postedAtMs: external_exports.number().int().nonnegative().optional()
|
|
65396
65453
|
});
|
|
65397
65454
|
var sandboxStateSchema = external_exports.enum(["absent", "created", "running", "stopped"]);
|
|
65398
65455
|
var sandboxStatusSchemaDefinition = external_exports.object({
|
|
@@ -65617,6 +65674,8 @@ var hostFrameSchemaDefinition = external_exports.discriminatedUnion("type", [
|
|
|
65617
65674
|
/** Try again's count: a later attempt is new work, not a resend of a message already seen. */
|
|
65618
65675
|
attempt: external_exports.number().int().min(2).optional(),
|
|
65619
65676
|
turnToken: external_exports.string().min(1).optional(),
|
|
65677
|
+
/** The owner's turn a personal agent presents in a turn it starts itself. */
|
|
65678
|
+
ownTurnToken: external_exports.string().min(1).optional(),
|
|
65620
65679
|
threadRootId: external_exports.string().min(1).optional(),
|
|
65621
65680
|
files: external_exports.array(deliveredFileSchema).max(10).default([]),
|
|
65622
65681
|
session: turnSessionSchema.optional()
|
|
@@ -66747,7 +66806,7 @@ var NAMING_FREE_CLI_COMMANDS = [
|
|
|
66747
66806
|
"whoami",
|
|
66748
66807
|
"history"
|
|
66749
66808
|
];
|
|
66750
|
-
var NAMING_IS_SILENT = "Naming or renaming a conversation is silent: never post a message about it
|
|
66809
|
+
var NAMING_IS_SILENT = "Naming or renaming a conversation is silent: never post a message about it.";
|
|
66751
66810
|
function namingFirstTextOf({ channelIds }) {
|
|
66752
66811
|
const lines2 = channelIds.map((id4) => ` laze conversation rename ${id4} "<a few words>"`);
|
|
66753
66812
|
return [
|
|
@@ -67995,7 +68054,9 @@ var harnessLoginEntrySchemaDefinition = external_exports.object({
|
|
|
67995
68054
|
/** When its provider's usage endpoint was last asked; null before. */
|
|
67996
68055
|
checkedAt: external_exports.iso.datetime().nullable(),
|
|
67997
68056
|
/** The agents running on this login now. */
|
|
67998
|
-
agentsOnIt: external_exports.number().int().nonnegative()
|
|
68057
|
+
agentsOnIt: external_exports.number().int().nonnegative(),
|
|
68058
|
+
/** `computer`: signed in on the person's own Laze computer, which keeps the token. */
|
|
68059
|
+
source: external_exports.enum(["keychain", "computer"]).optional()
|
|
67999
68060
|
});
|
|
68000
68061
|
var harnessLoginListSchemaDefinition = external_exports.object({
|
|
68001
68062
|
logins: external_exports.array(harnessLoginEntrySchemaDefinition)
|
|
@@ -70040,6 +70101,29 @@ var agentProfileUi = uiTokens("agent");
|
|
|
70040
70101
|
var AgentProfileSlot = agentProfileUi.component("profile");
|
|
70041
70102
|
var AgentOwnedListSlot = agentProfileUi.component("ownedList");
|
|
70042
70103
|
|
|
70104
|
+
// src/rules/linked-profile.rules.ts
|
|
70105
|
+
function slugOf(name3) {
|
|
70106
|
+
return name3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "agent";
|
|
70107
|
+
}
|
|
70108
|
+
function linkedProfileNameOf({
|
|
70109
|
+
args,
|
|
70110
|
+
linked,
|
|
70111
|
+
profiles: profiles2
|
|
70112
|
+
}) {
|
|
70113
|
+
const wanted = flagText({ args, name: "profile" }) || `agent-${slugOf(linked.agent.name)}`;
|
|
70114
|
+
const free = (name3) => {
|
|
70115
|
+
const held = profiles2[name3];
|
|
70116
|
+
return !held || held.kind === "agent" && held.agentId === linked.agent.id;
|
|
70117
|
+
};
|
|
70118
|
+
if (free(wanted)) return wanted;
|
|
70119
|
+
for (let number4 = 2; ; number4 += 1) {
|
|
70120
|
+
if (free(`${wanted}-${number4}`)) return `${wanted}-${number4}`;
|
|
70121
|
+
}
|
|
70122
|
+
}
|
|
70123
|
+
function revokedKeyLineOf({ profile }) {
|
|
70124
|
+
return `${profile}: this agent's key was revoked: run \`laze agent link\` again or remove it with \`laze logout --profile ${profile}\``;
|
|
70125
|
+
}
|
|
70126
|
+
|
|
70043
70127
|
// src/services/laze-client.service.ts
|
|
70044
70128
|
var CLI_VERSION_HEADER = "x-laze-cli-version";
|
|
70045
70129
|
var LazeApiError = class extends Error {
|
|
@@ -70075,14 +70159,16 @@ var LazeClient = class _LazeClient {
|
|
|
70075
70159
|
baseUrl,
|
|
70076
70160
|
token: token2,
|
|
70077
70161
|
fetcher,
|
|
70078
|
-
onMigrated
|
|
70162
|
+
onMigrated,
|
|
70163
|
+
onRefused
|
|
70079
70164
|
}) {
|
|
70080
70165
|
return new _LazeClient({
|
|
70081
70166
|
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
70082
70167
|
token: token2,
|
|
70083
70168
|
fetcher,
|
|
70084
70169
|
headers: {},
|
|
70085
|
-
onMigrated
|
|
70170
|
+
onMigrated,
|
|
70171
|
+
onRefused
|
|
70086
70172
|
});
|
|
70087
70173
|
}
|
|
70088
70174
|
/** The same client, sending these headers too on every call. */
|
|
@@ -70124,6 +70210,8 @@ var LazeClient = class _LazeClient {
|
|
|
70124
70210
|
const found = migratedNoticeOf(error63);
|
|
70125
70211
|
if (found && this.options.onMigrated)
|
|
70126
70212
|
await this.options.onMigrated(found).catch(() => void 0);
|
|
70213
|
+
else if (!found && error63.status === 401 && !error63.code.startsWith("http_") && this.options.onRefused)
|
|
70214
|
+
await this.options.onRefused(error63).catch(() => void 0);
|
|
70127
70215
|
}
|
|
70128
70216
|
async send({
|
|
70129
70217
|
method,
|
|
@@ -70281,6 +70369,22 @@ async function reportMachine({
|
|
|
70281
70369
|
function markMigratedOn({ context, profile }) {
|
|
70282
70370
|
return async ({ notice, link: link2 }) => context.store.markMigrated({ name: profile, migrated: { at: context.nowMs(), link: link2, notice } });
|
|
70283
70371
|
}
|
|
70372
|
+
var REFUSED_RECHECK_MS = 6 * 60 * 60 * 1e3;
|
|
70373
|
+
function markRefusedOn({
|
|
70374
|
+
context,
|
|
70375
|
+
profile,
|
|
70376
|
+
token: token2
|
|
70377
|
+
}) {
|
|
70378
|
+
return async (error63) => {
|
|
70379
|
+
const refused = { at: context.nowMs(), message: error63.message };
|
|
70380
|
+
const marked = await context.store.markRefused({ name: profile, token: token2, refused });
|
|
70381
|
+
if (marked) context.err(`${revokedKeyLineOf({ profile })}
|
|
70382
|
+
`);
|
|
70383
|
+
};
|
|
70384
|
+
}
|
|
70385
|
+
function refusedRecently({ profile, nowMs: nowMs2 }) {
|
|
70386
|
+
return profile.refused !== void 0 && nowMs2 - profile.refused.at < REFUSED_RECHECK_MS;
|
|
70387
|
+
}
|
|
70284
70388
|
function quietWhenMigrated({ args }) {
|
|
70285
70389
|
const [first = "", second = ""] = args.words;
|
|
70286
70390
|
if (first === "hook") return true;
|
|
@@ -70313,19 +70417,24 @@ async function signedIn({
|
|
|
70313
70417
|
throw new CliUsageError(
|
|
70314
70418
|
"Not signed in: run `laze login`, or `laze agent link --token <token>` from an agent."
|
|
70315
70419
|
);
|
|
70316
|
-
|
|
70317
|
-
|
|
70420
|
+
const quiet = quietWhenMigrated({ args });
|
|
70421
|
+
if (chosen.profile.migrated && quiet) throw new ProfileMigratedError(chosen.name);
|
|
70422
|
+
if (quiet && refusedRecently({ profile: chosen.profile, nowMs: context.nowMs() })) {
|
|
70423
|
+
throw new ProfileRefusedError(chosen.name);
|
|
70318
70424
|
}
|
|
70425
|
+
const turn = chosen.profile.kind === "agent" ? await turnTokenOf({ context }) : "";
|
|
70426
|
+
const { token: token2 } = chosen.profile;
|
|
70319
70427
|
const client = LazeClient.create({
|
|
70320
70428
|
baseUrl: chosen.profile.url,
|
|
70321
|
-
token:
|
|
70429
|
+
token: token2,
|
|
70322
70430
|
fetcher: context.fetcher,
|
|
70323
|
-
onMigrated: markMigratedOn({ context, profile: chosen.name })
|
|
70431
|
+
onMigrated: markMigratedOn({ context, profile: chosen.name }),
|
|
70432
|
+
...turn ? {} : { onRefused: markRefusedOn({ context, profile: chosen.name, token: token2 }) }
|
|
70324
70433
|
});
|
|
70434
|
+
if (quiet && chosen.profile.refused) await askedAgain({ context, name: chosen.name, client });
|
|
70325
70435
|
if (chosen.profile.kind !== "agent")
|
|
70326
70436
|
return { name: chosen.name, profile: chosen.profile, client };
|
|
70327
70437
|
await namingFirst({ client, args });
|
|
70328
|
-
const turn = await turnTokenOf({ context });
|
|
70329
70438
|
if (!turn) {
|
|
70330
70439
|
const { name: name3, profile } = chosen;
|
|
70331
70440
|
await reportMachine({ context, profile: name3, token: profile.token, client });
|
|
@@ -70336,6 +70445,20 @@ async function signedIn({
|
|
|
70336
70445
|
client: turn ? client.withHeaders({ "x-laze-turn": turn }) : client
|
|
70337
70446
|
};
|
|
70338
70447
|
}
|
|
70448
|
+
async function askedAgain({
|
|
70449
|
+
context,
|
|
70450
|
+
name: name3,
|
|
70451
|
+
client
|
|
70452
|
+
}) {
|
|
70453
|
+
const profile = (await context.store.read()).profiles[name3];
|
|
70454
|
+
try {
|
|
70455
|
+
await client.get("/api/agents/me");
|
|
70456
|
+
} catch (error63) {
|
|
70457
|
+
if (error63.status === 401) throw new ProfileRefusedError(name3);
|
|
70458
|
+
return;
|
|
70459
|
+
}
|
|
70460
|
+
if (profile) await context.store.markRefused({ name: name3, token: profile.token, refused: void 0 });
|
|
70461
|
+
}
|
|
70339
70462
|
var ALWAYS_FREE = [
|
|
70340
70463
|
"hook",
|
|
70341
70464
|
"adopt",
|
|
@@ -71679,6 +71802,8 @@ var slackConfig = Config.define((c) => ({
|
|
|
71679
71802
|
),
|
|
71680
71803
|
/** How long a delivery's timestamp may be old before its signature counts as replayed. */
|
|
71681
71804
|
signatureMaxAgeSeconds: c.env("SLACK_SIGNATURE_MAX_AGE_SECONDS", positiveInt4.default(300)),
|
|
71805
|
+
/** The progress board's alerts folder; unset, the missed-events card is only logged. */
|
|
71806
|
+
opsAlertDir: c.env("SLACK_OPS_ALERT_DIR", external_exports.string().min(1).optional()),
|
|
71682
71807
|
/** The longest wait between two Socket Mode reconnects. */
|
|
71683
71808
|
reconnectMaxSeconds: c.env("SLACK_RECONNECT_MAX_SECONDS", positiveInt4.default(30))
|
|
71684
71809
|
}));
|
|
@@ -71855,13 +71980,13 @@ function formatSearch({
|
|
|
71855
71980
|
}
|
|
71856
71981
|
|
|
71857
71982
|
// src/services/claude-turn.service.ts
|
|
71858
|
-
import { rm as
|
|
71859
|
-
import { dirname as
|
|
71983
|
+
import { rm as rm3 } from "node:fs/promises";
|
|
71984
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
71860
71985
|
|
|
71861
71986
|
// src/services/harness-session.service.ts
|
|
71862
|
-
import { open as open3, readdir, readFile as readFile5, stat as
|
|
71987
|
+
import { open as open3, readdir as readdir2, readFile as readFile5, stat as stat3 } from "node:fs/promises";
|
|
71863
71988
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
71864
|
-
import { dirname as
|
|
71989
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
71865
71990
|
|
|
71866
71991
|
// src/rules/claude-subagent.rules.ts
|
|
71867
71992
|
function lastCallAtOf({ text: text3, command }) {
|
|
@@ -71993,6 +72118,83 @@ async function claudeProjectOf({
|
|
|
71993
72118
|
return candidates.find((folder) => holds({ folder, inner: context.cwd })) ?? resolve2(context.cwd);
|
|
71994
72119
|
}
|
|
71995
72120
|
|
|
72121
|
+
// src/services/session-notes.service.ts
|
|
72122
|
+
import { readdir, rm as rm2, stat as stat2 } from "node:fs/promises";
|
|
72123
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
72124
|
+
function notePathOf({ context, pid }) {
|
|
72125
|
+
return statePathOf({ context, kind: "sessions", profile: String(pid) });
|
|
72126
|
+
}
|
|
72127
|
+
async function processOf({ context, pid }) {
|
|
72128
|
+
const start2 = await context.processes.startOf(pid);
|
|
72129
|
+
const command = (await context.processes.argsOf(pid))?.[0];
|
|
72130
|
+
return { ...start2 ? { start: start2 } : {}, ...command ? { command } : {} };
|
|
72131
|
+
}
|
|
72132
|
+
async function writeSessionNote({
|
|
72133
|
+
context,
|
|
72134
|
+
pid,
|
|
72135
|
+
note
|
|
72136
|
+
}) {
|
|
72137
|
+
const process2 = await processOf({ context, pid });
|
|
72138
|
+
await writeStateJson({ path: notePathOf({ context, pid }), value: { ...note, process: process2 } });
|
|
72139
|
+
}
|
|
72140
|
+
async function standingOf({
|
|
72141
|
+
context,
|
|
72142
|
+
pid,
|
|
72143
|
+
note
|
|
72144
|
+
}) {
|
|
72145
|
+
if (!context.processes.alive(pid)) return "gone";
|
|
72146
|
+
const now = await processOf({ context, pid });
|
|
72147
|
+
const was = note.process;
|
|
72148
|
+
if (was?.start && now.start) return was.start === now.start ? "live" : "stale";
|
|
72149
|
+
if (was?.command && now.command) return was.command === now.command ? "live" : "stale";
|
|
72150
|
+
if (was || !now.command) return "live";
|
|
72151
|
+
const args = await context.processes.argsOf(pid) ?? [];
|
|
72152
|
+
return args.some((word3) => /claude/i.test(word3)) ? "live" : "stale";
|
|
72153
|
+
}
|
|
72154
|
+
async function dropStale({
|
|
72155
|
+
context,
|
|
72156
|
+
pid,
|
|
72157
|
+
path,
|
|
72158
|
+
tell
|
|
72159
|
+
}) {
|
|
72160
|
+
await rm2(path, { force: true });
|
|
72161
|
+
const line = `Removed the stale session note ${path}: pid ${pid} is another process now.`;
|
|
72162
|
+
if (tell) context.err(`laze: ${line}
|
|
72163
|
+
`);
|
|
72164
|
+
return line;
|
|
72165
|
+
}
|
|
72166
|
+
async function sessionNotesOf({
|
|
72167
|
+
context,
|
|
72168
|
+
tell = true
|
|
72169
|
+
}) {
|
|
72170
|
+
const folder = dirname4(notePathOf({ context, pid: 1 }));
|
|
72171
|
+
const files2 = await readdir(folder).catch(() => []);
|
|
72172
|
+
const notes = [];
|
|
72173
|
+
const dropped = [];
|
|
72174
|
+
for (const file4 of files2) {
|
|
72175
|
+
const pid = Number(file4.replace(/\.json$/, ""));
|
|
72176
|
+
const path = join4(folder, file4);
|
|
72177
|
+
const note = pid ? await readStateJson({ path }) : void 0;
|
|
72178
|
+
if (!note) continue;
|
|
72179
|
+
const standing = await standingOf({ context, pid, note });
|
|
72180
|
+
if (standing === "stale") {
|
|
72181
|
+
dropped.push(await dropStale({ context, pid, path, tell }));
|
|
72182
|
+
continue;
|
|
72183
|
+
}
|
|
72184
|
+
const at = await stat2(path).then(
|
|
72185
|
+
(info) => info.mtimeMs,
|
|
72186
|
+
() => 0
|
|
72187
|
+
);
|
|
72188
|
+
notes.push({ pid, note, standing, at });
|
|
72189
|
+
}
|
|
72190
|
+
return { notes: notes.toSorted((a, b) => b.at - a.at), dropped };
|
|
72191
|
+
}
|
|
72192
|
+
async function noteProcessRuns({ context, pid }) {
|
|
72193
|
+
const note = await readStateJson({ path: notePathOf({ context, pid }) });
|
|
72194
|
+
if (!note) return context.processes.alive(pid);
|
|
72195
|
+
return await standingOf({ context, pid, note }) === "live";
|
|
72196
|
+
}
|
|
72197
|
+
|
|
71996
72198
|
// src/services/harness-session.service.ts
|
|
71997
72199
|
function sessionOf({
|
|
71998
72200
|
context,
|
|
@@ -72021,9 +72223,8 @@ async function rememberSession({
|
|
|
72021
72223
|
session
|
|
72022
72224
|
}) {
|
|
72023
72225
|
if (!session || !claudePid) return;
|
|
72024
|
-
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
72025
72226
|
const launch = launchEnvOf({ inherited: context.environment.inherited });
|
|
72026
|
-
await
|
|
72227
|
+
await writeSessionNote({ context, pid: claudePid, note: { ...session, launch } });
|
|
72027
72228
|
}
|
|
72028
72229
|
async function currentSessionOf({
|
|
72029
72230
|
context,
|
|
@@ -72092,29 +72293,25 @@ async function liveElsewhere({
|
|
|
72092
72293
|
asleepCounts = true
|
|
72093
72294
|
}) {
|
|
72094
72295
|
if (await rushKeeps({ context, key, claudePid, asleepCounts })) return true;
|
|
72095
|
-
const
|
|
72096
|
-
|
|
72097
|
-
|
|
72098
|
-
|
|
72099
|
-
const noted = await readStateJson({ path: join4(folder, file4) });
|
|
72100
|
-
if (noted && sessionKeyOf({ session: noted }) === key) return true;
|
|
72101
|
-
}
|
|
72102
|
-
return false;
|
|
72296
|
+
const { notes } = await sessionNotesOf({ context });
|
|
72297
|
+
return notes.some(
|
|
72298
|
+
({ pid, note, standing }) => standing === "live" && pid !== claudePid && sessionKeyOf({ session: note }) === key
|
|
72299
|
+
);
|
|
72103
72300
|
}
|
|
72104
72301
|
async function claudeTranscriptOf({
|
|
72105
72302
|
context,
|
|
72106
72303
|
sessionId
|
|
72107
72304
|
}) {
|
|
72108
72305
|
const inherited = context.environment.inherited;
|
|
72109
|
-
const root =
|
|
72110
|
-
inherited.CLAUDE_CONFIG_DIR ||
|
|
72306
|
+
const root = join5(
|
|
72307
|
+
inherited.CLAUDE_CONFIG_DIR || join5(inherited.HOME || homedir2(), ".claude"),
|
|
72111
72308
|
"projects"
|
|
72112
72309
|
);
|
|
72113
|
-
const folders = await
|
|
72310
|
+
const folders = await readdir2(root).catch(() => []);
|
|
72114
72311
|
const found = await Promise.all(
|
|
72115
72312
|
folders.map(async (folder) => {
|
|
72116
|
-
const path =
|
|
72117
|
-
return
|
|
72313
|
+
const path = join5(root, folder, `${sessionId}.jsonl`);
|
|
72314
|
+
return stat3(path).then(
|
|
72118
72315
|
(info) => info.isFile() ? [{ path, at: info.mtimeMs }] : [],
|
|
72119
72316
|
() => []
|
|
72120
72317
|
);
|
|
@@ -72141,11 +72338,11 @@ async function runsInSubagent({ context, command }) {
|
|
|
72141
72338
|
if (!sessionId) return false;
|
|
72142
72339
|
const { path } = await claudeTranscriptOf({ context, sessionId });
|
|
72143
72340
|
if (!path) return false;
|
|
72144
|
-
const folder =
|
|
72145
|
-
const files2 = await
|
|
72341
|
+
const folder = join5(dirname5(path), sessionId, "subagents");
|
|
72342
|
+
const files2 = await readdir2(folder).catch(() => []);
|
|
72146
72343
|
const subagents = await Promise.all(
|
|
72147
72344
|
files2.filter((file4) => file4.endsWith(".jsonl")).map(
|
|
72148
|
-
async (file4) => lastCallAtOf({ text: await tailOf({ path:
|
|
72345
|
+
async (file4) => lastCallAtOf({ text: await tailOf({ path: join5(folder, file4) }), command })
|
|
72149
72346
|
)
|
|
72150
72347
|
);
|
|
72151
72348
|
const session = lastCallAtOf({ text: await tailOf({ path }), command });
|
|
@@ -72219,7 +72416,7 @@ async function notBoundNotice({
|
|
|
72219
72416
|
|
|
72220
72417
|
// src/services/plugin-hook.service.ts
|
|
72221
72418
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
72222
|
-
import { join as
|
|
72419
|
+
import { join as join6 } from "node:path";
|
|
72223
72420
|
async function agentProfileHere({
|
|
72224
72421
|
context,
|
|
72225
72422
|
args,
|
|
@@ -72240,7 +72437,7 @@ async function agentProfileHere({
|
|
|
72240
72437
|
}
|
|
72241
72438
|
async function projectHooksHere({ context }) {
|
|
72242
72439
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd;
|
|
72243
|
-
const path =
|
|
72440
|
+
const path = join6(directory, ".claude", "settings.local.json");
|
|
72244
72441
|
return readFile6(path, "utf8").then((text3) => hasLazeHooks({ settings: JSON.parse(text3) })).catch(() => false);
|
|
72245
72442
|
}
|
|
72246
72443
|
async function pluginHookArgs({
|
|
@@ -72259,7 +72456,7 @@ async function pluginHookArgs({
|
|
|
72259
72456
|
var PRE_TOOL_TIMEOUT_MS = 3e3;
|
|
72260
72457
|
function statePath({ context, agent: agent3 }) {
|
|
72261
72458
|
const safe = agent3.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
72262
|
-
return
|
|
72459
|
+
return join7(dirname6(context.environment.configPath), "turns", `${safe}.json`);
|
|
72263
72460
|
}
|
|
72264
72461
|
async function readState({ context, agent: agent3 }) {
|
|
72265
72462
|
return readStateJson({ path: statePath({ context, agent: agent3 }) });
|
|
@@ -72324,7 +72521,7 @@ async function turnEnded({
|
|
|
72324
72521
|
}) {
|
|
72325
72522
|
const state = await readState({ context, agent: agent3 });
|
|
72326
72523
|
if (!state) return;
|
|
72327
|
-
await
|
|
72524
|
+
await rm3(statePath({ context, agent: agent3 }), { force: true });
|
|
72328
72525
|
await beat({ client, state, working: false }).catch(() => void 0);
|
|
72329
72526
|
}
|
|
72330
72527
|
async function preToolHook({ context, args }) {
|
|
@@ -72372,7 +72569,7 @@ async function preToolHook({ context, args }) {
|
|
|
72372
72569
|
}
|
|
72373
72570
|
|
|
72374
72571
|
// src/services/message-files.service.ts
|
|
72375
|
-
import { readFile as readFile7, stat as
|
|
72572
|
+
import { readFile as readFile7, stat as stat4 } from "node:fs/promises";
|
|
72376
72573
|
import { basename as basename4, resolve as resolve3 } from "node:path";
|
|
72377
72574
|
|
|
72378
72575
|
// src/rules/file-types.rules.ts
|
|
@@ -72471,7 +72668,7 @@ async function readyOf({ context, source }) {
|
|
|
72471
72668
|
return asBytes({ source, file: await downloaded({ context, url: value }) });
|
|
72472
72669
|
}
|
|
72473
72670
|
const full = resolve3(context.cwd, value);
|
|
72474
|
-
const found = await
|
|
72671
|
+
const found = await stat4(full).catch(() => void 0);
|
|
72475
72672
|
if (found?.isFile()) return asBytes({ source, file: await local({ full }) });
|
|
72476
72673
|
const marked = fileMarkerIdsIn(value)[0] ?? (UPLOADED_ID.test(value) ? value : void 0);
|
|
72477
72674
|
if (marked) return { kind: "id", id: marked };
|
|
@@ -73096,7 +73293,7 @@ async function slackOf({
|
|
|
73096
73293
|
if (!(error63 instanceof LazeApiError)) throw error63;
|
|
73097
73294
|
if (error63.code === "slack_search_person_only") return { answer: null, note: AGENT_NOTE };
|
|
73098
73295
|
if (error63.status === 404) return { answer: null, note: null };
|
|
73099
|
-
return { answer: null, note: `From Slack: ${
|
|
73296
|
+
return { answer: null, note: `From Slack: ${refusalText(error63)}` };
|
|
73100
73297
|
}
|
|
73101
73298
|
}
|
|
73102
73299
|
async function search({ context, args }) {
|
|
@@ -73124,11 +73321,11 @@ function channelLabelIn(channel) {
|
|
|
73124
73321
|
}
|
|
73125
73322
|
|
|
73126
73323
|
// src/services/claude-wait.service.ts
|
|
73127
|
-
import { readFile as readFile8, rm as
|
|
73324
|
+
import { readFile as readFile8, rm as rm6 } from "node:fs/promises";
|
|
73128
73325
|
|
|
73129
73326
|
// src/services/connect-service.service.ts
|
|
73130
73327
|
import { createHash as createHash2 } from "node:crypto";
|
|
73131
|
-
import { mkdir as mkdir3, rm as
|
|
73328
|
+
import { mkdir as mkdir3, rm as rm5, writeFile } from "node:fs/promises";
|
|
73132
73329
|
import { dirname as dirname12, join as join14 } from "node:path";
|
|
73133
73330
|
|
|
73134
73331
|
// src/rules/connect-service.rules.ts
|
|
@@ -73251,25 +73448,25 @@ function rolloutEventOf({
|
|
|
73251
73448
|
}
|
|
73252
73449
|
|
|
73253
73450
|
// src/services/connect-delivery.service.ts
|
|
73254
|
-
import { rm as
|
|
73451
|
+
import { rm as rm4, stat as stat5 } from "node:fs/promises";
|
|
73255
73452
|
import { homedir as homedir3, hostname as hostname5 } from "node:os";
|
|
73256
73453
|
import { dirname as dirname11, join as join13 } from "node:path";
|
|
73257
73454
|
|
|
73258
73455
|
// src/services/codex-turn-watch.service.ts
|
|
73259
|
-
import { open as open4, readdir as
|
|
73260
|
-
import { basename as basename5, join as
|
|
73456
|
+
import { open as open4, readdir as readdir3 } from "node:fs/promises";
|
|
73457
|
+
import { basename as basename5, join as join8 } from "node:path";
|
|
73261
73458
|
var READ_MS = 1500;
|
|
73262
73459
|
var KEEP_WORKING_MS = 3e4;
|
|
73263
73460
|
async function codexRolloutPathOf({
|
|
73264
73461
|
codexHome,
|
|
73265
73462
|
threadId
|
|
73266
73463
|
}) {
|
|
73267
|
-
const root =
|
|
73268
|
-
const files2 = await
|
|
73464
|
+
const root = join8(codexHome, "sessions");
|
|
73465
|
+
const files2 = await readdir3(root, { recursive: true }).catch(() => []);
|
|
73269
73466
|
const file4 = files2.find(
|
|
73270
73467
|
(name3) => basename5(name3).startsWith("rollout-") && name3.endsWith(`-${threadId}.jsonl`)
|
|
73271
73468
|
);
|
|
73272
|
-
return file4 ?
|
|
73469
|
+
return file4 ? join8(root, file4) : void 0;
|
|
73273
73470
|
}
|
|
73274
73471
|
function rolloutPathOf({ delivery }) {
|
|
73275
73472
|
return codexRolloutPathOf({ codexHome: delivery.codexHome, threadId: delivery.threadId });
|
|
@@ -73358,7 +73555,7 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
73358
73555
|
};
|
|
73359
73556
|
|
|
73360
73557
|
// src/services/mcp-relay.service.ts
|
|
73361
|
-
import { dirname as
|
|
73558
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
73362
73559
|
|
|
73363
73560
|
// ../../node_modules/.pnpm/ws@8.21.3_bufferutil@4.1.0/node_modules/ws/wrapper.mjs
|
|
73364
73561
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -73694,7 +73891,7 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
73694
73891
|
[CONNECTOR_RELAY_CLOSE.replaced.code, "another relay for this server took over"]
|
|
73695
73892
|
]);
|
|
73696
73893
|
function mcpRelaysPathOf({ context }) {
|
|
73697
|
-
return
|
|
73894
|
+
return join9(dirname7(context.environment.configPath), "connect", "mcp-relays.json");
|
|
73698
73895
|
}
|
|
73699
73896
|
async function readMcpRelays({ context }) {
|
|
73700
73897
|
return await readStateJson({ path: mcpRelaysPathOf({ context }) }) ?? {};
|
|
@@ -73854,7 +74051,7 @@ var McpRelayLoops = class _McpRelayLoops {
|
|
|
73854
74051
|
};
|
|
73855
74052
|
|
|
73856
74053
|
// src/services/openclaw-relay.service.ts
|
|
73857
|
-
import { dirname as
|
|
74054
|
+
import { dirname as dirname8, join as join10 } from "node:path";
|
|
73858
74055
|
|
|
73859
74056
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
73860
74057
|
var workspaceIdSchema18 = external_exports.string().min(1);
|
|
@@ -74075,7 +74272,7 @@ var STOPS2 = /* @__PURE__ */ new Map([
|
|
|
74075
74272
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
74076
74273
|
]);
|
|
74077
74274
|
function relaysPathOf({ context }) {
|
|
74078
|
-
return
|
|
74275
|
+
return join10(dirname8(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
74079
74276
|
}
|
|
74080
74277
|
async function readRelays({ context }) {
|
|
74081
74278
|
return await readStateJson({ path: relaysPathOf({ context }) }) ?? {};
|
|
@@ -74267,12 +74464,8 @@ var RelayLoops = class _RelayLoops {
|
|
|
74267
74464
|
}
|
|
74268
74465
|
};
|
|
74269
74466
|
|
|
74270
|
-
// src/services/rush-listeners.service.ts
|
|
74271
|
-
import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
74272
|
-
import { dirname as dirname9, join as join11 } from "node:path";
|
|
74273
|
-
|
|
74274
74467
|
// src/services/rush-host.service.ts
|
|
74275
|
-
import { dirname as
|
|
74468
|
+
import { dirname as dirname9, join as join11 } from "node:path";
|
|
74276
74469
|
async function rushAboveOf({
|
|
74277
74470
|
context,
|
|
74278
74471
|
from = context.processes.pid
|
|
@@ -74286,7 +74479,7 @@ async function rushAboveOf({
|
|
|
74286
74479
|
return void 0;
|
|
74287
74480
|
}
|
|
74288
74481
|
function guardPathOf({ context, claudePid }) {
|
|
74289
|
-
return
|
|
74482
|
+
return join11(dirname9(context.environment.configPath), "rush-guards", `${claudePid}.json`);
|
|
74290
74483
|
}
|
|
74291
74484
|
async function startRushGuard({
|
|
74292
74485
|
context,
|
|
@@ -74299,7 +74492,7 @@ async function startRushGuard({
|
|
|
74299
74492
|
if (holder && context.processes.alive(holder.pid)) return;
|
|
74300
74493
|
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
74301
74494
|
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
74302
|
-
const logPath =
|
|
74495
|
+
const logPath = join11(dirname9(context.environment.configPath), "rush-guards", "guard.log");
|
|
74303
74496
|
context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
|
|
74304
74497
|
}
|
|
74305
74498
|
async function claimRushGuard({
|
|
@@ -74327,22 +74520,11 @@ async function jsonOf(path) {
|
|
|
74327
74520
|
return readStateJson({ path });
|
|
74328
74521
|
}
|
|
74329
74522
|
async function notesOf({ context }) {
|
|
74330
|
-
const
|
|
74331
|
-
|
|
74332
|
-
|
|
74333
|
-
|
|
74334
|
-
|
|
74335
|
-
const note = await jsonOf(join11(folder, file4));
|
|
74336
|
-
const at = await stat4(join11(folder, file4)).then(
|
|
74337
|
-
(info) => info.mtimeMs,
|
|
74338
|
-
() => 0
|
|
74339
|
-
);
|
|
74340
|
-
if (!pid || !note) return [];
|
|
74341
|
-
const { launch = {}, ...session } = note;
|
|
74342
|
-
return [{ pid, key: sessionKeyOf({ session }), at, session, launch }];
|
|
74343
|
-
})
|
|
74344
|
-
);
|
|
74345
|
-
return notes.flat().toSorted((a, b) => b.at - a.at);
|
|
74523
|
+
const { notes } = await sessionNotesOf({ context });
|
|
74524
|
+
return notes.map(({ pid, note, standing }) => {
|
|
74525
|
+
const { launch = {}, process: _process, ...session } = note;
|
|
74526
|
+
return { pid, key: sessionKeyOf({ session }), session, launch, gone: standing === "gone" };
|
|
74527
|
+
});
|
|
74346
74528
|
}
|
|
74347
74529
|
async function rushListenersOf({
|
|
74348
74530
|
context
|
|
@@ -74360,25 +74542,39 @@ async function rushListenersOf({
|
|
|
74360
74542
|
for (const [key, profile] of bound) {
|
|
74361
74543
|
const one = sessions.find((each) => `claude-code:${each.sessionId}` === key);
|
|
74362
74544
|
if (!one?.id) continue;
|
|
74545
|
+
const entry = config2.profiles[profile];
|
|
74546
|
+
const refused = entry ? refusedRecently({ profile: entry, nowMs: context.nowMs() }) : false;
|
|
74363
74547
|
const own2 = notes.filter((note) => note.key === key);
|
|
74364
|
-
|
|
74365
|
-
const listenerPid = await listenerOf({ context, key, profile, pids });
|
|
74366
|
-
const waiterPid = await waiterOf({ context, key, profile });
|
|
74367
|
-
const lastClaudePid = pids.find((pid) => !context.processes.alive(pid));
|
|
74368
|
-
const newest = own2[0];
|
|
74369
|
-
rows.push({
|
|
74370
|
-
profile,
|
|
74371
|
-
rushId: one.id,
|
|
74372
|
-
key,
|
|
74373
|
-
standing: rushStandingOf({ one }),
|
|
74374
|
-
...listenerPid ? { listenerPid } : {},
|
|
74375
|
-
...waiterPid ? { waiterPid } : {},
|
|
74376
|
-
...lastClaudePid ? { lastClaudePid } : {},
|
|
74377
|
-
...newest ? { noted: { session: newest.session, launch: newest.launch } } : {}
|
|
74378
|
-
});
|
|
74548
|
+
rows.push(await rowOf({ context, key, profile, rushId: one.id, one, own: own2, refused }));
|
|
74379
74549
|
}
|
|
74380
74550
|
return rows;
|
|
74381
74551
|
}
|
|
74552
|
+
async function rowOf({
|
|
74553
|
+
context,
|
|
74554
|
+
key,
|
|
74555
|
+
profile,
|
|
74556
|
+
rushId,
|
|
74557
|
+
one,
|
|
74558
|
+
own: own2,
|
|
74559
|
+
refused
|
|
74560
|
+
}) {
|
|
74561
|
+
const pids = own2.map((note) => note.pid);
|
|
74562
|
+
const listenerPid = await listenerOf({ context, key, profile, pids });
|
|
74563
|
+
const waiterPid = await waiterOf({ context, key, profile });
|
|
74564
|
+
const lastClaudePid = own2.find((note) => note.gone)?.pid;
|
|
74565
|
+
const newest = own2[0];
|
|
74566
|
+
return {
|
|
74567
|
+
profile,
|
|
74568
|
+
rushId,
|
|
74569
|
+
key,
|
|
74570
|
+
standing: rushStandingOf({ one }),
|
|
74571
|
+
...listenerPid ? { listenerPid } : {},
|
|
74572
|
+
...waiterPid ? { waiterPid } : {},
|
|
74573
|
+
...lastClaudePid ? { lastClaudePid } : {},
|
|
74574
|
+
...newest ? { noted: { session: newest.session, launch: newest.launch } } : {},
|
|
74575
|
+
...refused ? { refused: true } : {}
|
|
74576
|
+
};
|
|
74577
|
+
}
|
|
74382
74578
|
async function listenerOf({
|
|
74383
74579
|
context,
|
|
74384
74580
|
key,
|
|
@@ -74404,7 +74600,7 @@ async function waiterOf({
|
|
|
74404
74600
|
async function rearmRushGuards({ context }) {
|
|
74405
74601
|
let started = 0;
|
|
74406
74602
|
for (const row of await rushListenersOf({ context })) {
|
|
74407
|
-
if (row.standing !== "asleep" || row.listenerPid || !row.lastClaudePid) continue;
|
|
74603
|
+
if (row.standing !== "asleep" || row.listenerPid || !row.lastClaudePid || row.refused) continue;
|
|
74408
74604
|
const rush = { id: row.rushId, program: "rush" };
|
|
74409
74605
|
await startRushGuard({ context, profile: row.profile, claudePid: row.lastClaudePid, rush });
|
|
74410
74606
|
started += 1;
|
|
@@ -74421,17 +74617,24 @@ function clientOf({ context, profile }) {
|
|
|
74421
74617
|
return context.store.read().then((config2) => {
|
|
74422
74618
|
const entry = config2.profiles[profile];
|
|
74423
74619
|
if (!entry || entry.migrated) return void 0;
|
|
74620
|
+
if (refusedRecently({ profile: entry, nowMs: context.nowMs() })) return void 0;
|
|
74424
74621
|
return LazeClient.create({
|
|
74425
74622
|
baseUrl: entry.url,
|
|
74426
74623
|
token: entry.token,
|
|
74427
74624
|
fetcher: (input2, init) => context.fetcher(input2, { ...init, signal: AbortSignal.timeout(CHECK_TIMEOUT_MS) }),
|
|
74428
|
-
onMigrated: markMigratedOn({ context, profile })
|
|
74625
|
+
onMigrated: markMigratedOn({ context, profile }),
|
|
74626
|
+
onRefused: markRefusedOn({ context, profile, token: entry.token })
|
|
74429
74627
|
});
|
|
74430
74628
|
});
|
|
74431
74629
|
}
|
|
74432
|
-
async function waitingOf({
|
|
74630
|
+
async function waitingOf({
|
|
74631
|
+
context,
|
|
74632
|
+
profile
|
|
74633
|
+
}) {
|
|
74433
74634
|
const client = await clientOf({ context, profile });
|
|
74434
|
-
return client?.get("/api/agents/me/inbox/waiting").catch(
|
|
74635
|
+
return client?.get("/api/agents/me/inbox/waiting").catch(
|
|
74636
|
+
(error63) => error63 instanceof LazeApiError && error63.status === 401 ? "refused" : void 0
|
|
74637
|
+
);
|
|
74435
74638
|
}
|
|
74436
74639
|
function waitedMsOf({ waiting, nowMs: nowMs2 }) {
|
|
74437
74640
|
if (waiting.count === 0 || !waiting.oldestPostedAt) return 0;
|
|
@@ -74635,7 +74838,8 @@ async function serveAgent({
|
|
|
74635
74838
|
baseUrl: entry.url,
|
|
74636
74839
|
token: entry.token,
|
|
74637
74840
|
fetcher: context.fetcher,
|
|
74638
|
-
onMigrated: markMigratedOn({ context, profile })
|
|
74841
|
+
onMigrated: markMigratedOn({ context, profile }),
|
|
74842
|
+
onRefused: markRefusedOn({ context, profile, token: entry.token })
|
|
74639
74843
|
});
|
|
74640
74844
|
const watch = CodexTurnWatch.create({ context, client, profile, delivery: entry.delivery });
|
|
74641
74845
|
const ended = new AbortController();
|
|
@@ -74793,7 +74997,7 @@ async function runConnectLoop({ context }) {
|
|
|
74793
74997
|
await mcpRelays.stopAll();
|
|
74794
74998
|
for (const current3 of run4.served.values()) current3.stop.abort();
|
|
74795
74999
|
await Promise.all([...run4.served.values()].map((current3) => current3.done));
|
|
74796
|
-
if (await holdsLock(run4)) await
|
|
75000
|
+
if (await holdsLock(run4)) await rm4(run4.path, { force: true });
|
|
74797
75001
|
}
|
|
74798
75002
|
return 0;
|
|
74799
75003
|
}
|
|
@@ -74956,11 +75160,8 @@ async function status2({ context }) {
|
|
|
74956
75160
|
}
|
|
74957
75161
|
for (const line of await mcpRelayLinesOf({ context })) context.out(`${line}
|
|
74958
75162
|
`);
|
|
74959
|
-
for (const
|
|
74960
|
-
const waiting = await waitingOf({ context, profile: row.profile });
|
|
74961
|
-
context.out(`${rushLineOf({ row })}${inLazeOf({ row, waiting, nowMs: context.nowMs() })}
|
|
75163
|
+
for (const line of await rushLinesOf({ context })) context.out(`${line}
|
|
74962
75164
|
`);
|
|
74963
|
-
}
|
|
74964
75165
|
const config2 = await context.store.read();
|
|
74965
75166
|
const linked = Object.entries(config2.profiles).filter(([, profile]) => profile.delivery);
|
|
74966
75167
|
if (linked.length === 0) context.out("No Codex agent is linked on this machine.\n");
|
|
@@ -74980,6 +75181,20 @@ async function mcpRelayLinesOf({ context }) {
|
|
|
74980
75181
|
return `${connectionId} ${relay2.label} ${targetLineOf({ target: relay2.target })} ${state}`;
|
|
74981
75182
|
});
|
|
74982
75183
|
}
|
|
75184
|
+
async function rushLinesOf({ context }) {
|
|
75185
|
+
const lines2 = [...(await sessionNotesOf({ context, tell: false })).dropped];
|
|
75186
|
+
const refused = /* @__PURE__ */ new Set();
|
|
75187
|
+
for (const row of await rushListenersOf({ context })) {
|
|
75188
|
+
if (refused.has(row.profile)) continue;
|
|
75189
|
+
const waiting = row.refused ? "refused" : await waitingOf({ context, profile: row.profile });
|
|
75190
|
+
if (waiting === "refused") {
|
|
75191
|
+
refused.add(row.profile);
|
|
75192
|
+
lines2.push(revokedKeyLineOf({ profile: row.profile }));
|
|
75193
|
+
} else
|
|
75194
|
+
lines2.push(`${rushLineOf({ row })}${inLazeOf({ row, waiting, nowMs: context.nowMs() })}`);
|
|
75195
|
+
}
|
|
75196
|
+
return lines2;
|
|
75197
|
+
}
|
|
74983
75198
|
function rushLineOf({ row }) {
|
|
74984
75199
|
const head = `${row.profile} Claude Code in rush ${row.rushId} ${row.standing}`;
|
|
74985
75200
|
if (row.standing === "awake" && row.waiterPid) {
|
|
@@ -75031,11 +75246,11 @@ async function uninstall({ context }) {
|
|
|
75031
75246
|
command: ["systemctl", "--user", "disable", `${installed.name}.service`]
|
|
75032
75247
|
});
|
|
75033
75248
|
}
|
|
75034
|
-
if (installed.file) await
|
|
75249
|
+
if (installed.file) await rm5(installed.file, { force: true });
|
|
75035
75250
|
if (installed.manager === "systemd") {
|
|
75036
75251
|
await run({ context, command: ["systemctl", "--user", "daemon-reload"] });
|
|
75037
75252
|
}
|
|
75038
|
-
await
|
|
75253
|
+
await rm5(path, { force: true });
|
|
75039
75254
|
context.out(
|
|
75040
75255
|
`Removed the connect service (${installed.manager}, ${installed.name}). Linked Codex agents get no messages until \`laze connect install\`.
|
|
75041
75256
|
`
|
|
@@ -75229,7 +75444,7 @@ async function waitForMessages({ context, args }) {
|
|
|
75229
75444
|
return 0;
|
|
75230
75445
|
} finally {
|
|
75231
75446
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
75232
|
-
await
|
|
75447
|
+
await rm6(lock, { force: true });
|
|
75233
75448
|
}
|
|
75234
75449
|
}
|
|
75235
75450
|
async function healRushDelivery({ context }) {
|
|
@@ -75253,6 +75468,7 @@ async function waitHook({ context, args }) {
|
|
|
75253
75468
|
`);
|
|
75254
75469
|
return 2;
|
|
75255
75470
|
}
|
|
75471
|
+
if (error63 instanceof LazeApiError && error63.status === 401) return 0;
|
|
75256
75472
|
context.err(`laze: the background waiter stopped: ${String(error63)}
|
|
75257
75473
|
`);
|
|
75258
75474
|
return 0;
|
|
@@ -75270,13 +75486,13 @@ async function monitorServes({
|
|
|
75270
75486
|
|
|
75271
75487
|
// src/services/codex-link.service.ts
|
|
75272
75488
|
import { createReadStream } from "node:fs";
|
|
75273
|
-
import { readdir as readdir5, rm as
|
|
75489
|
+
import { readdir as readdir5, rm as rm8, stat as stat7 } from "node:fs/promises";
|
|
75274
75490
|
import { join as join16, resolve as resolve4 } from "node:path";
|
|
75275
75491
|
import { createInterface as createInterface2 } from "node:readline";
|
|
75276
75492
|
|
|
75277
75493
|
// src/services/codex-adopt.service.ts
|
|
75278
75494
|
import { spawn as spawn2 } from "node:child_process";
|
|
75279
|
-
import { readdir as readdir4, rm as
|
|
75495
|
+
import { readdir as readdir4, rm as rm7, stat as stat6 } from "node:fs/promises";
|
|
75280
75496
|
import { join as join15 } from "node:path";
|
|
75281
75497
|
import { createInterface } from "node:readline";
|
|
75282
75498
|
|
|
@@ -75554,7 +75770,7 @@ Log: ${record4.log}
|
|
|
75554
75770
|
async function adoptStop({ context, profile }) {
|
|
75555
75771
|
const path = statePathOf({ context, kind: "adopt", profile });
|
|
75556
75772
|
const record4 = await recordOf({ path });
|
|
75557
|
-
await
|
|
75773
|
+
await rm7(path, { force: true });
|
|
75558
75774
|
if (!record4 || !context.processes.stop(record4.pid)) {
|
|
75559
75775
|
context.out(`laze adopt codex was not running in the background for profile "${profile}".
|
|
75560
75776
|
`);
|
|
@@ -75699,7 +75915,7 @@ async function stopAdopt({ context, profile }) {
|
|
|
75699
75915
|
const running = await readJson({ path });
|
|
75700
75916
|
if (!running) return;
|
|
75701
75917
|
context.processes.stop(running.pid);
|
|
75702
|
-
await
|
|
75918
|
+
await rm8(path, { force: true });
|
|
75703
75919
|
}
|
|
75704
75920
|
async function linkCodexSession({
|
|
75705
75921
|
context,
|
|
@@ -75738,7 +75954,7 @@ async function linkCodexSession({
|
|
|
75738
75954
|
}
|
|
75739
75955
|
|
|
75740
75956
|
// src/services/laze-plugin.service.ts
|
|
75741
|
-
import { mkdir as mkdir4, readFile as readFile9, rm as
|
|
75957
|
+
import { mkdir as mkdir4, readFile as readFile9, rm as rm9, writeFile as writeFile2 } from "node:fs/promises";
|
|
75742
75958
|
import { homedir as homedir4 } from "node:os";
|
|
75743
75959
|
import { dirname as dirname13, join as join18 } from "node:path";
|
|
75744
75960
|
|
|
@@ -75767,7 +75983,7 @@ function cliLineOf({
|
|
|
75767
75983
|
}
|
|
75768
75984
|
var SKILL = `---
|
|
75769
75985
|
name: laze
|
|
75770
|
-
description: Work in a Laze workspace as an agent - read your inbox, reply to messages, post in channels
|
|
75986
|
+
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.
|
|
75771
75987
|
---
|
|
75772
75988
|
|
|
75773
75989
|
# Laze
|
|
@@ -75857,6 +76073,10 @@ open cards by title and ranks them for them alone.
|
|
|
75857
76073
|
|
|
75858
76074
|
## Apps
|
|
75859
76075
|
|
|
76076
|
+
Apps are also called artifacts. When someone in Laze asks for an artifact, a page, a dashboard, a
|
|
76077
|
+
deck or a mock, build a Laze app and post it in the conversation, not a claude.ai artifact, unless
|
|
76078
|
+
the person asks for that specifically.
|
|
76079
|
+
|
|
75860
76080
|
Asked for an app (a tracker, a CRM, a dashboard, a page that explains something), read the full
|
|
75861
76081
|
guide first: https://laze.so/docs/agents/apps.md. The short version:
|
|
75862
76082
|
|
|
@@ -76102,7 +76322,7 @@ async function plugin({ context, args }) {
|
|
|
76102
76322
|
if (action === "uninstall") {
|
|
76103
76323
|
const name3 = pluginNameHere({ context });
|
|
76104
76324
|
const removed = await unregisterAs({ context, name: name3 });
|
|
76105
|
-
await
|
|
76325
|
+
await rm9(registeredMarkOf({ context }), { force: true });
|
|
76106
76326
|
context.out(
|
|
76107
76327
|
removed ? `Removed the Laze plugin ${name3}@${name3} from Claude Code.
|
|
76108
76328
|
` : `Claude Code did not remove it; run: claude plugin uninstall ${name3}@${name3} && claude plugin marketplace remove ${name3}
|
|
@@ -76123,8 +76343,28 @@ async function plugin({ context, args }) {
|
|
|
76123
76343
|
return 0;
|
|
76124
76344
|
}
|
|
76125
76345
|
|
|
76346
|
+
// src/services/link-listener.service.ts
|
|
76347
|
+
async function listenAfterLink({
|
|
76348
|
+
context,
|
|
76349
|
+
args,
|
|
76350
|
+
profile,
|
|
76351
|
+
claudePid
|
|
76352
|
+
}) {
|
|
76353
|
+
if (!claudePid) return;
|
|
76354
|
+
const parent = await context.processes.parentOf(claudePid) ?? 0;
|
|
76355
|
+
const rush = rushSessionOf({ parentArgs: await context.processes.argsOf(parent) });
|
|
76356
|
+
if (!rush) return;
|
|
76357
|
+
const session = await currentSessionOf({ context, args });
|
|
76358
|
+
await rememberSession({ context, claudePid, session });
|
|
76359
|
+
await startRushGuard({ context, profile, claudePid, rush });
|
|
76360
|
+
await ensureConnectService({ context }).catch((error63) => {
|
|
76361
|
+
context.err(`laze: could not start the connect service: ${String(error63)}
|
|
76362
|
+
`);
|
|
76363
|
+
});
|
|
76364
|
+
}
|
|
76365
|
+
|
|
76126
76366
|
// src/services/mcp-channel.service.ts
|
|
76127
|
-
import { rm as
|
|
76367
|
+
import { rm as rm10 } from "node:fs/promises";
|
|
76128
76368
|
var LAZE_MCP_SERVER = "laze";
|
|
76129
76369
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
76130
76370
|
var ROUND_SECONDS3 = 50;
|
|
@@ -76243,7 +76483,7 @@ async function pushInbox({
|
|
|
76243
76483
|
`);
|
|
76244
76484
|
}
|
|
76245
76485
|
} finally {
|
|
76246
|
-
await
|
|
76486
|
+
await rm10(marker, { force: true });
|
|
76247
76487
|
}
|
|
76248
76488
|
}
|
|
76249
76489
|
|
|
@@ -76348,9 +76588,6 @@ async function harnessOf2({ context, args }) {
|
|
|
76348
76588
|
const nearest = await nearestHarnessOf({ context });
|
|
76349
76589
|
return nearest ?? { harness: context.environment.harness, pid: void 0 };
|
|
76350
76590
|
}
|
|
76351
|
-
function slugOf(name3) {
|
|
76352
|
-
return name3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "agent";
|
|
76353
|
-
}
|
|
76354
76591
|
function settingsOf({ path, text: text3 }) {
|
|
76355
76592
|
try {
|
|
76356
76593
|
return JSON.parse(text3);
|
|
@@ -76518,6 +76755,7 @@ async function settleLinked({
|
|
|
76518
76755
|
}
|
|
76519
76756
|
const hooked = claude && !args.flags["no-hook"];
|
|
76520
76757
|
const hookPath = hooked ? await installHooks({ context, directory, profile: name3 }) : void 0;
|
|
76758
|
+
if (hooked) await listenAfterLink({ context, args, profile: name3, claudePid: pid });
|
|
76521
76759
|
const laze = lazeCommandOf({ program: context.program });
|
|
76522
76760
|
const steps = await nextStepsFor({
|
|
76523
76761
|
context,
|
|
@@ -76539,21 +76777,6 @@ async function settleLinked({
|
|
|
76539
76777
|
);
|
|
76540
76778
|
return name3;
|
|
76541
76779
|
}
|
|
76542
|
-
function linkedProfileNameOf({
|
|
76543
|
-
args,
|
|
76544
|
-
linked,
|
|
76545
|
-
profiles: profiles2
|
|
76546
|
-
}) {
|
|
76547
|
-
const wanted = flagText({ args, name: "profile" }) || `agent-${slugOf(linked.agent.name)}`;
|
|
76548
|
-
const free = (name3) => {
|
|
76549
|
-
const held = profiles2[name3];
|
|
76550
|
-
return !held || held.kind === "agent" && held.agentId === linked.agent.id;
|
|
76551
|
-
};
|
|
76552
|
-
if (free(wanted)) return wanted;
|
|
76553
|
-
for (let number4 = 2; ; number4 += 1) {
|
|
76554
|
-
if (free(`${wanted}-${number4}`)) return `${wanted}-${number4}`;
|
|
76555
|
-
}
|
|
76556
|
-
}
|
|
76557
76780
|
function requestProfileNameOf({ profile }) {
|
|
76558
76781
|
return `${profile}-request`;
|
|
76559
76782
|
}
|
|
@@ -76793,11 +77016,6 @@ function formatPools({ pools, nowMs: nowMs2 }) {
|
|
|
76793
77016
|
return `${pools.pools.map((pool) => formatPool({ pool, nowMs: nowMs2 })).join("\n\n")}
|
|
76794
77017
|
`;
|
|
76795
77018
|
}
|
|
76796
|
-
function refusalLine({ code, message: message2 }) {
|
|
76797
|
-
const sentence = message2.trim().replace(/[.!]*$/, ".");
|
|
76798
|
-
return `laze: ${code}: ${sentence}
|
|
76799
|
-
`;
|
|
76800
|
-
}
|
|
76801
77019
|
var SWITCH_REASONS = {
|
|
76802
77020
|
out_of_usage: "out of usage",
|
|
76803
77021
|
login_removed: "login removed",
|
|
@@ -77830,7 +78048,7 @@ async function uploadParts({
|
|
|
77830
78048
|
await client.put(`/api/agents/me/migrations/${migrationId}/parts/${index}`, { text: text3 });
|
|
77831
78049
|
} catch (error63) {
|
|
77832
78050
|
if (migratedNoticeOf(error63)) throw error63;
|
|
77833
|
-
const why =
|
|
78051
|
+
const why = whyOf(error63);
|
|
77834
78052
|
throw new CliUsageError(
|
|
77835
78053
|
`Part ${index + 1} of ${upload.parts.length} did not upload (${why}). Nothing moved yet: run \`${again}\` again.`
|
|
77836
78054
|
);
|
|
@@ -77921,6 +78139,10 @@ async function agentMigrate({ context, args }) {
|
|
|
77921
78139
|
if (sub || !args.words[2]) throw new CliUsageError(`Usage: ${MIGRATE_USAGE}`);
|
|
77922
78140
|
return migrate({ context, args });
|
|
77923
78141
|
}
|
|
78142
|
+
function whyOf(error63) {
|
|
78143
|
+
if (error63 instanceof LazeApiError) return refusalText(error63);
|
|
78144
|
+
return error63 instanceof Error ? error63.message : String(error63);
|
|
78145
|
+
}
|
|
77924
78146
|
|
|
77925
78147
|
// src/services/agent-session-commands.service.ts
|
|
77926
78148
|
var NO_SESSION = "Run this inside the Claude Code or Codex session the agent should listen in, or pass --session <id>.";
|
|
@@ -79712,6 +79934,7 @@ var deleteAppUserByKeyInputSchemaDefinition = deleteAppUserInputSchema.omit(byKe
|
|
|
79712
79934
|
var appListByKeyQuerySchemaDefinition = external_exports.object({ archived: external_exports.enum(["true"]).optional() });
|
|
79713
79935
|
|
|
79714
79936
|
// ../../modules/app/contract/src/app.cli.ts
|
|
79937
|
+
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.";
|
|
79715
79938
|
var APP_MANIFEST_FILE = "laze.app.json";
|
|
79716
79939
|
var appManifestSchemaDefinition = external_exports.object({
|
|
79717
79940
|
app: external_exports.object({ id: external_exports.string().min(1), name: external_exports.string(), slug: appSlugSchema }),
|
|
@@ -80559,7 +80782,7 @@ async function appPinsCommand({
|
|
|
80559
80782
|
|
|
80560
80783
|
// src/services/app-script-check.service.ts
|
|
80561
80784
|
import { execFile } from "node:child_process";
|
|
80562
|
-
import { mkdtemp, rm as
|
|
80785
|
+
import { mkdtemp, rm as rm11, writeFile as writeFile4 } from "node:fs/promises";
|
|
80563
80786
|
import { tmpdir } from "node:os";
|
|
80564
80787
|
import { join as join21 } from "node:path";
|
|
80565
80788
|
import { promisify } from "node:util";
|
|
@@ -80607,7 +80830,7 @@ async function scriptErrorsOf({
|
|
|
80607
80830
|
);
|
|
80608
80831
|
return [...errors.filter((error63) => error63 !== null), ...unknown2];
|
|
80609
80832
|
} finally {
|
|
80610
|
-
await
|
|
80833
|
+
await rm11(dir, { recursive: true, force: true });
|
|
80611
80834
|
}
|
|
80612
80835
|
}
|
|
80613
80836
|
|
|
@@ -80890,6 +81113,8 @@ async function connectedTurnTokenOf({
|
|
|
80890
81113
|
|
|
80891
81114
|
// src/services/app-commands.service.ts
|
|
80892
81115
|
var USAGE5 = `Usage: laze app <command>. The app comes from ${APP_MANIFEST_FILE} in the folder, or --app <id|slug>.
|
|
81116
|
+
${APP_ARTIFACT_RULE}
|
|
81117
|
+
${APP_ARTIFACT_RULE}
|
|
80893
81118
|
|
|
80894
81119
|
${appCliCommands.map((entry) => ` ${entry.command} ${entry.arguments.join(" ")}
|
|
80895
81120
|
${entry.summary}`).join("\n")}`;
|
|
@@ -82533,7 +82758,7 @@ function loginValuesOf({
|
|
|
82533
82758
|
|
|
82534
82759
|
// src/services/vault-commands.service.ts
|
|
82535
82760
|
import { createHash as createHash6 } from "node:crypto";
|
|
82536
|
-
import { readFile as readFile16, rm as
|
|
82761
|
+
import { readFile as readFile16, rm as rm12 } from "node:fs/promises";
|
|
82537
82762
|
import { hostname as hostname7, tmpdir as tmpdir2 } from "node:os";
|
|
82538
82763
|
import { dirname as dirname15, join as join24 } from "node:path";
|
|
82539
82764
|
|
|
@@ -82786,13 +83011,13 @@ async function settled({
|
|
|
82786
83011
|
}) {
|
|
82787
83012
|
if (release2 === "capped") return { exitCode: 75 };
|
|
82788
83013
|
if (release2.outcome === "deny") {
|
|
82789
|
-
await
|
|
83014
|
+
await rm12(keyPath, { force: true });
|
|
82790
83015
|
context.err(`${release2.message}
|
|
82791
83016
|
`);
|
|
82792
83017
|
return { exitCode: release2.exitCode || 1 };
|
|
82793
83018
|
}
|
|
82794
83019
|
const values = await envOf({ release: release2, run: run4 });
|
|
82795
|
-
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await
|
|
83020
|
+
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await rm12(keyPath, { force: true });
|
|
82796
83021
|
if (release2.message) context.err(`${release2.message}
|
|
82797
83022
|
`);
|
|
82798
83023
|
return { env: values };
|
|
@@ -82802,7 +83027,7 @@ function refusedRelease(error63) {
|
|
|
82802
83027
|
return {
|
|
82803
83028
|
outcome: "deny",
|
|
82804
83029
|
exitCode: 1,
|
|
82805
|
-
message: `laze vault: the release was refused: ${
|
|
83030
|
+
message: `laze vault: the release was refused: ${refusalText(error63)}`
|
|
82806
83031
|
};
|
|
82807
83032
|
}
|
|
82808
83033
|
var WHERE = "works only on a Laze agent's computer, on a machine it runs on, or signed in with `laze login` (as yourself or as a connected agent)";
|
|
@@ -83966,8 +84191,7 @@ async function changing({
|
|
|
83966
84191
|
} catch (error63) {
|
|
83967
84192
|
const refused = error63 instanceof LazeApiError && profile.kind === "agent" && ["agent_restricted", "permission_denied", "channel_admin_required"].includes(error63.code);
|
|
83968
84193
|
if (!refused) throw error63;
|
|
83969
|
-
context.err(
|
|
83970
|
-
${AGENT_HINT}`);
|
|
84194
|
+
context.err(`${refusalLine(error63)}${AGENT_HINT}`);
|
|
83971
84195
|
return 1;
|
|
83972
84196
|
}
|
|
83973
84197
|
}
|
|
@@ -84129,8 +84353,7 @@ async function changing2({
|
|
|
84129
84353
|
} catch (error63) {
|
|
84130
84354
|
const refused = error63 instanceof LazeApiError && profile.kind === "agent" && ["agent_restricted", "permission_denied", "channel_admin_required"].includes(error63.code);
|
|
84131
84355
|
if (!refused) throw error63;
|
|
84132
|
-
context.err(
|
|
84133
|
-
${AGENT_HINT2}`);
|
|
84356
|
+
context.err(`${refusalLine(error63)}${AGENT_HINT2}`);
|
|
84134
84357
|
return 1;
|
|
84135
84358
|
}
|
|
84136
84359
|
}
|
|
@@ -84425,7 +84648,7 @@ import { basename as basename8, isAbsolute as isAbsolute2, relative as relative4
|
|
|
84425
84648
|
|
|
84426
84649
|
// src/services/file-download.service.ts
|
|
84427
84650
|
import { createWriteStream } from "node:fs";
|
|
84428
|
-
import { mkdir as mkdir8, rename as rename3, rm as
|
|
84651
|
+
import { mkdir as mkdir8, rename as rename3, rm as rm13, stat as stat10, truncate } from "node:fs/promises";
|
|
84429
84652
|
import { basename as basename7, dirname as dirname17, resolve as resolve9 } from "node:path";
|
|
84430
84653
|
import { Readable, Transform } from "node:stream";
|
|
84431
84654
|
import { pipeline } from "node:stream/promises";
|
|
@@ -84550,7 +84773,7 @@ async function downloadFile({
|
|
|
84550
84773
|
await mkdir8(dirname17(part), { recursive: true });
|
|
84551
84774
|
const named = await fetchWhole({ context, client, attachmentId, part, out }).catch(
|
|
84552
84775
|
async (error63) => {
|
|
84553
|
-
await
|
|
84776
|
+
await rm13(part, { force: true });
|
|
84554
84777
|
if (!isDiskError(error63)) throw error63;
|
|
84555
84778
|
throw new CliUsageError(`Could not write ${attachmentId} to disk: ${String(error63)}`);
|
|
84556
84779
|
}
|
|
@@ -85002,7 +85225,7 @@ async function chatActions({
|
|
|
85002
85225
|
}
|
|
85003
85226
|
|
|
85004
85227
|
// src/services/claude-monitor.service.ts
|
|
85005
|
-
import { rm as
|
|
85228
|
+
import { rm as rm14 } from "node:fs/promises";
|
|
85006
85229
|
var MONITOR_IDLE_MS = 3e4;
|
|
85007
85230
|
var MONITOR_OUTRANKED_MS = 3e3;
|
|
85008
85231
|
async function deliverOnce({
|
|
@@ -85070,7 +85293,7 @@ async function monitorRound(turn) {
|
|
|
85070
85293
|
async function release({ context, profile }) {
|
|
85071
85294
|
const lock = statePathOf({ context, kind: "waiters", profile });
|
|
85072
85295
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
85073
|
-
await
|
|
85296
|
+
await rm14(lock, { force: true });
|
|
85074
85297
|
}
|
|
85075
85298
|
async function monitorHook({ context, args }) {
|
|
85076
85299
|
const claudePid = await claudePidOf({ context });
|
|
@@ -86579,7 +86802,13 @@ var whatsappChangeDefinition = external_exports.object({
|
|
|
86579
86802
|
/** Fetched with a "media" request while the store is open; absent from older connectors. */
|
|
86580
86803
|
media: whatsappChangeMediaDefinition.optional(),
|
|
86581
86804
|
/** The chat's other ids, such as the hidden id it was first seen under; new in Nov 2026. */
|
|
86582
|
-
aliases: external_exports.array(external_exports.string().min(1).max(200)).max(16).optional()
|
|
86805
|
+
aliases: external_exports.array(external_exports.string().min(1).max(200)).max(16).optional(),
|
|
86806
|
+
/** The message this one replies to, its sender's name and text; absent from older connectors. */
|
|
86807
|
+
quote: external_exports.object({
|
|
86808
|
+
id: external_exports.string().min(1).max(200),
|
|
86809
|
+
sender: external_exports.string().max(500),
|
|
86810
|
+
text: external_exports.string().max(1e3)
|
|
86811
|
+
}).optional()
|
|
86583
86812
|
});
|
|
86584
86813
|
var whatsappReadDefinition = external_exports.object({
|
|
86585
86814
|
chat: external_exports.string().min(1).max(200),
|
|
@@ -87102,7 +87331,7 @@ var restSettleComputerCopyInputDefinition = settleComputerCopyInputDefinition.om
|
|
|
87102
87331
|
});
|
|
87103
87332
|
|
|
87104
87333
|
// src/services/computer-copy-commands.service.ts
|
|
87105
|
-
import { mkdtemp as mkdtemp2, open as open5, rm as
|
|
87334
|
+
import { mkdtemp as mkdtemp2, open as open5, rm as rm15, stat as stat11 } from "node:fs/promises";
|
|
87106
87335
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
87107
87336
|
import { basename as basename9, dirname as dirname18, resolve as resolve11 } from "node:path";
|
|
87108
87337
|
var COMPUTER_COPY_USAGE = ` laze computer copy <path> --agent <agent> [--to <folder>] [--json]
|
|
@@ -87203,7 +87432,7 @@ It lands before ${done.agentName}'s next turn.
|
|
|
87203
87432
|
`
|
|
87204
87433
|
);
|
|
87205
87434
|
} finally {
|
|
87206
|
-
await
|
|
87435
|
+
await rm15(dir, { recursive: true, force: true });
|
|
87207
87436
|
}
|
|
87208
87437
|
}
|
|
87209
87438
|
|
|
@@ -92587,8 +92816,7 @@ async function history2({
|
|
|
92587
92816
|
`);
|
|
92588
92817
|
} else context.out(formatHistory(output2));
|
|
92589
92818
|
if (!refused) return void 0;
|
|
92590
|
-
context.err(
|
|
92591
|
-
`);
|
|
92819
|
+
context.err(refusalLine(refused));
|
|
92592
92820
|
return 1;
|
|
92593
92821
|
}
|
|
92594
92822
|
|
|
@@ -92853,7 +93081,7 @@ async function ip({ context, args }) {
|
|
|
92853
93081
|
}
|
|
92854
93082
|
|
|
92855
93083
|
// src/services/join-commands.service.ts
|
|
92856
|
-
import { rm as
|
|
93084
|
+
import { rm as rm16 } from "node:fs/promises";
|
|
92857
93085
|
import { dirname as dirname19, join as join28 } from "node:path";
|
|
92858
93086
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
92859
93087
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
@@ -92874,7 +93102,7 @@ async function keepPending({ context, pending: pending2 }) {
|
|
|
92874
93102
|
await writeStateJson({ path: pendingPathOf({ context }), value: pending2 });
|
|
92875
93103
|
}
|
|
92876
93104
|
async function dropPending({ context }) {
|
|
92877
|
-
await
|
|
93105
|
+
await rm16(pendingPathOf({ context }), { force: true });
|
|
92878
93106
|
}
|
|
92879
93107
|
function waitSecondsOf3({ args }) {
|
|
92880
93108
|
const raw = flagText({ args, name: "timeout" });
|
|
@@ -94012,7 +94240,7 @@ import { readdir as readdir7, readFile as readFile29 } from "node:fs/promises";
|
|
|
94012
94240
|
import { join as join29, resolve as resolve19 } from "node:path";
|
|
94013
94241
|
|
|
94014
94242
|
// src/services/mount-files.service.ts
|
|
94015
|
-
import { mkdir as mkdir10, readFile as readFile28, rm as
|
|
94243
|
+
import { mkdir as mkdir10, readFile as readFile28, rm as rm17, writeFile as writeFile8 } from "node:fs/promises";
|
|
94016
94244
|
import { dirname as dirname20, relative as relative5, resolve as resolve18 } from "node:path";
|
|
94017
94245
|
async function textArgument({
|
|
94018
94246
|
context,
|
|
@@ -94032,7 +94260,7 @@ async function writeMount({
|
|
|
94032
94260
|
files: files2
|
|
94033
94261
|
}) {
|
|
94034
94262
|
const root = resolve18(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
94035
|
-
await
|
|
94263
|
+
await rm17(root, { recursive: true, force: true });
|
|
94036
94264
|
await mkdir10(root, { recursive: true });
|
|
94037
94265
|
for (const file4 of files2) {
|
|
94038
94266
|
const target = resolve18(root, file4.path);
|
|
@@ -94897,7 +95125,7 @@ async function openclaw({
|
|
|
94897
95125
|
|
|
94898
95126
|
// src/services/operator-key-commands.service.ts
|
|
94899
95127
|
import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
|
|
94900
|
-
import { mkdir as mkdir11, readFile as readFile30, rm as
|
|
95128
|
+
import { mkdir as mkdir11, readFile as readFile30, rm as rm18, writeFile as writeFile9 } from "node:fs/promises";
|
|
94901
95129
|
import { dirname as dirname21, join as join30 } from "node:path";
|
|
94902
95130
|
|
|
94903
95131
|
// ../../modules/audit-log/contract/src/audit-log.api.ts
|
|
@@ -96335,7 +96563,7 @@ async function forgetIfOver({
|
|
|
96335
96563
|
const key = await client.post(OPERATOR_KEY_REST_PATHS.status, { keyId });
|
|
96336
96564
|
const windowOver = key.endsAt !== null && Temporal3.Instant.from(key.endsAt).epochMilliseconds <= context.nowMs();
|
|
96337
96565
|
if (key.status !== "pending" && (key.status !== "approved" || windowOver || key.spentAt)) {
|
|
96338
|
-
await
|
|
96566
|
+
await rm18(keyFile({ context, keyId }), { force: true });
|
|
96339
96567
|
}
|
|
96340
96568
|
return key;
|
|
96341
96569
|
}
|
|
@@ -96601,7 +96829,7 @@ function watchingRelease({
|
|
|
96601
96829
|
}
|
|
96602
96830
|
|
|
96603
96831
|
// src/services/rush-guard.service.ts
|
|
96604
|
-
import { rm as
|
|
96832
|
+
import { rm as rm19 } from "node:fs/promises";
|
|
96605
96833
|
var WATCH_MS3 = 2e3;
|
|
96606
96834
|
var RETRY_MS2 = 3e4;
|
|
96607
96835
|
async function guardRound(guard) {
|
|
@@ -96630,6 +96858,30 @@ async function guardRound(guard) {
|
|
|
96630
96858
|
await dropFromSpool({ context, profile: name3, messageIds: messages.map((m) => m.messageId) });
|
|
96631
96859
|
return true;
|
|
96632
96860
|
}
|
|
96861
|
+
function afterFailure({ context, error: error63 }) {
|
|
96862
|
+
const migrated = migratedNoticeOf(error63);
|
|
96863
|
+
if (migrated) {
|
|
96864
|
+
context.err(`${migrated.notice}
|
|
96865
|
+
`);
|
|
96866
|
+
return true;
|
|
96867
|
+
}
|
|
96868
|
+
if (error63 instanceof LazeApiError && error63.status === 401) return true;
|
|
96869
|
+
context.err(`laze: the rush guard will try again: ${String(error63)}
|
|
96870
|
+
`);
|
|
96871
|
+
return "failed";
|
|
96872
|
+
}
|
|
96873
|
+
async function guardRounds(guard) {
|
|
96874
|
+
const { context } = guard;
|
|
96875
|
+
const deadline = context.nowMs() + WAIT_HOOK_TIMEOUT_SECONDS * 1e3;
|
|
96876
|
+
while (context.nowMs() < deadline) {
|
|
96877
|
+
const done = await guardRound(guard).catch(
|
|
96878
|
+
(error63) => afterFailure({ context, error: error63 })
|
|
96879
|
+
);
|
|
96880
|
+
if (done === true) return 0;
|
|
96881
|
+
await context.sleep(done === "failed" ? RETRY_MS2 : 1e3);
|
|
96882
|
+
}
|
|
96883
|
+
return 0;
|
|
96884
|
+
}
|
|
96633
96885
|
function sessionIdOf({ session }) {
|
|
96634
96886
|
return session ? { sessionId: session.sessionId } : {};
|
|
96635
96887
|
}
|
|
@@ -96641,7 +96893,7 @@ async function rushWakeHook({ context, args }) {
|
|
|
96641
96893
|
if (!await claimRushGuard({ context, claudePid })) return 0;
|
|
96642
96894
|
const path = guardPathOf({ context, claudePid });
|
|
96643
96895
|
try {
|
|
96644
|
-
while (context
|
|
96896
|
+
while (await noteProcessRuns({ context, pid: claudePid })) await context.sleep(WATCH_MS3);
|
|
96645
96897
|
const { client, name: name3 } = await signedIn({ context, args });
|
|
96646
96898
|
const noted = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
96647
96899
|
const note = await readStateJson({ path: noted });
|
|
@@ -96650,30 +96902,14 @@ async function rushWakeHook({ context, args }) {
|
|
|
96650
96902
|
const rush = { id: id4, program };
|
|
96651
96903
|
const known = note ? session : void 0;
|
|
96652
96904
|
const guard = { context, client, name: name3, lock, claudePid, session: known, rush, launch };
|
|
96653
|
-
const deadline = context.nowMs() + WAIT_HOOK_TIMEOUT_SECONDS * 1e3;
|
|
96654
96905
|
try {
|
|
96655
|
-
|
|
96656
|
-
const done = await guardRound(guard).catch((error63) => {
|
|
96657
|
-
const migrated = migratedNoticeOf(error63);
|
|
96658
|
-
if (migrated) {
|
|
96659
|
-
context.err(`${migrated.notice}
|
|
96660
|
-
`);
|
|
96661
|
-
return true;
|
|
96662
|
-
}
|
|
96663
|
-
context.err(`laze: the rush guard will try again: ${String(error63)}
|
|
96664
|
-
`);
|
|
96665
|
-
return "failed";
|
|
96666
|
-
});
|
|
96667
|
-
if (done === true) return 0;
|
|
96668
|
-
await context.sleep(done === "failed" ? RETRY_MS2 : 1e3);
|
|
96669
|
-
}
|
|
96670
|
-
return 0;
|
|
96906
|
+
return await guardRounds(guard);
|
|
96671
96907
|
} finally {
|
|
96672
96908
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
96673
|
-
await
|
|
96909
|
+
await rm19(lock, { force: true });
|
|
96674
96910
|
}
|
|
96675
96911
|
} finally {
|
|
96676
|
-
await
|
|
96912
|
+
await rm19(path, { force: true });
|
|
96677
96913
|
}
|
|
96678
96914
|
}
|
|
96679
96915
|
|
|
@@ -97866,7 +98102,7 @@ function credentialProcessJson(fields) {
|
|
|
97866
98102
|
}
|
|
97867
98103
|
|
|
97868
98104
|
// src/services/vault-batch.service.ts
|
|
97869
|
-
import { rm as
|
|
98105
|
+
import { rm as rm20 } from "node:fs/promises";
|
|
97870
98106
|
async function batchOf({ response }) {
|
|
97871
98107
|
const text3 = await response.text();
|
|
97872
98108
|
if (!response.ok) {
|
|
@@ -97933,9 +98169,7 @@ async function doorOf({
|
|
|
97933
98169
|
return await client.post(door.ask, { ...body, ...door.extra });
|
|
97934
98170
|
} catch (error63) {
|
|
97935
98171
|
if (!(error63 instanceof LazeApiError)) throw error63;
|
|
97936
|
-
throw new CliUsageError(
|
|
97937
|
-
`laze vault: the batch was refused: ${error63.message} (${error63.code})`
|
|
97938
|
-
);
|
|
98172
|
+
throw new CliUsageError(`laze vault: the batch was refused: ${refusalText(error63)}`);
|
|
97939
98173
|
}
|
|
97940
98174
|
},
|
|
97941
98175
|
status: (requestId) => client.post(door.status, { requestId, ...door.extra }).catch(refusedRelease)
|
|
@@ -98048,7 +98282,7 @@ async function valuesOf({
|
|
|
98048
98282
|
}) {
|
|
98049
98283
|
const refused = refusalOf({ context, settled: settled2 });
|
|
98050
98284
|
if (refused !== 0) {
|
|
98051
|
-
await
|
|
98285
|
+
await rm20(keyPath, { force: true });
|
|
98052
98286
|
return { exitCode: refused };
|
|
98053
98287
|
}
|
|
98054
98288
|
const opened = /* @__PURE__ */ new Map();
|
|
@@ -98060,7 +98294,7 @@ async function valuesOf({
|
|
|
98060
98294
|
if (release2.message) context.err(`${release2.message}
|
|
98061
98295
|
`);
|
|
98062
98296
|
}
|
|
98063
|
-
if (!keep2) await
|
|
98297
|
+
if (!keep2) await rm20(keyPath, { force: true });
|
|
98064
98298
|
const released = /* @__PURE__ */ new Map();
|
|
98065
98299
|
for (const entry of entries) {
|
|
98066
98300
|
const fields = opened.get(keyOf(entry));
|
|
@@ -99613,6 +99847,7 @@ var HELP = `laze: work in a Laze workspace from your terminal or your agent.
|
|
|
99613
99847
|
laze wiki list|get|put|search|history|mv|rm the workspace wiki
|
|
99614
99848
|
laze skill list|install|show|pull|rm|update|pin|unpin your agent's skills and the catalogue
|
|
99615
99849
|
laze app create <name> ... build an app from scratch (--template slides for a deck), push, revert
|
|
99850
|
+
apps are also called artifacts: asked for an artifact, page, dashboard, deck or mock, build a Laze app
|
|
99616
99851
|
laze app every laze app command, with its flags
|
|
99617
99852
|
laze agents list | laze agents status <name> the workspace's agents and their context
|
|
99618
99853
|
laze agents show <name> [--json] an agent's profile: kind, how it runs, intelligence
|
|
@@ -100013,8 +100248,7 @@ function exitCodeOf({ context, error: error63 }) {
|
|
|
100013
100248
|
`);
|
|
100014
100249
|
else if (error63 instanceof CliUsageError) context.err(`${error63.message}
|
|
100015
100250
|
`);
|
|
100016
|
-
else if (error63 instanceof LazeApiError) context.err(
|
|
100017
|
-
`);
|
|
100251
|
+
else if (error63 instanceof LazeApiError) context.err(refusalLine(error63));
|
|
100018
100252
|
else {
|
|
100019
100253
|
const unreachable = unreachableReasonOf(error63);
|
|
100020
100254
|
if (unreachable === void 0) throw error63;
|
|
@@ -100033,7 +100267,7 @@ import {
|
|
|
100033
100267
|
randomBytes as randomBytes5,
|
|
100034
100268
|
sign
|
|
100035
100269
|
} from "node:crypto";
|
|
100036
|
-
import { chmod, link, mkdir as mkdir12, readFile as readFile36, rm as
|
|
100270
|
+
import { chmod, link, mkdir as mkdir12, readFile as readFile36, rm as rm21, writeFile as writeFile11 } from "node:fs/promises";
|
|
100037
100271
|
import { dirname as dirname24, join as join34 } from "node:path";
|
|
100038
100272
|
var KEYCHAIN_SERVICE = "laze-cli-machine-key";
|
|
100039
100273
|
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve26, reject) => {
|
|
@@ -100145,7 +100379,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
100145
100379
|
return kept;
|
|
100146
100380
|
}
|
|
100147
100381
|
async drop({ tier, jwk }) {
|
|
100148
|
-
if (tier === "file") return
|
|
100382
|
+
if (tier === "file") return rm21(this.pemPathOf(jwk), { force: true });
|
|
100149
100383
|
await this.options.run({
|
|
100150
100384
|
program: "security",
|
|
100151
100385
|
args: ["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", this.accountOf(jwk)],
|
|
@@ -100201,7 +100435,7 @@ async function writeOnce({ path, text: text3 }) {
|
|
|
100201
100435
|
if (error63.code === "EEXIST") return false;
|
|
100202
100436
|
throw error63;
|
|
100203
100437
|
} finally {
|
|
100204
|
-
await
|
|
100438
|
+
await rm21(temporary, { force: true });
|
|
100205
100439
|
}
|
|
100206
100440
|
}
|
|
100207
100441
|
async function writePrivate({ path, text: text3 }) {
|
|
@@ -100262,7 +100496,7 @@ function machineProofFetch({
|
|
|
100262
100496
|
|
|
100263
100497
|
// src/services/processes.service.ts
|
|
100264
100498
|
import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
|
|
100265
|
-
import { closeSync, mkdirSync, openSync } from "node:fs";
|
|
100499
|
+
import { closeSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
|
|
100266
100500
|
import { readFile as readFile37, readlink } from "node:fs/promises";
|
|
100267
100501
|
import { dirname as dirname25 } from "node:path";
|
|
100268
100502
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -100291,6 +100525,13 @@ async function parentOf(pid) {
|
|
|
100291
100525
|
const parent = Number(listed?.stdout.trim());
|
|
100292
100526
|
return parent > 0 ? parent : void 0;
|
|
100293
100527
|
}
|
|
100528
|
+
async function startOf(pid) {
|
|
100529
|
+
const stat13 = await readFile37(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
|
|
100530
|
+
const ticks = stat13 ? stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[19] : void 0;
|
|
100531
|
+
if (ticks) return ticks;
|
|
100532
|
+
const listed = await run3("ps", ["-o", "lstart=", "-p", String(pid)]).catch(() => void 0);
|
|
100533
|
+
return listed?.stdout.trim() || void 0;
|
|
100534
|
+
}
|
|
100294
100535
|
async function cwdOf(pid) {
|
|
100295
100536
|
const linked = await readlink(`/proc/${pid}/cwd`).catch(() => void 0);
|
|
100296
100537
|
if (linked) return linked;
|
|
@@ -100315,12 +100556,18 @@ function spawnOrphan({ argv, log }) {
|
|
|
100315
100556
|
});
|
|
100316
100557
|
return Number(shell.stdout.trim()) || 0;
|
|
100317
100558
|
}
|
|
100559
|
+
var LOG_LIMIT_BYTES = 1024 * 1024;
|
|
100560
|
+
function keepLogSmall({ logPath }) {
|
|
100561
|
+
const size = statSync(logPath, { throwIfNoEntry: false })?.size ?? 0;
|
|
100562
|
+
if (size > LOG_LIMIT_BYTES) renameSync(logPath, `${logPath}.1`);
|
|
100563
|
+
}
|
|
100318
100564
|
function spawnDetached({
|
|
100319
100565
|
argv,
|
|
100320
100566
|
logPath,
|
|
100321
100567
|
orphan = false
|
|
100322
100568
|
}) {
|
|
100323
100569
|
mkdirSync(dirname25(logPath), { recursive: true, mode: 448 });
|
|
100570
|
+
keepLogSmall({ logPath });
|
|
100324
100571
|
const log = openSync(logPath, "a", 384);
|
|
100325
100572
|
if (orphan) {
|
|
100326
100573
|
try {
|
|
@@ -100344,7 +100591,7 @@ function stop2(pid) {
|
|
|
100344
100591
|
return true;
|
|
100345
100592
|
}
|
|
100346
100593
|
function nodeProcesses() {
|
|
100347
|
-
return { pid: process.pid, alive, argsOf: argsOf2, parentOf, cwdOf, spawnDetached, stop: stop2 };
|
|
100594
|
+
return { pid: process.pid, alive, argsOf: argsOf2, startOf, parentOf, cwdOf, spawnDetached, stop: stop2 };
|
|
100348
100595
|
}
|
|
100349
100596
|
|
|
100350
100597
|
// src/services/proxied-fetch.service.ts
|