@lazehq/cli 0.1.89 → 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 +434 -197
- 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",
|
|
@@ -71857,13 +71980,13 @@ function formatSearch({
|
|
|
71857
71980
|
}
|
|
71858
71981
|
|
|
71859
71982
|
// src/services/claude-turn.service.ts
|
|
71860
|
-
import { rm as
|
|
71861
|
-
import { dirname as
|
|
71983
|
+
import { rm as rm3 } from "node:fs/promises";
|
|
71984
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
71862
71985
|
|
|
71863
71986
|
// src/services/harness-session.service.ts
|
|
71864
|
-
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";
|
|
71865
71988
|
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
71866
|
-
import { dirname as
|
|
71989
|
+
import { dirname as dirname5, join as join5 } from "node:path";
|
|
71867
71990
|
|
|
71868
71991
|
// src/rules/claude-subagent.rules.ts
|
|
71869
71992
|
function lastCallAtOf({ text: text3, command }) {
|
|
@@ -71995,6 +72118,83 @@ async function claudeProjectOf({
|
|
|
71995
72118
|
return candidates.find((folder) => holds({ folder, inner: context.cwd })) ?? resolve2(context.cwd);
|
|
71996
72119
|
}
|
|
71997
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
|
+
|
|
71998
72198
|
// src/services/harness-session.service.ts
|
|
71999
72199
|
function sessionOf({
|
|
72000
72200
|
context,
|
|
@@ -72023,9 +72223,8 @@ async function rememberSession({
|
|
|
72023
72223
|
session
|
|
72024
72224
|
}) {
|
|
72025
72225
|
if (!session || !claudePid) return;
|
|
72026
|
-
const path = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
72027
72226
|
const launch = launchEnvOf({ inherited: context.environment.inherited });
|
|
72028
|
-
await
|
|
72227
|
+
await writeSessionNote({ context, pid: claudePid, note: { ...session, launch } });
|
|
72029
72228
|
}
|
|
72030
72229
|
async function currentSessionOf({
|
|
72031
72230
|
context,
|
|
@@ -72094,29 +72293,25 @@ async function liveElsewhere({
|
|
|
72094
72293
|
asleepCounts = true
|
|
72095
72294
|
}) {
|
|
72096
72295
|
if (await rushKeeps({ context, key, claudePid, asleepCounts })) return true;
|
|
72097
|
-
const
|
|
72098
|
-
|
|
72099
|
-
|
|
72100
|
-
|
|
72101
|
-
const noted = await readStateJson({ path: join4(folder, file4) });
|
|
72102
|
-
if (noted && sessionKeyOf({ session: noted }) === key) return true;
|
|
72103
|
-
}
|
|
72104
|
-
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
|
+
);
|
|
72105
72300
|
}
|
|
72106
72301
|
async function claudeTranscriptOf({
|
|
72107
72302
|
context,
|
|
72108
72303
|
sessionId
|
|
72109
72304
|
}) {
|
|
72110
72305
|
const inherited = context.environment.inherited;
|
|
72111
|
-
const root =
|
|
72112
|
-
inherited.CLAUDE_CONFIG_DIR ||
|
|
72306
|
+
const root = join5(
|
|
72307
|
+
inherited.CLAUDE_CONFIG_DIR || join5(inherited.HOME || homedir2(), ".claude"),
|
|
72113
72308
|
"projects"
|
|
72114
72309
|
);
|
|
72115
|
-
const folders = await
|
|
72310
|
+
const folders = await readdir2(root).catch(() => []);
|
|
72116
72311
|
const found = await Promise.all(
|
|
72117
72312
|
folders.map(async (folder) => {
|
|
72118
|
-
const path =
|
|
72119
|
-
return
|
|
72313
|
+
const path = join5(root, folder, `${sessionId}.jsonl`);
|
|
72314
|
+
return stat3(path).then(
|
|
72120
72315
|
(info) => info.isFile() ? [{ path, at: info.mtimeMs }] : [],
|
|
72121
72316
|
() => []
|
|
72122
72317
|
);
|
|
@@ -72143,11 +72338,11 @@ async function runsInSubagent({ context, command }) {
|
|
|
72143
72338
|
if (!sessionId) return false;
|
|
72144
72339
|
const { path } = await claudeTranscriptOf({ context, sessionId });
|
|
72145
72340
|
if (!path) return false;
|
|
72146
|
-
const folder =
|
|
72147
|
-
const files2 = await
|
|
72341
|
+
const folder = join5(dirname5(path), sessionId, "subagents");
|
|
72342
|
+
const files2 = await readdir2(folder).catch(() => []);
|
|
72148
72343
|
const subagents = await Promise.all(
|
|
72149
72344
|
files2.filter((file4) => file4.endsWith(".jsonl")).map(
|
|
72150
|
-
async (file4) => lastCallAtOf({ text: await tailOf({ path:
|
|
72345
|
+
async (file4) => lastCallAtOf({ text: await tailOf({ path: join5(folder, file4) }), command })
|
|
72151
72346
|
)
|
|
72152
72347
|
);
|
|
72153
72348
|
const session = lastCallAtOf({ text: await tailOf({ path }), command });
|
|
@@ -72221,7 +72416,7 @@ async function notBoundNotice({
|
|
|
72221
72416
|
|
|
72222
72417
|
// src/services/plugin-hook.service.ts
|
|
72223
72418
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
72224
|
-
import { join as
|
|
72419
|
+
import { join as join6 } from "node:path";
|
|
72225
72420
|
async function agentProfileHere({
|
|
72226
72421
|
context,
|
|
72227
72422
|
args,
|
|
@@ -72242,7 +72437,7 @@ async function agentProfileHere({
|
|
|
72242
72437
|
}
|
|
72243
72438
|
async function projectHooksHere({ context }) {
|
|
72244
72439
|
const directory = context.environment.inherited.CLAUDE_PROJECT_DIR || context.cwd;
|
|
72245
|
-
const path =
|
|
72440
|
+
const path = join6(directory, ".claude", "settings.local.json");
|
|
72246
72441
|
return readFile6(path, "utf8").then((text3) => hasLazeHooks({ settings: JSON.parse(text3) })).catch(() => false);
|
|
72247
72442
|
}
|
|
72248
72443
|
async function pluginHookArgs({
|
|
@@ -72261,7 +72456,7 @@ async function pluginHookArgs({
|
|
|
72261
72456
|
var PRE_TOOL_TIMEOUT_MS = 3e3;
|
|
72262
72457
|
function statePath({ context, agent: agent3 }) {
|
|
72263
72458
|
const safe = agent3.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
72264
|
-
return
|
|
72459
|
+
return join7(dirname6(context.environment.configPath), "turns", `${safe}.json`);
|
|
72265
72460
|
}
|
|
72266
72461
|
async function readState({ context, agent: agent3 }) {
|
|
72267
72462
|
return readStateJson({ path: statePath({ context, agent: agent3 }) });
|
|
@@ -72326,7 +72521,7 @@ async function turnEnded({
|
|
|
72326
72521
|
}) {
|
|
72327
72522
|
const state = await readState({ context, agent: agent3 });
|
|
72328
72523
|
if (!state) return;
|
|
72329
|
-
await
|
|
72524
|
+
await rm3(statePath({ context, agent: agent3 }), { force: true });
|
|
72330
72525
|
await beat({ client, state, working: false }).catch(() => void 0);
|
|
72331
72526
|
}
|
|
72332
72527
|
async function preToolHook({ context, args }) {
|
|
@@ -72374,7 +72569,7 @@ async function preToolHook({ context, args }) {
|
|
|
72374
72569
|
}
|
|
72375
72570
|
|
|
72376
72571
|
// src/services/message-files.service.ts
|
|
72377
|
-
import { readFile as readFile7, stat as
|
|
72572
|
+
import { readFile as readFile7, stat as stat4 } from "node:fs/promises";
|
|
72378
72573
|
import { basename as basename4, resolve as resolve3 } from "node:path";
|
|
72379
72574
|
|
|
72380
72575
|
// src/rules/file-types.rules.ts
|
|
@@ -72473,7 +72668,7 @@ async function readyOf({ context, source }) {
|
|
|
72473
72668
|
return asBytes({ source, file: await downloaded({ context, url: value }) });
|
|
72474
72669
|
}
|
|
72475
72670
|
const full = resolve3(context.cwd, value);
|
|
72476
|
-
const found = await
|
|
72671
|
+
const found = await stat4(full).catch(() => void 0);
|
|
72477
72672
|
if (found?.isFile()) return asBytes({ source, file: await local({ full }) });
|
|
72478
72673
|
const marked = fileMarkerIdsIn(value)[0] ?? (UPLOADED_ID.test(value) ? value : void 0);
|
|
72479
72674
|
if (marked) return { kind: "id", id: marked };
|
|
@@ -73098,7 +73293,7 @@ async function slackOf({
|
|
|
73098
73293
|
if (!(error63 instanceof LazeApiError)) throw error63;
|
|
73099
73294
|
if (error63.code === "slack_search_person_only") return { answer: null, note: AGENT_NOTE };
|
|
73100
73295
|
if (error63.status === 404) return { answer: null, note: null };
|
|
73101
|
-
return { answer: null, note: `From Slack: ${
|
|
73296
|
+
return { answer: null, note: `From Slack: ${refusalText(error63)}` };
|
|
73102
73297
|
}
|
|
73103
73298
|
}
|
|
73104
73299
|
async function search({ context, args }) {
|
|
@@ -73126,11 +73321,11 @@ function channelLabelIn(channel) {
|
|
|
73126
73321
|
}
|
|
73127
73322
|
|
|
73128
73323
|
// src/services/claude-wait.service.ts
|
|
73129
|
-
import { readFile as readFile8, rm as
|
|
73324
|
+
import { readFile as readFile8, rm as rm6 } from "node:fs/promises";
|
|
73130
73325
|
|
|
73131
73326
|
// src/services/connect-service.service.ts
|
|
73132
73327
|
import { createHash as createHash2 } from "node:crypto";
|
|
73133
|
-
import { mkdir as mkdir3, rm as
|
|
73328
|
+
import { mkdir as mkdir3, rm as rm5, writeFile } from "node:fs/promises";
|
|
73134
73329
|
import { dirname as dirname12, join as join14 } from "node:path";
|
|
73135
73330
|
|
|
73136
73331
|
// src/rules/connect-service.rules.ts
|
|
@@ -73253,25 +73448,25 @@ function rolloutEventOf({
|
|
|
73253
73448
|
}
|
|
73254
73449
|
|
|
73255
73450
|
// src/services/connect-delivery.service.ts
|
|
73256
|
-
import { rm as
|
|
73451
|
+
import { rm as rm4, stat as stat5 } from "node:fs/promises";
|
|
73257
73452
|
import { homedir as homedir3, hostname as hostname5 } from "node:os";
|
|
73258
73453
|
import { dirname as dirname11, join as join13 } from "node:path";
|
|
73259
73454
|
|
|
73260
73455
|
// src/services/codex-turn-watch.service.ts
|
|
73261
|
-
import { open as open4, readdir as
|
|
73262
|
-
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";
|
|
73263
73458
|
var READ_MS = 1500;
|
|
73264
73459
|
var KEEP_WORKING_MS = 3e4;
|
|
73265
73460
|
async function codexRolloutPathOf({
|
|
73266
73461
|
codexHome,
|
|
73267
73462
|
threadId
|
|
73268
73463
|
}) {
|
|
73269
|
-
const root =
|
|
73270
|
-
const files2 = await
|
|
73464
|
+
const root = join8(codexHome, "sessions");
|
|
73465
|
+
const files2 = await readdir3(root, { recursive: true }).catch(() => []);
|
|
73271
73466
|
const file4 = files2.find(
|
|
73272
73467
|
(name3) => basename5(name3).startsWith("rollout-") && name3.endsWith(`-${threadId}.jsonl`)
|
|
73273
73468
|
);
|
|
73274
|
-
return file4 ?
|
|
73469
|
+
return file4 ? join8(root, file4) : void 0;
|
|
73275
73470
|
}
|
|
73276
73471
|
function rolloutPathOf({ delivery }) {
|
|
73277
73472
|
return codexRolloutPathOf({ codexHome: delivery.codexHome, threadId: delivery.threadId });
|
|
@@ -73360,7 +73555,7 @@ var CodexTurnWatch = class _CodexTurnWatch {
|
|
|
73360
73555
|
};
|
|
73361
73556
|
|
|
73362
73557
|
// src/services/mcp-relay.service.ts
|
|
73363
|
-
import { dirname as
|
|
73558
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
73364
73559
|
|
|
73365
73560
|
// ../../node_modules/.pnpm/ws@8.21.3_bufferutil@4.1.0/node_modules/ws/wrapper.mjs
|
|
73366
73561
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -73696,7 +73891,7 @@ var STOPS = /* @__PURE__ */ new Map([
|
|
|
73696
73891
|
[CONNECTOR_RELAY_CLOSE.replaced.code, "another relay for this server took over"]
|
|
73697
73892
|
]);
|
|
73698
73893
|
function mcpRelaysPathOf({ context }) {
|
|
73699
|
-
return
|
|
73894
|
+
return join9(dirname7(context.environment.configPath), "connect", "mcp-relays.json");
|
|
73700
73895
|
}
|
|
73701
73896
|
async function readMcpRelays({ context }) {
|
|
73702
73897
|
return await readStateJson({ path: mcpRelaysPathOf({ context }) }) ?? {};
|
|
@@ -73856,7 +74051,7 @@ var McpRelayLoops = class _McpRelayLoops {
|
|
|
73856
74051
|
};
|
|
73857
74052
|
|
|
73858
74053
|
// src/services/openclaw-relay.service.ts
|
|
73859
|
-
import { dirname as
|
|
74054
|
+
import { dirname as dirname8, join as join10 } from "node:path";
|
|
73860
74055
|
|
|
73861
74056
|
// ../../modules/openclaw/contract/src/openclaw.ts
|
|
73862
74057
|
var workspaceIdSchema18 = external_exports.string().min(1);
|
|
@@ -74077,7 +74272,7 @@ var STOPS2 = /* @__PURE__ */ new Map([
|
|
|
74077
74272
|
[OPENCLAW_RELAY_CLOSE.replaced.code, "another relay for this gateway took over"]
|
|
74078
74273
|
]);
|
|
74079
74274
|
function relaysPathOf({ context }) {
|
|
74080
|
-
return
|
|
74275
|
+
return join10(dirname8(context.environment.configPath), "connect", "openclaw-relays.json");
|
|
74081
74276
|
}
|
|
74082
74277
|
async function readRelays({ context }) {
|
|
74083
74278
|
return await readStateJson({ path: relaysPathOf({ context }) }) ?? {};
|
|
@@ -74269,12 +74464,8 @@ var RelayLoops = class _RelayLoops {
|
|
|
74269
74464
|
}
|
|
74270
74465
|
};
|
|
74271
74466
|
|
|
74272
|
-
// src/services/rush-listeners.service.ts
|
|
74273
|
-
import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
|
|
74274
|
-
import { dirname as dirname9, join as join11 } from "node:path";
|
|
74275
|
-
|
|
74276
74467
|
// src/services/rush-host.service.ts
|
|
74277
|
-
import { dirname as
|
|
74468
|
+
import { dirname as dirname9, join as join11 } from "node:path";
|
|
74278
74469
|
async function rushAboveOf({
|
|
74279
74470
|
context,
|
|
74280
74471
|
from = context.processes.pid
|
|
@@ -74288,7 +74479,7 @@ async function rushAboveOf({
|
|
|
74288
74479
|
return void 0;
|
|
74289
74480
|
}
|
|
74290
74481
|
function guardPathOf({ context, claudePid }) {
|
|
74291
|
-
return
|
|
74482
|
+
return join11(dirname9(context.environment.configPath), "rush-guards", `${claudePid}.json`);
|
|
74292
74483
|
}
|
|
74293
74484
|
async function startRushGuard({
|
|
74294
74485
|
context,
|
|
@@ -74301,7 +74492,7 @@ async function startRushGuard({
|
|
|
74301
74492
|
if (holder && context.processes.alive(holder.pid)) return;
|
|
74302
74493
|
const flags2 = ["--profile", profile, "--claude-pid", String(claudePid), "--rush-id", rush.id];
|
|
74303
74494
|
const argv = [...context.program, "hook", "rush-wake", ...flags2, "--rush-program", rush.program];
|
|
74304
|
-
const logPath =
|
|
74495
|
+
const logPath = join11(dirname9(context.environment.configPath), "rush-guards", "guard.log");
|
|
74305
74496
|
context.processes.spawnDetached({ argv: ["sh", "-c", '"$@" &', "sh", ...argv], logPath });
|
|
74306
74497
|
}
|
|
74307
74498
|
async function claimRushGuard({
|
|
@@ -74329,22 +74520,11 @@ async function jsonOf(path) {
|
|
|
74329
74520
|
return readStateJson({ path });
|
|
74330
74521
|
}
|
|
74331
74522
|
async function notesOf({ context }) {
|
|
74332
|
-
const
|
|
74333
|
-
|
|
74334
|
-
|
|
74335
|
-
|
|
74336
|
-
|
|
74337
|
-
const note = await jsonOf(join11(folder, file4));
|
|
74338
|
-
const at = await stat4(join11(folder, file4)).then(
|
|
74339
|
-
(info) => info.mtimeMs,
|
|
74340
|
-
() => 0
|
|
74341
|
-
);
|
|
74342
|
-
if (!pid || !note) return [];
|
|
74343
|
-
const { launch = {}, ...session } = note;
|
|
74344
|
-
return [{ pid, key: sessionKeyOf({ session }), at, session, launch }];
|
|
74345
|
-
})
|
|
74346
|
-
);
|
|
74347
|
-
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
|
+
});
|
|
74348
74528
|
}
|
|
74349
74529
|
async function rushListenersOf({
|
|
74350
74530
|
context
|
|
@@ -74362,25 +74542,39 @@ async function rushListenersOf({
|
|
|
74362
74542
|
for (const [key, profile] of bound) {
|
|
74363
74543
|
const one = sessions.find((each) => `claude-code:${each.sessionId}` === key);
|
|
74364
74544
|
if (!one?.id) continue;
|
|
74545
|
+
const entry = config2.profiles[profile];
|
|
74546
|
+
const refused = entry ? refusedRecently({ profile: entry, nowMs: context.nowMs() }) : false;
|
|
74365
74547
|
const own2 = notes.filter((note) => note.key === key);
|
|
74366
|
-
|
|
74367
|
-
const listenerPid = await listenerOf({ context, key, profile, pids });
|
|
74368
|
-
const waiterPid = await waiterOf({ context, key, profile });
|
|
74369
|
-
const lastClaudePid = pids.find((pid) => !context.processes.alive(pid));
|
|
74370
|
-
const newest = own2[0];
|
|
74371
|
-
rows.push({
|
|
74372
|
-
profile,
|
|
74373
|
-
rushId: one.id,
|
|
74374
|
-
key,
|
|
74375
|
-
standing: rushStandingOf({ one }),
|
|
74376
|
-
...listenerPid ? { listenerPid } : {},
|
|
74377
|
-
...waiterPid ? { waiterPid } : {},
|
|
74378
|
-
...lastClaudePid ? { lastClaudePid } : {},
|
|
74379
|
-
...newest ? { noted: { session: newest.session, launch: newest.launch } } : {}
|
|
74380
|
-
});
|
|
74548
|
+
rows.push(await rowOf({ context, key, profile, rushId: one.id, one, own: own2, refused }));
|
|
74381
74549
|
}
|
|
74382
74550
|
return rows;
|
|
74383
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
|
+
}
|
|
74384
74578
|
async function listenerOf({
|
|
74385
74579
|
context,
|
|
74386
74580
|
key,
|
|
@@ -74406,7 +74600,7 @@ async function waiterOf({
|
|
|
74406
74600
|
async function rearmRushGuards({ context }) {
|
|
74407
74601
|
let started = 0;
|
|
74408
74602
|
for (const row of await rushListenersOf({ context })) {
|
|
74409
|
-
if (row.standing !== "asleep" || row.listenerPid || !row.lastClaudePid) continue;
|
|
74603
|
+
if (row.standing !== "asleep" || row.listenerPid || !row.lastClaudePid || row.refused) continue;
|
|
74410
74604
|
const rush = { id: row.rushId, program: "rush" };
|
|
74411
74605
|
await startRushGuard({ context, profile: row.profile, claudePid: row.lastClaudePid, rush });
|
|
74412
74606
|
started += 1;
|
|
@@ -74423,17 +74617,24 @@ function clientOf({ context, profile }) {
|
|
|
74423
74617
|
return context.store.read().then((config2) => {
|
|
74424
74618
|
const entry = config2.profiles[profile];
|
|
74425
74619
|
if (!entry || entry.migrated) return void 0;
|
|
74620
|
+
if (refusedRecently({ profile: entry, nowMs: context.nowMs() })) return void 0;
|
|
74426
74621
|
return LazeClient.create({
|
|
74427
74622
|
baseUrl: entry.url,
|
|
74428
74623
|
token: entry.token,
|
|
74429
74624
|
fetcher: (input2, init) => context.fetcher(input2, { ...init, signal: AbortSignal.timeout(CHECK_TIMEOUT_MS) }),
|
|
74430
|
-
onMigrated: markMigratedOn({ context, profile })
|
|
74625
|
+
onMigrated: markMigratedOn({ context, profile }),
|
|
74626
|
+
onRefused: markRefusedOn({ context, profile, token: entry.token })
|
|
74431
74627
|
});
|
|
74432
74628
|
});
|
|
74433
74629
|
}
|
|
74434
|
-
async function waitingOf({
|
|
74630
|
+
async function waitingOf({
|
|
74631
|
+
context,
|
|
74632
|
+
profile
|
|
74633
|
+
}) {
|
|
74435
74634
|
const client = await clientOf({ context, profile });
|
|
74436
|
-
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
|
+
);
|
|
74437
74638
|
}
|
|
74438
74639
|
function waitedMsOf({ waiting, nowMs: nowMs2 }) {
|
|
74439
74640
|
if (waiting.count === 0 || !waiting.oldestPostedAt) return 0;
|
|
@@ -74637,7 +74838,8 @@ async function serveAgent({
|
|
|
74637
74838
|
baseUrl: entry.url,
|
|
74638
74839
|
token: entry.token,
|
|
74639
74840
|
fetcher: context.fetcher,
|
|
74640
|
-
onMigrated: markMigratedOn({ context, profile })
|
|
74841
|
+
onMigrated: markMigratedOn({ context, profile }),
|
|
74842
|
+
onRefused: markRefusedOn({ context, profile, token: entry.token })
|
|
74641
74843
|
});
|
|
74642
74844
|
const watch = CodexTurnWatch.create({ context, client, profile, delivery: entry.delivery });
|
|
74643
74845
|
const ended = new AbortController();
|
|
@@ -74795,7 +74997,7 @@ async function runConnectLoop({ context }) {
|
|
|
74795
74997
|
await mcpRelays.stopAll();
|
|
74796
74998
|
for (const current3 of run4.served.values()) current3.stop.abort();
|
|
74797
74999
|
await Promise.all([...run4.served.values()].map((current3) => current3.done));
|
|
74798
|
-
if (await holdsLock(run4)) await
|
|
75000
|
+
if (await holdsLock(run4)) await rm4(run4.path, { force: true });
|
|
74799
75001
|
}
|
|
74800
75002
|
return 0;
|
|
74801
75003
|
}
|
|
@@ -74958,11 +75160,8 @@ async function status2({ context }) {
|
|
|
74958
75160
|
}
|
|
74959
75161
|
for (const line of await mcpRelayLinesOf({ context })) context.out(`${line}
|
|
74960
75162
|
`);
|
|
74961
|
-
for (const
|
|
74962
|
-
const waiting = await waitingOf({ context, profile: row.profile });
|
|
74963
|
-
context.out(`${rushLineOf({ row })}${inLazeOf({ row, waiting, nowMs: context.nowMs() })}
|
|
75163
|
+
for (const line of await rushLinesOf({ context })) context.out(`${line}
|
|
74964
75164
|
`);
|
|
74965
|
-
}
|
|
74966
75165
|
const config2 = await context.store.read();
|
|
74967
75166
|
const linked = Object.entries(config2.profiles).filter(([, profile]) => profile.delivery);
|
|
74968
75167
|
if (linked.length === 0) context.out("No Codex agent is linked on this machine.\n");
|
|
@@ -74982,6 +75181,20 @@ async function mcpRelayLinesOf({ context }) {
|
|
|
74982
75181
|
return `${connectionId} ${relay2.label} ${targetLineOf({ target: relay2.target })} ${state}`;
|
|
74983
75182
|
});
|
|
74984
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
|
+
}
|
|
74985
75198
|
function rushLineOf({ row }) {
|
|
74986
75199
|
const head = `${row.profile} Claude Code in rush ${row.rushId} ${row.standing}`;
|
|
74987
75200
|
if (row.standing === "awake" && row.waiterPid) {
|
|
@@ -75033,11 +75246,11 @@ async function uninstall({ context }) {
|
|
|
75033
75246
|
command: ["systemctl", "--user", "disable", `${installed.name}.service`]
|
|
75034
75247
|
});
|
|
75035
75248
|
}
|
|
75036
|
-
if (installed.file) await
|
|
75249
|
+
if (installed.file) await rm5(installed.file, { force: true });
|
|
75037
75250
|
if (installed.manager === "systemd") {
|
|
75038
75251
|
await run({ context, command: ["systemctl", "--user", "daemon-reload"] });
|
|
75039
75252
|
}
|
|
75040
|
-
await
|
|
75253
|
+
await rm5(path, { force: true });
|
|
75041
75254
|
context.out(
|
|
75042
75255
|
`Removed the connect service (${installed.manager}, ${installed.name}). Linked Codex agents get no messages until \`laze connect install\`.
|
|
75043
75256
|
`
|
|
@@ -75231,7 +75444,7 @@ async function waitForMessages({ context, args }) {
|
|
|
75231
75444
|
return 0;
|
|
75232
75445
|
} finally {
|
|
75233
75446
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
75234
|
-
await
|
|
75447
|
+
await rm6(lock, { force: true });
|
|
75235
75448
|
}
|
|
75236
75449
|
}
|
|
75237
75450
|
async function healRushDelivery({ context }) {
|
|
@@ -75255,6 +75468,7 @@ async function waitHook({ context, args }) {
|
|
|
75255
75468
|
`);
|
|
75256
75469
|
return 2;
|
|
75257
75470
|
}
|
|
75471
|
+
if (error63 instanceof LazeApiError && error63.status === 401) return 0;
|
|
75258
75472
|
context.err(`laze: the background waiter stopped: ${String(error63)}
|
|
75259
75473
|
`);
|
|
75260
75474
|
return 0;
|
|
@@ -75272,13 +75486,13 @@ async function monitorServes({
|
|
|
75272
75486
|
|
|
75273
75487
|
// src/services/codex-link.service.ts
|
|
75274
75488
|
import { createReadStream } from "node:fs";
|
|
75275
|
-
import { readdir as readdir5, rm as
|
|
75489
|
+
import { readdir as readdir5, rm as rm8, stat as stat7 } from "node:fs/promises";
|
|
75276
75490
|
import { join as join16, resolve as resolve4 } from "node:path";
|
|
75277
75491
|
import { createInterface as createInterface2 } from "node:readline";
|
|
75278
75492
|
|
|
75279
75493
|
// src/services/codex-adopt.service.ts
|
|
75280
75494
|
import { spawn as spawn2 } from "node:child_process";
|
|
75281
|
-
import { readdir as readdir4, rm as
|
|
75495
|
+
import { readdir as readdir4, rm as rm7, stat as stat6 } from "node:fs/promises";
|
|
75282
75496
|
import { join as join15 } from "node:path";
|
|
75283
75497
|
import { createInterface } from "node:readline";
|
|
75284
75498
|
|
|
@@ -75556,7 +75770,7 @@ Log: ${record4.log}
|
|
|
75556
75770
|
async function adoptStop({ context, profile }) {
|
|
75557
75771
|
const path = statePathOf({ context, kind: "adopt", profile });
|
|
75558
75772
|
const record4 = await recordOf({ path });
|
|
75559
|
-
await
|
|
75773
|
+
await rm7(path, { force: true });
|
|
75560
75774
|
if (!record4 || !context.processes.stop(record4.pid)) {
|
|
75561
75775
|
context.out(`laze adopt codex was not running in the background for profile "${profile}".
|
|
75562
75776
|
`);
|
|
@@ -75701,7 +75915,7 @@ async function stopAdopt({ context, profile }) {
|
|
|
75701
75915
|
const running = await readJson({ path });
|
|
75702
75916
|
if (!running) return;
|
|
75703
75917
|
context.processes.stop(running.pid);
|
|
75704
|
-
await
|
|
75918
|
+
await rm8(path, { force: true });
|
|
75705
75919
|
}
|
|
75706
75920
|
async function linkCodexSession({
|
|
75707
75921
|
context,
|
|
@@ -75740,7 +75954,7 @@ async function linkCodexSession({
|
|
|
75740
75954
|
}
|
|
75741
75955
|
|
|
75742
75956
|
// src/services/laze-plugin.service.ts
|
|
75743
|
-
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";
|
|
75744
75958
|
import { homedir as homedir4 } from "node:os";
|
|
75745
75959
|
import { dirname as dirname13, join as join18 } from "node:path";
|
|
75746
75960
|
|
|
@@ -76108,7 +76322,7 @@ async function plugin({ context, args }) {
|
|
|
76108
76322
|
if (action === "uninstall") {
|
|
76109
76323
|
const name3 = pluginNameHere({ context });
|
|
76110
76324
|
const removed = await unregisterAs({ context, name: name3 });
|
|
76111
|
-
await
|
|
76325
|
+
await rm9(registeredMarkOf({ context }), { force: true });
|
|
76112
76326
|
context.out(
|
|
76113
76327
|
removed ? `Removed the Laze plugin ${name3}@${name3} from Claude Code.
|
|
76114
76328
|
` : `Claude Code did not remove it; run: claude plugin uninstall ${name3}@${name3} && claude plugin marketplace remove ${name3}
|
|
@@ -76129,8 +76343,28 @@ async function plugin({ context, args }) {
|
|
|
76129
76343
|
return 0;
|
|
76130
76344
|
}
|
|
76131
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
|
+
|
|
76132
76366
|
// src/services/mcp-channel.service.ts
|
|
76133
|
-
import { rm as
|
|
76367
|
+
import { rm as rm10 } from "node:fs/promises";
|
|
76134
76368
|
var LAZE_MCP_SERVER = "laze";
|
|
76135
76369
|
var DEV_CHANNELS_FLAG = "--dangerously-load-development-channels";
|
|
76136
76370
|
var ROUND_SECONDS3 = 50;
|
|
@@ -76249,7 +76483,7 @@ async function pushInbox({
|
|
|
76249
76483
|
`);
|
|
76250
76484
|
}
|
|
76251
76485
|
} finally {
|
|
76252
|
-
await
|
|
76486
|
+
await rm10(marker, { force: true });
|
|
76253
76487
|
}
|
|
76254
76488
|
}
|
|
76255
76489
|
|
|
@@ -76354,9 +76588,6 @@ async function harnessOf2({ context, args }) {
|
|
|
76354
76588
|
const nearest = await nearestHarnessOf({ context });
|
|
76355
76589
|
return nearest ?? { harness: context.environment.harness, pid: void 0 };
|
|
76356
76590
|
}
|
|
76357
|
-
function slugOf(name3) {
|
|
76358
|
-
return name3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "agent";
|
|
76359
|
-
}
|
|
76360
76591
|
function settingsOf({ path, text: text3 }) {
|
|
76361
76592
|
try {
|
|
76362
76593
|
return JSON.parse(text3);
|
|
@@ -76524,6 +76755,7 @@ async function settleLinked({
|
|
|
76524
76755
|
}
|
|
76525
76756
|
const hooked = claude && !args.flags["no-hook"];
|
|
76526
76757
|
const hookPath = hooked ? await installHooks({ context, directory, profile: name3 }) : void 0;
|
|
76758
|
+
if (hooked) await listenAfterLink({ context, args, profile: name3, claudePid: pid });
|
|
76527
76759
|
const laze = lazeCommandOf({ program: context.program });
|
|
76528
76760
|
const steps = await nextStepsFor({
|
|
76529
76761
|
context,
|
|
@@ -76545,21 +76777,6 @@ async function settleLinked({
|
|
|
76545
76777
|
);
|
|
76546
76778
|
return name3;
|
|
76547
76779
|
}
|
|
76548
|
-
function linkedProfileNameOf({
|
|
76549
|
-
args,
|
|
76550
|
-
linked,
|
|
76551
|
-
profiles: profiles2
|
|
76552
|
-
}) {
|
|
76553
|
-
const wanted = flagText({ args, name: "profile" }) || `agent-${slugOf(linked.agent.name)}`;
|
|
76554
|
-
const free = (name3) => {
|
|
76555
|
-
const held = profiles2[name3];
|
|
76556
|
-
return !held || held.kind === "agent" && held.agentId === linked.agent.id;
|
|
76557
|
-
};
|
|
76558
|
-
if (free(wanted)) return wanted;
|
|
76559
|
-
for (let number4 = 2; ; number4 += 1) {
|
|
76560
|
-
if (free(`${wanted}-${number4}`)) return `${wanted}-${number4}`;
|
|
76561
|
-
}
|
|
76562
|
-
}
|
|
76563
76780
|
function requestProfileNameOf({ profile }) {
|
|
76564
76781
|
return `${profile}-request`;
|
|
76565
76782
|
}
|
|
@@ -76799,11 +77016,6 @@ function formatPools({ pools, nowMs: nowMs2 }) {
|
|
|
76799
77016
|
return `${pools.pools.map((pool) => formatPool({ pool, nowMs: nowMs2 })).join("\n\n")}
|
|
76800
77017
|
`;
|
|
76801
77018
|
}
|
|
76802
|
-
function refusalLine({ code, message: message2 }) {
|
|
76803
|
-
const sentence = message2.trim().replace(/[.!]*$/, ".");
|
|
76804
|
-
return `laze: ${code}: ${sentence}
|
|
76805
|
-
`;
|
|
76806
|
-
}
|
|
76807
77019
|
var SWITCH_REASONS = {
|
|
76808
77020
|
out_of_usage: "out of usage",
|
|
76809
77021
|
login_removed: "login removed",
|
|
@@ -77836,7 +78048,7 @@ async function uploadParts({
|
|
|
77836
78048
|
await client.put(`/api/agents/me/migrations/${migrationId}/parts/${index}`, { text: text3 });
|
|
77837
78049
|
} catch (error63) {
|
|
77838
78050
|
if (migratedNoticeOf(error63)) throw error63;
|
|
77839
|
-
const why =
|
|
78051
|
+
const why = whyOf(error63);
|
|
77840
78052
|
throw new CliUsageError(
|
|
77841
78053
|
`Part ${index + 1} of ${upload.parts.length} did not upload (${why}). Nothing moved yet: run \`${again}\` again.`
|
|
77842
78054
|
);
|
|
@@ -77927,6 +78139,10 @@ async function agentMigrate({ context, args }) {
|
|
|
77927
78139
|
if (sub || !args.words[2]) throw new CliUsageError(`Usage: ${MIGRATE_USAGE}`);
|
|
77928
78140
|
return migrate({ context, args });
|
|
77929
78141
|
}
|
|
78142
|
+
function whyOf(error63) {
|
|
78143
|
+
if (error63 instanceof LazeApiError) return refusalText(error63);
|
|
78144
|
+
return error63 instanceof Error ? error63.message : String(error63);
|
|
78145
|
+
}
|
|
77930
78146
|
|
|
77931
78147
|
// src/services/agent-session-commands.service.ts
|
|
77932
78148
|
var NO_SESSION = "Run this inside the Claude Code or Codex session the agent should listen in, or pass --session <id>.";
|
|
@@ -80566,7 +80782,7 @@ async function appPinsCommand({
|
|
|
80566
80782
|
|
|
80567
80783
|
// src/services/app-script-check.service.ts
|
|
80568
80784
|
import { execFile } from "node:child_process";
|
|
80569
|
-
import { mkdtemp, rm as
|
|
80785
|
+
import { mkdtemp, rm as rm11, writeFile as writeFile4 } from "node:fs/promises";
|
|
80570
80786
|
import { tmpdir } from "node:os";
|
|
80571
80787
|
import { join as join21 } from "node:path";
|
|
80572
80788
|
import { promisify } from "node:util";
|
|
@@ -80614,7 +80830,7 @@ async function scriptErrorsOf({
|
|
|
80614
80830
|
);
|
|
80615
80831
|
return [...errors.filter((error63) => error63 !== null), ...unknown2];
|
|
80616
80832
|
} finally {
|
|
80617
|
-
await
|
|
80833
|
+
await rm11(dir, { recursive: true, force: true });
|
|
80618
80834
|
}
|
|
80619
80835
|
}
|
|
80620
80836
|
|
|
@@ -82542,7 +82758,7 @@ function loginValuesOf({
|
|
|
82542
82758
|
|
|
82543
82759
|
// src/services/vault-commands.service.ts
|
|
82544
82760
|
import { createHash as createHash6 } from "node:crypto";
|
|
82545
|
-
import { readFile as readFile16, rm as
|
|
82761
|
+
import { readFile as readFile16, rm as rm12 } from "node:fs/promises";
|
|
82546
82762
|
import { hostname as hostname7, tmpdir as tmpdir2 } from "node:os";
|
|
82547
82763
|
import { dirname as dirname15, join as join24 } from "node:path";
|
|
82548
82764
|
|
|
@@ -82795,13 +83011,13 @@ async function settled({
|
|
|
82795
83011
|
}) {
|
|
82796
83012
|
if (release2 === "capped") return { exitCode: 75 };
|
|
82797
83013
|
if (release2.outcome === "deny") {
|
|
82798
|
-
await
|
|
83014
|
+
await rm12(keyPath, { force: true });
|
|
82799
83015
|
context.err(`${release2.message}
|
|
82800
83016
|
`);
|
|
82801
83017
|
return { exitCode: release2.exitCode || 1 };
|
|
82802
83018
|
}
|
|
82803
83019
|
const values = await envOf({ release: release2, run: run4 });
|
|
82804
|
-
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await
|
|
83020
|
+
if (!leaseHolds({ release: release2, nowMs: context.nowMs() })) await rm12(keyPath, { force: true });
|
|
82805
83021
|
if (release2.message) context.err(`${release2.message}
|
|
82806
83022
|
`);
|
|
82807
83023
|
return { env: values };
|
|
@@ -82811,7 +83027,7 @@ function refusedRelease(error63) {
|
|
|
82811
83027
|
return {
|
|
82812
83028
|
outcome: "deny",
|
|
82813
83029
|
exitCode: 1,
|
|
82814
|
-
message: `laze vault: the release was refused: ${
|
|
83030
|
+
message: `laze vault: the release was refused: ${refusalText(error63)}`
|
|
82815
83031
|
};
|
|
82816
83032
|
}
|
|
82817
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)";
|
|
@@ -83975,8 +84191,7 @@ async function changing({
|
|
|
83975
84191
|
} catch (error63) {
|
|
83976
84192
|
const refused = error63 instanceof LazeApiError && profile.kind === "agent" && ["agent_restricted", "permission_denied", "channel_admin_required"].includes(error63.code);
|
|
83977
84193
|
if (!refused) throw error63;
|
|
83978
|
-
context.err(
|
|
83979
|
-
${AGENT_HINT}`);
|
|
84194
|
+
context.err(`${refusalLine(error63)}${AGENT_HINT}`);
|
|
83980
84195
|
return 1;
|
|
83981
84196
|
}
|
|
83982
84197
|
}
|
|
@@ -84138,8 +84353,7 @@ async function changing2({
|
|
|
84138
84353
|
} catch (error63) {
|
|
84139
84354
|
const refused = error63 instanceof LazeApiError && profile.kind === "agent" && ["agent_restricted", "permission_denied", "channel_admin_required"].includes(error63.code);
|
|
84140
84355
|
if (!refused) throw error63;
|
|
84141
|
-
context.err(
|
|
84142
|
-
${AGENT_HINT2}`);
|
|
84356
|
+
context.err(`${refusalLine(error63)}${AGENT_HINT2}`);
|
|
84143
84357
|
return 1;
|
|
84144
84358
|
}
|
|
84145
84359
|
}
|
|
@@ -84434,7 +84648,7 @@ import { basename as basename8, isAbsolute as isAbsolute2, relative as relative4
|
|
|
84434
84648
|
|
|
84435
84649
|
// src/services/file-download.service.ts
|
|
84436
84650
|
import { createWriteStream } from "node:fs";
|
|
84437
|
-
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";
|
|
84438
84652
|
import { basename as basename7, dirname as dirname17, resolve as resolve9 } from "node:path";
|
|
84439
84653
|
import { Readable, Transform } from "node:stream";
|
|
84440
84654
|
import { pipeline } from "node:stream/promises";
|
|
@@ -84559,7 +84773,7 @@ async function downloadFile({
|
|
|
84559
84773
|
await mkdir8(dirname17(part), { recursive: true });
|
|
84560
84774
|
const named = await fetchWhole({ context, client, attachmentId, part, out }).catch(
|
|
84561
84775
|
async (error63) => {
|
|
84562
|
-
await
|
|
84776
|
+
await rm13(part, { force: true });
|
|
84563
84777
|
if (!isDiskError(error63)) throw error63;
|
|
84564
84778
|
throw new CliUsageError(`Could not write ${attachmentId} to disk: ${String(error63)}`);
|
|
84565
84779
|
}
|
|
@@ -85011,7 +85225,7 @@ async function chatActions({
|
|
|
85011
85225
|
}
|
|
85012
85226
|
|
|
85013
85227
|
// src/services/claude-monitor.service.ts
|
|
85014
|
-
import { rm as
|
|
85228
|
+
import { rm as rm14 } from "node:fs/promises";
|
|
85015
85229
|
var MONITOR_IDLE_MS = 3e4;
|
|
85016
85230
|
var MONITOR_OUTRANKED_MS = 3e3;
|
|
85017
85231
|
async function deliverOnce({
|
|
@@ -85079,7 +85293,7 @@ async function monitorRound(turn) {
|
|
|
85079
85293
|
async function release({ context, profile }) {
|
|
85080
85294
|
const lock = statePathOf({ context, kind: "waiters", profile });
|
|
85081
85295
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
85082
|
-
await
|
|
85296
|
+
await rm14(lock, { force: true });
|
|
85083
85297
|
}
|
|
85084
85298
|
async function monitorHook({ context, args }) {
|
|
85085
85299
|
const claudePid = await claudePidOf({ context });
|
|
@@ -86588,7 +86802,13 @@ var whatsappChangeDefinition = external_exports.object({
|
|
|
86588
86802
|
/** Fetched with a "media" request while the store is open; absent from older connectors. */
|
|
86589
86803
|
media: whatsappChangeMediaDefinition.optional(),
|
|
86590
86804
|
/** The chat's other ids, such as the hidden id it was first seen under; new in Nov 2026. */
|
|
86591
|
-
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()
|
|
86592
86812
|
});
|
|
86593
86813
|
var whatsappReadDefinition = external_exports.object({
|
|
86594
86814
|
chat: external_exports.string().min(1).max(200),
|
|
@@ -87111,7 +87331,7 @@ var restSettleComputerCopyInputDefinition = settleComputerCopyInputDefinition.om
|
|
|
87111
87331
|
});
|
|
87112
87332
|
|
|
87113
87333
|
// src/services/computer-copy-commands.service.ts
|
|
87114
|
-
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";
|
|
87115
87335
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
87116
87336
|
import { basename as basename9, dirname as dirname18, resolve as resolve11 } from "node:path";
|
|
87117
87337
|
var COMPUTER_COPY_USAGE = ` laze computer copy <path> --agent <agent> [--to <folder>] [--json]
|
|
@@ -87212,7 +87432,7 @@ It lands before ${done.agentName}'s next turn.
|
|
|
87212
87432
|
`
|
|
87213
87433
|
);
|
|
87214
87434
|
} finally {
|
|
87215
|
-
await
|
|
87435
|
+
await rm15(dir, { recursive: true, force: true });
|
|
87216
87436
|
}
|
|
87217
87437
|
}
|
|
87218
87438
|
|
|
@@ -92596,8 +92816,7 @@ async function history2({
|
|
|
92596
92816
|
`);
|
|
92597
92817
|
} else context.out(formatHistory(output2));
|
|
92598
92818
|
if (!refused) return void 0;
|
|
92599
|
-
context.err(
|
|
92600
|
-
`);
|
|
92819
|
+
context.err(refusalLine(refused));
|
|
92601
92820
|
return 1;
|
|
92602
92821
|
}
|
|
92603
92822
|
|
|
@@ -92862,7 +93081,7 @@ async function ip({ context, args }) {
|
|
|
92862
93081
|
}
|
|
92863
93082
|
|
|
92864
93083
|
// src/services/join-commands.service.ts
|
|
92865
|
-
import { rm as
|
|
93084
|
+
import { rm as rm16 } from "node:fs/promises";
|
|
92866
93085
|
import { dirname as dirname19, join as join28 } from "node:path";
|
|
92867
93086
|
var DEFAULT_WAIT_SECONDS2 = 100;
|
|
92868
93087
|
var JOIN_USAGE = "Usage: laze join [--workspace <name|id|invite link>] [--for <email>] [--name <name>] [--note <text>] [--timeout <seconds>] [--project <folder>]";
|
|
@@ -92883,7 +93102,7 @@ async function keepPending({ context, pending: pending2 }) {
|
|
|
92883
93102
|
await writeStateJson({ path: pendingPathOf({ context }), value: pending2 });
|
|
92884
93103
|
}
|
|
92885
93104
|
async function dropPending({ context }) {
|
|
92886
|
-
await
|
|
93105
|
+
await rm16(pendingPathOf({ context }), { force: true });
|
|
92887
93106
|
}
|
|
92888
93107
|
function waitSecondsOf3({ args }) {
|
|
92889
93108
|
const raw = flagText({ args, name: "timeout" });
|
|
@@ -94021,7 +94240,7 @@ import { readdir as readdir7, readFile as readFile29 } from "node:fs/promises";
|
|
|
94021
94240
|
import { join as join29, resolve as resolve19 } from "node:path";
|
|
94022
94241
|
|
|
94023
94242
|
// src/services/mount-files.service.ts
|
|
94024
|
-
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";
|
|
94025
94244
|
import { dirname as dirname20, relative as relative5, resolve as resolve18 } from "node:path";
|
|
94026
94245
|
async function textArgument({
|
|
94027
94246
|
context,
|
|
@@ -94041,7 +94260,7 @@ async function writeMount({
|
|
|
94041
94260
|
files: files2
|
|
94042
94261
|
}) {
|
|
94043
94262
|
const root = resolve18(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
|
|
94044
|
-
await
|
|
94263
|
+
await rm17(root, { recursive: true, force: true });
|
|
94045
94264
|
await mkdir10(root, { recursive: true });
|
|
94046
94265
|
for (const file4 of files2) {
|
|
94047
94266
|
const target = resolve18(root, file4.path);
|
|
@@ -94906,7 +95125,7 @@ async function openclaw({
|
|
|
94906
95125
|
|
|
94907
95126
|
// src/services/operator-key-commands.service.ts
|
|
94908
95127
|
import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
|
|
94909
|
-
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";
|
|
94910
95129
|
import { dirname as dirname21, join as join30 } from "node:path";
|
|
94911
95130
|
|
|
94912
95131
|
// ../../modules/audit-log/contract/src/audit-log.api.ts
|
|
@@ -96344,7 +96563,7 @@ async function forgetIfOver({
|
|
|
96344
96563
|
const key = await client.post(OPERATOR_KEY_REST_PATHS.status, { keyId });
|
|
96345
96564
|
const windowOver = key.endsAt !== null && Temporal3.Instant.from(key.endsAt).epochMilliseconds <= context.nowMs();
|
|
96346
96565
|
if (key.status !== "pending" && (key.status !== "approved" || windowOver || key.spentAt)) {
|
|
96347
|
-
await
|
|
96566
|
+
await rm18(keyFile({ context, keyId }), { force: true });
|
|
96348
96567
|
}
|
|
96349
96568
|
return key;
|
|
96350
96569
|
}
|
|
@@ -96610,7 +96829,7 @@ function watchingRelease({
|
|
|
96610
96829
|
}
|
|
96611
96830
|
|
|
96612
96831
|
// src/services/rush-guard.service.ts
|
|
96613
|
-
import { rm as
|
|
96832
|
+
import { rm as rm19 } from "node:fs/promises";
|
|
96614
96833
|
var WATCH_MS3 = 2e3;
|
|
96615
96834
|
var RETRY_MS2 = 3e4;
|
|
96616
96835
|
async function guardRound(guard) {
|
|
@@ -96639,6 +96858,30 @@ async function guardRound(guard) {
|
|
|
96639
96858
|
await dropFromSpool({ context, profile: name3, messageIds: messages.map((m) => m.messageId) });
|
|
96640
96859
|
return true;
|
|
96641
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
|
+
}
|
|
96642
96885
|
function sessionIdOf({ session }) {
|
|
96643
96886
|
return session ? { sessionId: session.sessionId } : {};
|
|
96644
96887
|
}
|
|
@@ -96650,7 +96893,7 @@ async function rushWakeHook({ context, args }) {
|
|
|
96650
96893
|
if (!await claimRushGuard({ context, claudePid })) return 0;
|
|
96651
96894
|
const path = guardPathOf({ context, claudePid });
|
|
96652
96895
|
try {
|
|
96653
|
-
while (context
|
|
96896
|
+
while (await noteProcessRuns({ context, pid: claudePid })) await context.sleep(WATCH_MS3);
|
|
96654
96897
|
const { client, name: name3 } = await signedIn({ context, args });
|
|
96655
96898
|
const noted = statePathOf({ context, kind: "sessions", profile: String(claudePid) });
|
|
96656
96899
|
const note = await readStateJson({ path: noted });
|
|
@@ -96659,30 +96902,14 @@ async function rushWakeHook({ context, args }) {
|
|
|
96659
96902
|
const rush = { id: id4, program };
|
|
96660
96903
|
const known = note ? session : void 0;
|
|
96661
96904
|
const guard = { context, client, name: name3, lock, claudePid, session: known, rush, launch };
|
|
96662
|
-
const deadline = context.nowMs() + WAIT_HOOK_TIMEOUT_SECONDS * 1e3;
|
|
96663
96905
|
try {
|
|
96664
|
-
|
|
96665
|
-
const done = await guardRound(guard).catch((error63) => {
|
|
96666
|
-
const migrated = migratedNoticeOf(error63);
|
|
96667
|
-
if (migrated) {
|
|
96668
|
-
context.err(`${migrated.notice}
|
|
96669
|
-
`);
|
|
96670
|
-
return true;
|
|
96671
|
-
}
|
|
96672
|
-
context.err(`laze: the rush guard will try again: ${String(error63)}
|
|
96673
|
-
`);
|
|
96674
|
-
return "failed";
|
|
96675
|
-
});
|
|
96676
|
-
if (done === true) return 0;
|
|
96677
|
-
await context.sleep(done === "failed" ? RETRY_MS2 : 1e3);
|
|
96678
|
-
}
|
|
96679
|
-
return 0;
|
|
96906
|
+
return await guardRounds(guard);
|
|
96680
96907
|
} finally {
|
|
96681
96908
|
if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
|
|
96682
|
-
await
|
|
96909
|
+
await rm19(lock, { force: true });
|
|
96683
96910
|
}
|
|
96684
96911
|
} finally {
|
|
96685
|
-
await
|
|
96912
|
+
await rm19(path, { force: true });
|
|
96686
96913
|
}
|
|
96687
96914
|
}
|
|
96688
96915
|
|
|
@@ -97875,7 +98102,7 @@ function credentialProcessJson(fields) {
|
|
|
97875
98102
|
}
|
|
97876
98103
|
|
|
97877
98104
|
// src/services/vault-batch.service.ts
|
|
97878
|
-
import { rm as
|
|
98105
|
+
import { rm as rm20 } from "node:fs/promises";
|
|
97879
98106
|
async function batchOf({ response }) {
|
|
97880
98107
|
const text3 = await response.text();
|
|
97881
98108
|
if (!response.ok) {
|
|
@@ -97942,9 +98169,7 @@ async function doorOf({
|
|
|
97942
98169
|
return await client.post(door.ask, { ...body, ...door.extra });
|
|
97943
98170
|
} catch (error63) {
|
|
97944
98171
|
if (!(error63 instanceof LazeApiError)) throw error63;
|
|
97945
|
-
throw new CliUsageError(
|
|
97946
|
-
`laze vault: the batch was refused: ${error63.message} (${error63.code})`
|
|
97947
|
-
);
|
|
98172
|
+
throw new CliUsageError(`laze vault: the batch was refused: ${refusalText(error63)}`);
|
|
97948
98173
|
}
|
|
97949
98174
|
},
|
|
97950
98175
|
status: (requestId) => client.post(door.status, { requestId, ...door.extra }).catch(refusedRelease)
|
|
@@ -98057,7 +98282,7 @@ async function valuesOf({
|
|
|
98057
98282
|
}) {
|
|
98058
98283
|
const refused = refusalOf({ context, settled: settled2 });
|
|
98059
98284
|
if (refused !== 0) {
|
|
98060
|
-
await
|
|
98285
|
+
await rm20(keyPath, { force: true });
|
|
98061
98286
|
return { exitCode: refused };
|
|
98062
98287
|
}
|
|
98063
98288
|
const opened = /* @__PURE__ */ new Map();
|
|
@@ -98069,7 +98294,7 @@ async function valuesOf({
|
|
|
98069
98294
|
if (release2.message) context.err(`${release2.message}
|
|
98070
98295
|
`);
|
|
98071
98296
|
}
|
|
98072
|
-
if (!keep2) await
|
|
98297
|
+
if (!keep2) await rm20(keyPath, { force: true });
|
|
98073
98298
|
const released = /* @__PURE__ */ new Map();
|
|
98074
98299
|
for (const entry of entries) {
|
|
98075
98300
|
const fields = opened.get(keyOf(entry));
|
|
@@ -100023,8 +100248,7 @@ function exitCodeOf({ context, error: error63 }) {
|
|
|
100023
100248
|
`);
|
|
100024
100249
|
else if (error63 instanceof CliUsageError) context.err(`${error63.message}
|
|
100025
100250
|
`);
|
|
100026
|
-
else if (error63 instanceof LazeApiError) context.err(
|
|
100027
|
-
`);
|
|
100251
|
+
else if (error63 instanceof LazeApiError) context.err(refusalLine(error63));
|
|
100028
100252
|
else {
|
|
100029
100253
|
const unreachable = unreachableReasonOf(error63);
|
|
100030
100254
|
if (unreachable === void 0) throw error63;
|
|
@@ -100043,7 +100267,7 @@ import {
|
|
|
100043
100267
|
randomBytes as randomBytes5,
|
|
100044
100268
|
sign
|
|
100045
100269
|
} from "node:crypto";
|
|
100046
|
-
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";
|
|
100047
100271
|
import { dirname as dirname24, join as join34 } from "node:path";
|
|
100048
100272
|
var KEYCHAIN_SERVICE = "laze-cli-machine-key";
|
|
100049
100273
|
var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve26, reject) => {
|
|
@@ -100155,7 +100379,7 @@ var MachineKeyStore = class _MachineKeyStore {
|
|
|
100155
100379
|
return kept;
|
|
100156
100380
|
}
|
|
100157
100381
|
async drop({ tier, jwk }) {
|
|
100158
|
-
if (tier === "file") return
|
|
100382
|
+
if (tier === "file") return rm21(this.pemPathOf(jwk), { force: true });
|
|
100159
100383
|
await this.options.run({
|
|
100160
100384
|
program: "security",
|
|
100161
100385
|
args: ["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", this.accountOf(jwk)],
|
|
@@ -100211,7 +100435,7 @@ async function writeOnce({ path, text: text3 }) {
|
|
|
100211
100435
|
if (error63.code === "EEXIST") return false;
|
|
100212
100436
|
throw error63;
|
|
100213
100437
|
} finally {
|
|
100214
|
-
await
|
|
100438
|
+
await rm21(temporary, { force: true });
|
|
100215
100439
|
}
|
|
100216
100440
|
}
|
|
100217
100441
|
async function writePrivate({ path, text: text3 }) {
|
|
@@ -100272,7 +100496,7 @@ function machineProofFetch({
|
|
|
100272
100496
|
|
|
100273
100497
|
// src/services/processes.service.ts
|
|
100274
100498
|
import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
|
|
100275
|
-
import { closeSync, mkdirSync, openSync } from "node:fs";
|
|
100499
|
+
import { closeSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
|
|
100276
100500
|
import { readFile as readFile37, readlink } from "node:fs/promises";
|
|
100277
100501
|
import { dirname as dirname25 } from "node:path";
|
|
100278
100502
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -100301,6 +100525,13 @@ async function parentOf(pid) {
|
|
|
100301
100525
|
const parent = Number(listed?.stdout.trim());
|
|
100302
100526
|
return parent > 0 ? parent : void 0;
|
|
100303
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
|
+
}
|
|
100304
100535
|
async function cwdOf(pid) {
|
|
100305
100536
|
const linked = await readlink(`/proc/${pid}/cwd`).catch(() => void 0);
|
|
100306
100537
|
if (linked) return linked;
|
|
@@ -100325,12 +100556,18 @@ function spawnOrphan({ argv, log }) {
|
|
|
100325
100556
|
});
|
|
100326
100557
|
return Number(shell.stdout.trim()) || 0;
|
|
100327
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
|
+
}
|
|
100328
100564
|
function spawnDetached({
|
|
100329
100565
|
argv,
|
|
100330
100566
|
logPath,
|
|
100331
100567
|
orphan = false
|
|
100332
100568
|
}) {
|
|
100333
100569
|
mkdirSync(dirname25(logPath), { recursive: true, mode: 448 });
|
|
100570
|
+
keepLogSmall({ logPath });
|
|
100334
100571
|
const log = openSync(logPath, "a", 384);
|
|
100335
100572
|
if (orphan) {
|
|
100336
100573
|
try {
|
|
@@ -100354,7 +100591,7 @@ function stop2(pid) {
|
|
|
100354
100591
|
return true;
|
|
100355
100592
|
}
|
|
100356
100593
|
function nodeProcesses() {
|
|
100357
|
-
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 };
|
|
100358
100595
|
}
|
|
100359
100596
|
|
|
100360
100597
|
// src/services/proxied-fetch.service.ts
|