@alook/daemon 0.1.73 → 0.1.75
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/THIRD_PARTY_NOTICES.md +207 -0
- package/dist/cli/index.js +2788 -568
- package/dist/index.js +776 -150
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24158,6 +24158,55 @@ async function killProcessTree(pid, opts) {
|
|
|
24158
24158
|
import { createRequire as createRequire2 } from "node:module";
|
|
24159
24159
|
import { homedir as homedir2 } from "node:os";
|
|
24160
24160
|
import { join as join4, resolve } from "node:path";
|
|
24161
|
+
var MAX_CHILD_PROGRESS_ROWS = 64;
|
|
24162
|
+
function parseAgyVersion(version) {
|
|
24163
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec(version.trim());
|
|
24164
|
+
if (!match)
|
|
24165
|
+
return null;
|
|
24166
|
+
const major = Number(match[1]);
|
|
24167
|
+
const minor = Number(match[2]);
|
|
24168
|
+
const patch = Number(match[3]);
|
|
24169
|
+
if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) {
|
|
24170
|
+
return null;
|
|
24171
|
+
}
|
|
24172
|
+
return [major, minor, patch];
|
|
24173
|
+
}
|
|
24174
|
+
function compareSemver(a, b) {
|
|
24175
|
+
for (let index = 0;index < 3; index += 1) {
|
|
24176
|
+
if (a[index] !== b[index])
|
|
24177
|
+
return a[index] - b[index];
|
|
24178
|
+
}
|
|
24179
|
+
return 0;
|
|
24180
|
+
}
|
|
24181
|
+
function isAgyVersionAtLeast(version, min, maxMajorExclusive) {
|
|
24182
|
+
const parsed = parseAgyVersion(version);
|
|
24183
|
+
if (!parsed)
|
|
24184
|
+
return false;
|
|
24185
|
+
if (maxMajorExclusive !== undefined && parsed[0] >= maxMajorExclusive)
|
|
24186
|
+
return false;
|
|
24187
|
+
return compareSemver(parsed, min) >= 0;
|
|
24188
|
+
}
|
|
24189
|
+
function resolveAgyUsageProfile(version) {
|
|
24190
|
+
const parsed = parseAgyVersion(version);
|
|
24191
|
+
if (!parsed || parsed[0] >= 2)
|
|
24192
|
+
return;
|
|
24193
|
+
if (compareSemver(parsed, [1, 5, 9]) >= 0) {
|
|
24194
|
+
return { inputIncludesCache: false, outputIncludesReasoning: true };
|
|
24195
|
+
}
|
|
24196
|
+
if (compareSemver(parsed, [1, 4, 12]) >= 0) {
|
|
24197
|
+
return { inputIncludesCache: true, outputIncludesReasoning: false };
|
|
24198
|
+
}
|
|
24199
|
+
return;
|
|
24200
|
+
}
|
|
24201
|
+
function readConversationSummaryColumns(db) {
|
|
24202
|
+
const rows = db.prepare("PRAGMA table_info(conversation_summaries)").all();
|
|
24203
|
+
const columns = new Set;
|
|
24204
|
+
for (const row of rows) {
|
|
24205
|
+
if (typeof row?.name === "string")
|
|
24206
|
+
columns.add(row.name);
|
|
24207
|
+
}
|
|
24208
|
+
return columns;
|
|
24209
|
+
}
|
|
24161
24210
|
function agyStateHome(env, cwd) {
|
|
24162
24211
|
const home = env.HOME || env.USERPROFILE || homedir2();
|
|
24163
24212
|
return resolve(cwd, env.GEMINI_HOME?.trim().replace(/^~(?=[/\\]|$)/, home) || join4(home, ".gemini"));
|
|
@@ -24307,10 +24356,14 @@ class NativeSessionActivityReader {
|
|
|
24307
24356
|
this.path = join4(home, "antigravity-cli", "conversation_summaries.db");
|
|
24308
24357
|
}
|
|
24309
24358
|
async activity() {
|
|
24310
|
-
if (this.version
|
|
24359
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
24311
24360
|
return "unknown";
|
|
24312
24361
|
const db = await this.openDatabase(this.path);
|
|
24313
24362
|
try {
|
|
24363
|
+
const columns = readConversationSummaryColumns(db);
|
|
24364
|
+
if (!columns.has("conversation_id") || !columns.has("status") || !columns.has("not_fully_idle")) {
|
|
24365
|
+
return "unknown";
|
|
24366
|
+
}
|
|
24314
24367
|
const rows = db.prepare("SELECT status,not_fully_idle FROM conversation_summaries WHERE conversation_id = ? LIMIT 1").all(this.sessionId);
|
|
24315
24368
|
const row = rows[0];
|
|
24316
24369
|
if (!row || row.not_fully_idle !== 0 && row.not_fully_idle !== 1)
|
|
@@ -24322,6 +24375,40 @@ class NativeSessionActivityReader {
|
|
|
24322
24375
|
db.close();
|
|
24323
24376
|
}
|
|
24324
24377
|
}
|
|
24378
|
+
async childProgress() {
|
|
24379
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
24380
|
+
return null;
|
|
24381
|
+
let db;
|
|
24382
|
+
try {
|
|
24383
|
+
db = await this.openDatabase(this.path);
|
|
24384
|
+
} catch {
|
|
24385
|
+
return null;
|
|
24386
|
+
}
|
|
24387
|
+
try {
|
|
24388
|
+
const columns = readConversationSummaryColumns(db);
|
|
24389
|
+
if (!columns.has("conversation_id") || !columns.has("parent_conversation_id") || !columns.has("step_count") || !columns.has("last_modified_time")) {
|
|
24390
|
+
return null;
|
|
24391
|
+
}
|
|
24392
|
+
const rows = db.prepare(`SELECT conversation_id,step_count,last_modified_time FROM conversation_summaries WHERE parent_conversation_id = ? ORDER BY last_modified_time DESC LIMIT ${MAX_CHILD_PROGRESS_ROWS}`).all(this.sessionId);
|
|
24393
|
+
const children = [];
|
|
24394
|
+
for (const row of rows) {
|
|
24395
|
+
if (typeof row?.conversation_id !== "string" || !row.conversation_id)
|
|
24396
|
+
continue;
|
|
24397
|
+
const stepCount = typeof row.step_count === "number" && Number.isSafeInteger(row.step_count) && row.step_count >= 0 ? row.step_count : 0;
|
|
24398
|
+
const lastModifiedTime = typeof row.last_modified_time === "string" ? row.last_modified_time : typeof row.last_modified_time === "number" && Number.isFinite(row.last_modified_time) ? String(row.last_modified_time) : "";
|
|
24399
|
+
children.push({
|
|
24400
|
+
conversationId: row.conversation_id,
|
|
24401
|
+
stepCount,
|
|
24402
|
+
lastModifiedTime
|
|
24403
|
+
});
|
|
24404
|
+
}
|
|
24405
|
+
return children;
|
|
24406
|
+
} catch {
|
|
24407
|
+
return null;
|
|
24408
|
+
} finally {
|
|
24409
|
+
db.close();
|
|
24410
|
+
}
|
|
24411
|
+
}
|
|
24325
24412
|
}
|
|
24326
24413
|
|
|
24327
24414
|
// agent-driver/dist/internal/model-observation.js
|
|
@@ -24533,6 +24620,28 @@ function isMissingSessionError(error) {
|
|
|
24533
24620
|
const message = error instanceof Error ? error.message : String(error);
|
|
24534
24621
|
return /\bsession\b.*\b(not found|missing|unknown|invalid)\b/i.test(message) || /\b(not found|missing|unknown|invalid)\b.*\bsession\b/i.test(message);
|
|
24535
24622
|
}
|
|
24623
|
+
function timestampAdvanced(previous, next) {
|
|
24624
|
+
if (!next || next === previous)
|
|
24625
|
+
return false;
|
|
24626
|
+
if (!previous)
|
|
24627
|
+
return true;
|
|
24628
|
+
const previousMs = Date.parse(previous);
|
|
24629
|
+
const nextMs = Date.parse(next);
|
|
24630
|
+
if (Number.isFinite(previousMs) && Number.isFinite(nextMs)) {
|
|
24631
|
+
return nextMs > previousMs || nextMs === previousMs && next > previous;
|
|
24632
|
+
}
|
|
24633
|
+
return next > previous;
|
|
24634
|
+
}
|
|
24635
|
+
function toChildProgressMap(children) {
|
|
24636
|
+
const map = new Map;
|
|
24637
|
+
for (const child of children) {
|
|
24638
|
+
map.set(child.conversationId, {
|
|
24639
|
+
stepCount: child.stepCount,
|
|
24640
|
+
lastModifiedTime: child.lastModifiedTime
|
|
24641
|
+
});
|
|
24642
|
+
}
|
|
24643
|
+
return map;
|
|
24644
|
+
}
|
|
24536
24645
|
|
|
24537
24646
|
class AgyAcpLane {
|
|
24538
24647
|
factory;
|
|
@@ -24549,6 +24658,8 @@ class AgyAcpLane {
|
|
|
24549
24658
|
nativeActivity = "unknown";
|
|
24550
24659
|
publishedActivity;
|
|
24551
24660
|
activityRevision = 0;
|
|
24661
|
+
childProgressBaseline = null;
|
|
24662
|
+
resumedSession = false;
|
|
24552
24663
|
nativeVersion = "";
|
|
24553
24664
|
contentOwner;
|
|
24554
24665
|
executionIsolated = true;
|
|
@@ -24598,6 +24709,7 @@ class AgyAcpLane {
|
|
|
24598
24709
|
return { ok: false, reason: "runtime_error", error: "Agy ACP session already started" };
|
|
24599
24710
|
}
|
|
24600
24711
|
this.started = true;
|
|
24712
|
+
this.resumedSession = Boolean(input.sessionId ?? this.ctx.config.sessionId);
|
|
24601
24713
|
const launchCtx = {
|
|
24602
24714
|
...this.ctx,
|
|
24603
24715
|
prompt: input.text,
|
|
@@ -24628,7 +24740,7 @@ class AgyAcpLane {
|
|
|
24628
24740
|
const sessionId = this.sessionId;
|
|
24629
24741
|
if (!sessionId)
|
|
24630
24742
|
throw new Error("Agy ACP handshake completed without a session id");
|
|
24631
|
-
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, this.nativeVersion
|
|
24743
|
+
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, isAgyVersionAtLeast(this.nativeVersion, [1, 5, 16], 2));
|
|
24632
24744
|
this.processActivated = true;
|
|
24633
24745
|
this.ready = true;
|
|
24634
24746
|
this.events.emit("runtime_event", { kind: "session_init", sessionId, acquisition: { status: input.sessionId ? "resumed" : "created", evidence: "native_api" } });
|
|
@@ -24680,6 +24792,7 @@ class AgyAcpLane {
|
|
|
24680
24792
|
this.requestedStopReason ??= input.reason ?? "requested_stop";
|
|
24681
24793
|
this.ready = false;
|
|
24682
24794
|
this.clearActivityTimer();
|
|
24795
|
+
this.childProgressBaseline = null;
|
|
24683
24796
|
this.currentPromptRequestId = null;
|
|
24684
24797
|
this.terminalOwner = null;
|
|
24685
24798
|
this.toolCalls.clear();
|
|
@@ -24738,7 +24851,7 @@ class AgyAcpLane {
|
|
|
24738
24851
|
}
|
|
24739
24852
|
const version = record2(initialize.agentInfo)?.version;
|
|
24740
24853
|
this.nativeVersion = typeof version === "string" ? version : "";
|
|
24741
|
-
this.usageProfile = version === "
|
|
24854
|
+
this.usageProfile = typeof version === "string" ? resolveAgyUsageProfile(version) : undefined;
|
|
24742
24855
|
if (!record2(record2(initialize.agentCapabilities)?.sessionCapabilities)?.resume) {
|
|
24743
24856
|
throw new AgyAcpIncompatibleError("Antigravity CLI ACP does not support native session resume");
|
|
24744
24857
|
}
|
|
@@ -24943,6 +25056,11 @@ class AgyAcpLane {
|
|
|
24943
25056
|
const checkpoint = await read;
|
|
24944
25057
|
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
24945
25058
|
return { ok: false, reason: "closed" };
|
|
25059
|
+
const childBaseline = await this.readChildProgress();
|
|
25060
|
+
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
25061
|
+
return { ok: false, reason: "closed" };
|
|
25062
|
+
if (childBaseline)
|
|
25063
|
+
this.childProgressBaseline = toChildProgressMap(childBaseline);
|
|
24946
25064
|
this.executionCheckpoint = checkpoint;
|
|
24947
25065
|
this.executionIsolated = !this.unownedContent && !this.hasPendingTools();
|
|
24948
25066
|
return this.admitPrompt(text, "prompt", inputs);
|
|
@@ -25476,6 +25594,51 @@ class AgyAcpLane {
|
|
|
25476
25594
|
this.nativeActivity = "unknown";
|
|
25477
25595
|
this.publishActivity();
|
|
25478
25596
|
}
|
|
25597
|
+
async readChildProgress() {
|
|
25598
|
+
if (!this.activityReader?.childProgress)
|
|
25599
|
+
return null;
|
|
25600
|
+
try {
|
|
25601
|
+
return await this.activityReader.childProgress();
|
|
25602
|
+
} catch {
|
|
25603
|
+
return null;
|
|
25604
|
+
}
|
|
25605
|
+
}
|
|
25606
|
+
observeChildProgress(children) {
|
|
25607
|
+
if (!children || this.currentPromptRequestId === null || this.terminalOwner === null)
|
|
25608
|
+
return;
|
|
25609
|
+
if (this.childProgressBaseline === null) {
|
|
25610
|
+
this.childProgressBaseline = toChildProgressMap(children);
|
|
25611
|
+
if (!this.resumedSession && children.length > 0) {
|
|
25612
|
+
this.events.emit("runtime_event", {
|
|
25613
|
+
kind: "internal_progress",
|
|
25614
|
+
source: "agy.native",
|
|
25615
|
+
itemType: "subagent_progress"
|
|
25616
|
+
});
|
|
25617
|
+
}
|
|
25618
|
+
return;
|
|
25619
|
+
}
|
|
25620
|
+
let advanced = false;
|
|
25621
|
+
for (const child of children) {
|
|
25622
|
+
const previous = this.childProgressBaseline.get(child.conversationId);
|
|
25623
|
+
if (!previous || child.stepCount > previous.stepCount || timestampAdvanced(previous.lastModifiedTime, child.lastModifiedTime)) {
|
|
25624
|
+
advanced = true;
|
|
25625
|
+
}
|
|
25626
|
+
this.childProgressBaseline.set(child.conversationId, {
|
|
25627
|
+
stepCount: Math.max(previous?.stepCount ?? 0, child.stepCount),
|
|
25628
|
+
lastModifiedTime: previous && !timestampAdvanced(previous.lastModifiedTime, child.lastModifiedTime) ? previous.lastModifiedTime : child.lastModifiedTime
|
|
25629
|
+
});
|
|
25630
|
+
}
|
|
25631
|
+
while (this.childProgressBaseline.size > 256) {
|
|
25632
|
+
this.childProgressBaseline.delete(this.childProgressBaseline.keys().next().value);
|
|
25633
|
+
}
|
|
25634
|
+
if (advanced) {
|
|
25635
|
+
this.events.emit("runtime_event", {
|
|
25636
|
+
kind: "internal_progress",
|
|
25637
|
+
source: "agy.native",
|
|
25638
|
+
itemType: "subagent_progress"
|
|
25639
|
+
});
|
|
25640
|
+
}
|
|
25641
|
+
}
|
|
25479
25642
|
refreshActivity() {
|
|
25480
25643
|
if (this.activityRead)
|
|
25481
25644
|
return this.activityRead;
|
|
@@ -25494,6 +25657,12 @@ class AgyAcpLane {
|
|
|
25494
25657
|
if (status === "running" && this.currentPromptRequestId === null)
|
|
25495
25658
|
this.unownedContent = true;
|
|
25496
25659
|
this.publishActivity();
|
|
25660
|
+
if (this.currentPromptRequestId !== null && this.terminalOwner !== null) {
|
|
25661
|
+
const children = await this.readChildProgress();
|
|
25662
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25663
|
+
return;
|
|
25664
|
+
this.observeChildProgress(children);
|
|
25665
|
+
}
|
|
25497
25666
|
})();
|
|
25498
25667
|
this.activityRead = reading;
|
|
25499
25668
|
reading.finally(() => {
|
|
@@ -35439,6 +35608,11 @@ function assertInstructionFileName(name) {
|
|
|
35439
35608
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
35440
35609
|
var SEMANTIC_ASSEMBLER_MAX_BYTES = 1048576;
|
|
35441
35610
|
var WORK_HEARTBEAT_MIN_INTERVAL_MS = 1000;
|
|
35611
|
+
var QUEUED_BATCH_MAX_BYTES = 64 * 1024;
|
|
35612
|
+
var QUEUED_BATCH_SEPARATOR = `
|
|
35613
|
+
|
|
35614
|
+
`;
|
|
35615
|
+
var QUEUED_BATCH_SEPARATOR_BYTES = Buffer.byteLength(QUEUED_BATCH_SEPARATOR, "utf8");
|
|
35442
35616
|
function emptySemanticAssembler() {
|
|
35443
35617
|
return { chunks: [], bytes: 0, truncated: false };
|
|
35444
35618
|
}
|
|
@@ -35560,6 +35734,8 @@ class LogicalAgentSession {
|
|
|
35560
35734
|
compacting = false;
|
|
35561
35735
|
reviewing = false;
|
|
35562
35736
|
steeringDeliveries = new Set;
|
|
35737
|
+
pendingSteers = [];
|
|
35738
|
+
pendingSteerFlushTurn;
|
|
35563
35739
|
laneAdmissionTail = Promise.resolve();
|
|
35564
35740
|
laneAdmissionPending = 0;
|
|
35565
35741
|
toolBoundaryOpen = true;
|
|
@@ -36416,30 +36592,57 @@ class LogicalAgentSession {
|
|
|
36416
36592
|
canFlushSafeBoundaryQueue() {
|
|
36417
36593
|
return this.state === "working" && this.behavior.midTurnDelivery === "safe_boundary_queue" && this.toolBoundaryOpen && !this.toolBoundaryFlushDisabled && !this.compacting && !this.reviewing && this.activeTurn !== undefined && this.lane !== null && this.queued.length > 0 && this.queued[0].message.delivery !== "next_turn";
|
|
36418
36594
|
}
|
|
36595
|
+
takeBatch(queue, getMessage, opts = {}) {
|
|
36596
|
+
const batch = [];
|
|
36597
|
+
let totalBytes = 0;
|
|
36598
|
+
while (queue.length > 0) {
|
|
36599
|
+
const next = queue[0];
|
|
36600
|
+
if (opts.predicate && !opts.predicate(next))
|
|
36601
|
+
break;
|
|
36602
|
+
const message = getMessage(next);
|
|
36603
|
+
if (opts.stopAtNextTurn && message.delivery === "next_turn")
|
|
36604
|
+
break;
|
|
36605
|
+
const nextBytes = Buffer.byteLength(message.text, "utf8");
|
|
36606
|
+
const projected = batch.length === 0 ? nextBytes : totalBytes + QUEUED_BATCH_SEPARATOR_BYTES + nextBytes;
|
|
36607
|
+
if (batch.length > 0 && projected > QUEUED_BATCH_MAX_BYTES)
|
|
36608
|
+
break;
|
|
36609
|
+
queue.shift();
|
|
36610
|
+
batch.push(next);
|
|
36611
|
+
totalBytes = projected;
|
|
36612
|
+
}
|
|
36613
|
+
return batch;
|
|
36614
|
+
}
|
|
36419
36615
|
async drainSafeBoundaryQueue() {
|
|
36420
36616
|
while (this.canFlushSafeBoundaryQueue()) {
|
|
36421
|
-
const
|
|
36617
|
+
const items = this.takeBatch(this.queued, (entry) => entry.message, { stopAtNextTurn: true });
|
|
36618
|
+
if (items.length === 0)
|
|
36619
|
+
return;
|
|
36422
36620
|
const activeTurn = this.activeTurn;
|
|
36423
|
-
const delivery = {
|
|
36621
|
+
const delivery = { items, activeTurn, finalized: false };
|
|
36424
36622
|
this.safeBoundaryDelivery = delivery;
|
|
36623
|
+
const messages = items.map((item) => item.message);
|
|
36624
|
+
const text = messages.map((message) => message.text).join(QUEUED_BATCH_SEPARATOR);
|
|
36425
36625
|
try {
|
|
36426
|
-
await this.sendLane(
|
|
36626
|
+
await this.sendLane(text, "busy", messages);
|
|
36427
36627
|
} catch (error) {
|
|
36428
36628
|
if (error instanceof StructuredLaneAdmissionError && error.code === "runtime_busy") {
|
|
36429
|
-
this.queued.unshift(
|
|
36629
|
+
this.queued.unshift(...items);
|
|
36430
36630
|
this.toolBoundaryFlushDisabled = true;
|
|
36431
36631
|
return;
|
|
36432
36632
|
}
|
|
36433
36633
|
if (!delivery.finalized) {
|
|
36434
|
-
this.recordQueueDwell(item);
|
|
36435
36634
|
delivery.finalized = true;
|
|
36436
|
-
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36635
|
+
const failure = driverError("process", "delivery_failed", String(error), true);
|
|
36636
|
+
for (const item of items) {
|
|
36637
|
+
this.recordQueueDwell(item);
|
|
36638
|
+
this.emit({
|
|
36639
|
+
type: "command_failed",
|
|
36640
|
+
scope: "input",
|
|
36641
|
+
commandId: item.message.id,
|
|
36642
|
+
turnId: activeTurn.turnId,
|
|
36643
|
+
error: failure
|
|
36644
|
+
});
|
|
36645
|
+
}
|
|
36443
36646
|
}
|
|
36444
36647
|
continue;
|
|
36445
36648
|
} finally {
|
|
@@ -36448,15 +36651,17 @@ class LogicalAgentSession {
|
|
|
36448
36651
|
}
|
|
36449
36652
|
if (delivery.finalized)
|
|
36450
36653
|
continue;
|
|
36451
|
-
this.recordQueueDwell(item);
|
|
36452
36654
|
delivery.finalized = true;
|
|
36453
|
-
|
|
36454
|
-
|
|
36455
|
-
|
|
36456
|
-
|
|
36457
|
-
|
|
36458
|
-
|
|
36459
|
-
|
|
36655
|
+
for (const item of items) {
|
|
36656
|
+
this.recordQueueDwell(item);
|
|
36657
|
+
activeTurn.commandIds.push(item.message.id);
|
|
36658
|
+
this.emit({
|
|
36659
|
+
type: "command_accepted",
|
|
36660
|
+
commandId: item.message.id,
|
|
36661
|
+
turnId: activeTurn.turnId,
|
|
36662
|
+
delivery: "steer"
|
|
36663
|
+
});
|
|
36664
|
+
}
|
|
36460
36665
|
}
|
|
36461
36666
|
}
|
|
36462
36667
|
failSafeBoundaryDelivery(category, code, message) {
|
|
@@ -36464,13 +36669,16 @@ class LogicalAgentSession {
|
|
|
36464
36669
|
if (!delivery || delivery.finalized)
|
|
36465
36670
|
return;
|
|
36466
36671
|
delivery.finalized = true;
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
|
|
36470
|
-
|
|
36471
|
-
|
|
36472
|
-
|
|
36473
|
-
|
|
36672
|
+
const error = driverError(category, code, message);
|
|
36673
|
+
for (const item of delivery.items) {
|
|
36674
|
+
this.emit({
|
|
36675
|
+
type: "command_failed",
|
|
36676
|
+
scope: "input",
|
|
36677
|
+
commandId: item.message.id,
|
|
36678
|
+
turnId: delivery.activeTurn.turnId,
|
|
36679
|
+
error
|
|
36680
|
+
});
|
|
36681
|
+
}
|
|
36474
36682
|
}
|
|
36475
36683
|
failTurnAdmission(category, code, message) {
|
|
36476
36684
|
this.failTurnAdmissionWithError(driverError(category, code, message));
|
|
@@ -36527,9 +36735,12 @@ class LogicalAgentSession {
|
|
|
36527
36735
|
async startNextQueued() {
|
|
36528
36736
|
if (this.state !== "idle" || this.queued.length === 0 || this.processTurnEnded || this.retiringLane)
|
|
36529
36737
|
return;
|
|
36530
|
-
const
|
|
36531
|
-
|
|
36532
|
-
|
|
36738
|
+
const items = this.takeBatch(this.queued, (entry) => entry.message);
|
|
36739
|
+
if (items.length === 0)
|
|
36740
|
+
return;
|
|
36741
|
+
for (const item of items)
|
|
36742
|
+
this.recordQueueDwell(item);
|
|
36743
|
+
await this.startTurn(items.map((item) => item.message), "prompt");
|
|
36533
36744
|
}
|
|
36534
36745
|
onLaneError(error, physicalOwner, generation) {
|
|
36535
36746
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -36718,6 +36929,10 @@ class LogicalAgentSession {
|
|
|
36718
36929
|
return reserved;
|
|
36719
36930
|
}
|
|
36720
36931
|
async deliverSteer(message, activeTurn) {
|
|
36932
|
+
let resolveReceipt;
|
|
36933
|
+
const settled = new Promise((resolve6) => {
|
|
36934
|
+
resolveReceipt = resolve6;
|
|
36935
|
+
});
|
|
36721
36936
|
let rejectCancellation;
|
|
36722
36937
|
const cancellation = new Promise((_resolve, reject) => {
|
|
36723
36938
|
rejectCancellation = reject;
|
|
@@ -36726,40 +36941,17 @@ class LogicalAgentSession {
|
|
|
36726
36941
|
message,
|
|
36727
36942
|
activeTurn,
|
|
36728
36943
|
finalized: false,
|
|
36944
|
+
resolve: resolveReceipt,
|
|
36729
36945
|
cancellation,
|
|
36730
36946
|
cancel(error) {
|
|
36731
36947
|
rejectCancellation(error);
|
|
36732
36948
|
}
|
|
36733
36949
|
};
|
|
36734
36950
|
this.steeringDeliveries.add(delivery);
|
|
36735
|
-
|
|
36736
|
-
|
|
36737
|
-
if (delivery.finalized || this.activeTurn !== activeTurn) {
|
|
36738
|
-
throw delivery.failure ?? driverError("cancelled", "turn_closed_before_command_acceptance", "Turn closed before command acceptance");
|
|
36739
|
-
}
|
|
36740
|
-
await this.sendLane(message.text, "busy", [message]);
|
|
36741
|
-
if (delivery.finalized || this.activeTurn !== activeTurn) {
|
|
36742
|
-
throw delivery.failure ?? driverError("cancelled", "turn_closed_before_command_acceptance", "Turn closed before command acceptance");
|
|
36743
|
-
}
|
|
36744
|
-
delivery.finalized = true;
|
|
36745
|
-
activeTurn.commandIds.push(message.id);
|
|
36746
|
-
this.emit({ type: "command_accepted", commandId: message.id, turnId: activeTurn.turnId, delivery: "steer" });
|
|
36747
|
-
return { status: "accepted", delivery: "steer", commandId: message.id, turnId: activeTurn.turnId };
|
|
36748
|
-
} catch (error) {
|
|
36749
|
-
if (!delivery.finalized && this.activeTurn === activeTurn && error instanceof StructuredLaneAdmissionError && error.code === "runtime_busy") {
|
|
36750
|
-
delivery.finalized = true;
|
|
36751
|
-
return this.queue(message, "runtime_busy");
|
|
36752
|
-
}
|
|
36753
|
-
const failure = delivery.failure ?? (typeof error === "object" && error !== null && "category" in error ? error : driverError("process", "delivery_failed", String(error), true));
|
|
36754
|
-
if (!delivery.finalized) {
|
|
36755
|
-
delivery.finalized = true;
|
|
36756
|
-
this.emit({ type: "command_failed", scope: "input", commandId: message.id, turnId: activeTurn.turnId, error: failure });
|
|
36757
|
-
}
|
|
36758
|
-
return { status: "rejected", reason: "runtime_unavailable", error: failure };
|
|
36759
|
-
}
|
|
36760
|
-
});
|
|
36951
|
+
this.pendingSteers.push(delivery);
|
|
36952
|
+
this.scheduleSteerFlush(activeTurn);
|
|
36761
36953
|
try {
|
|
36762
|
-
return await Promise.race([
|
|
36954
|
+
return await Promise.race([settled, cancellation]);
|
|
36763
36955
|
} catch (error) {
|
|
36764
36956
|
const failure = delivery.failure ?? (typeof error === "object" && error !== null && "category" in error ? error : driverError("process", "delivery_failed", String(error), true));
|
|
36765
36957
|
if (!delivery.finalized) {
|
|
@@ -36771,6 +36963,71 @@ class LogicalAgentSession {
|
|
|
36771
36963
|
this.steeringDeliveries.delete(delivery);
|
|
36772
36964
|
}
|
|
36773
36965
|
}
|
|
36966
|
+
scheduleSteerFlush(activeTurn) {
|
|
36967
|
+
if (this.pendingSteerFlushTurn === activeTurn)
|
|
36968
|
+
return;
|
|
36969
|
+
this.pendingSteerFlushTurn = activeTurn;
|
|
36970
|
+
this.enqueueLaneAdmission(async () => {
|
|
36971
|
+
if (this.pendingSteerFlushTurn === activeTurn)
|
|
36972
|
+
this.pendingSteerFlushTurn = undefined;
|
|
36973
|
+
while (this.pendingSteers.length > 0 && this.pendingSteers[0].finalized) {
|
|
36974
|
+
this.pendingSteers.shift();
|
|
36975
|
+
}
|
|
36976
|
+
const batch = this.takeBatch(this.pendingSteers, (entry) => entry.message, { predicate: (entry) => !entry.finalized && entry.activeTurn === activeTurn });
|
|
36977
|
+
if (batch.length === 0)
|
|
36978
|
+
return;
|
|
36979
|
+
let deferredToQueue = false;
|
|
36980
|
+
try {
|
|
36981
|
+
if (this.activeTurn !== activeTurn || batch.every((entry) => entry.finalized)) {
|
|
36982
|
+
throw driverError("cancelled", "turn_closed_before_command_acceptance", "Turn closed before command acceptance");
|
|
36983
|
+
}
|
|
36984
|
+
const messages = batch.map((entry) => entry.message);
|
|
36985
|
+
const text = messages.map((msg) => msg.text).join(QUEUED_BATCH_SEPARATOR);
|
|
36986
|
+
await this.sendLane(text, "busy", messages);
|
|
36987
|
+
if (this.activeTurn !== activeTurn) {
|
|
36988
|
+
throw driverError("cancelled", "turn_closed_before_command_acceptance", "Turn closed before command acceptance");
|
|
36989
|
+
}
|
|
36990
|
+
for (const entry of batch) {
|
|
36991
|
+
if (entry.finalized)
|
|
36992
|
+
continue;
|
|
36993
|
+
entry.finalized = true;
|
|
36994
|
+
activeTurn.commandIds.push(entry.message.id);
|
|
36995
|
+
this.emit({ type: "command_accepted", commandId: entry.message.id, turnId: activeTurn.turnId, delivery: "steer" });
|
|
36996
|
+
entry.resolve({ status: "accepted", delivery: "steer", commandId: entry.message.id, turnId: activeTurn.turnId });
|
|
36997
|
+
}
|
|
36998
|
+
} catch (error) {
|
|
36999
|
+
if (this.activeTurn === activeTurn && error instanceof StructuredLaneAdmissionError && error.code === "runtime_busy") {
|
|
37000
|
+
deferredToQueue = true;
|
|
37001
|
+
for (const entry of batch) {
|
|
37002
|
+
if (entry.finalized)
|
|
37003
|
+
continue;
|
|
37004
|
+
entry.finalized = true;
|
|
37005
|
+
entry.resolve(this.queue(entry.message, "runtime_busy"));
|
|
37006
|
+
}
|
|
37007
|
+
while (this.pendingSteers.length > 0 && this.pendingSteers[0].activeTurn === activeTurn) {
|
|
37008
|
+
const remaining = this.pendingSteers.shift();
|
|
37009
|
+
if (remaining.finalized)
|
|
37010
|
+
continue;
|
|
37011
|
+
remaining.finalized = true;
|
|
37012
|
+
remaining.resolve(this.queue(remaining.message, "runtime_busy"));
|
|
37013
|
+
}
|
|
37014
|
+
return;
|
|
37015
|
+
}
|
|
37016
|
+
for (const entry of batch) {
|
|
37017
|
+
const failure = entry.failure ?? (typeof error === "object" && error !== null && "category" in error ? error : driverError("process", "delivery_failed", String(error), true));
|
|
37018
|
+
if (!entry.finalized) {
|
|
37019
|
+
entry.finalized = true;
|
|
37020
|
+
this.emit({ type: "command_failed", scope: "input", commandId: entry.message.id, turnId: activeTurn.turnId, error: failure });
|
|
37021
|
+
}
|
|
37022
|
+
entry.resolve({ status: "rejected", reason: "runtime_unavailable", error: failure });
|
|
37023
|
+
}
|
|
37024
|
+
} finally {
|
|
37025
|
+
if (!deferredToQueue && this.activeTurn === activeTurn && this.pendingSteers.some((entry) => !entry.finalized && entry.activeTurn === activeTurn)) {
|
|
37026
|
+
this.scheduleSteerFlush(activeTurn);
|
|
37027
|
+
}
|
|
37028
|
+
}
|
|
37029
|
+
});
|
|
37030
|
+
}
|
|
36774
37031
|
failSteeringDeliveries(category, code, message, activeTurn) {
|
|
36775
37032
|
const error = driverError(category, code, message);
|
|
36776
37033
|
for (const delivery of this.steeringDeliveries) {
|
|
@@ -37719,8 +37976,36 @@ async function readCursorQuota(options = {}, backend = "cursor") {
|
|
|
37719
37976
|
// agent-driver/dist/adapters/agy/quota.js
|
|
37720
37977
|
import { homedir as homedir14 } from "node:os";
|
|
37721
37978
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
37979
|
+
function classifyAgyQuotaError(message, sourceEpoch, structured) {
|
|
37980
|
+
const text2 = message.trim();
|
|
37981
|
+
if (!text2)
|
|
37982
|
+
return null;
|
|
37983
|
+
if (/(?:not authenticated|authentication (?:required|failed)|sign[ -]?in required|unauthenticated|unauthorized|invalid credentials|token expired|permission denied|\b401\b|\b403\b)/i.test(text2)) {
|
|
37984
|
+
return { status: "error", sourceEpoch, code: "unauthorized", retryable: false };
|
|
37985
|
+
}
|
|
37986
|
+
if (/(?:eligibility check failed|not eligible|not (?:currently )?available in your (?:location|region|country)|unsupported (?:location|region|country))/i.test(text2)) {
|
|
37987
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: false };
|
|
37988
|
+
}
|
|
37989
|
+
if (/(?:econnrefused|econnreset|etimedout|enotfound|ehostunreach|network error|fetch failed|dial tcp|socket hang up|connection refused|connection reset|proxyconnect|timed out|\bdns\b|\btls\b|\bssl\b)/i.test(text2)) {
|
|
37990
|
+
return { status: "error", sourceEpoch, code: "network", retryable: true };
|
|
37991
|
+
}
|
|
37992
|
+
if (/(?:rate[ -]?limit|too many requests|quota exceeded|\b429\b|\b50[0234]\b|internal server error|service unavailable|bad gateway|temporarily unavailable|resource exhausted|upstream)/i.test(text2)) {
|
|
37993
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
37994
|
+
}
|
|
37995
|
+
return structured ? { status: "error", sourceEpoch, code: "provider_error", retryable: true } : null;
|
|
37996
|
+
}
|
|
37997
|
+
function tryParseJson(text2) {
|
|
37998
|
+
try {
|
|
37999
|
+
return { ok: true, value: JSON.parse(text2) };
|
|
38000
|
+
} catch {
|
|
38001
|
+
return { ok: false };
|
|
38002
|
+
}
|
|
38003
|
+
}
|
|
37722
38004
|
function parseAgyQuota(value, sourceEpoch) {
|
|
37723
38005
|
const result = asRecord(value);
|
|
38006
|
+
if (result?.status === "ERROR" && typeof result.error === "string" && result.error.trim()) {
|
|
38007
|
+
return classifyAgyQuotaError(result.error, sourceEpoch, true) ?? { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
38008
|
+
}
|
|
37724
38009
|
const command = asRecord(result?.command);
|
|
37725
38010
|
const data = asRecord(command?.data);
|
|
37726
38011
|
const groups = data?.groups;
|
|
@@ -37757,21 +38042,58 @@ async function readAgyQuota(options = {}) {
|
|
|
37757
38042
|
const source = quotaSource("agy", randomUUID9());
|
|
37758
38043
|
const read = async (args) => {
|
|
37759
38044
|
const child = (options.spawn ?? spawnAgentProcess)(spec.command, args, { cwd: options.cwd ?? process.cwd(), env: { ...env, CI: "1", AGY_CLI_DISABLE_AUTO_UPDATE: "true" }, shell: spec.shell, stdin: "ignore" });
|
|
37760
|
-
let
|
|
37761
|
-
|
|
37762
|
-
|
|
37763
|
-
|
|
37764
|
-
|
|
37765
|
-
|
|
37766
|
-
|
|
37767
|
-
|
|
37768
|
-
|
|
38045
|
+
let stdout = "";
|
|
38046
|
+
let stderr = "";
|
|
38047
|
+
return runBoundedDiscoveryProcess({
|
|
38048
|
+
process: child,
|
|
38049
|
+
label: "AGY quota",
|
|
38050
|
+
timeoutMs: options.timeoutMs ?? 30000,
|
|
38051
|
+
outputMaxBytes: options.outputMaxBytes ?? 1024 * 1024,
|
|
38052
|
+
stderr: "count",
|
|
38053
|
+
cleanupGraceMs: 100,
|
|
38054
|
+
cleanup: options.cleanup,
|
|
38055
|
+
exitEvent: "close",
|
|
38056
|
+
onStdout: (text2) => {
|
|
38057
|
+
stdout += text2;
|
|
38058
|
+
},
|
|
38059
|
+
onStderr: (text2) => {
|
|
38060
|
+
stderr += text2;
|
|
38061
|
+
},
|
|
38062
|
+
onExit: (code, _signal, control) => {
|
|
38063
|
+
control.flushStdout();
|
|
38064
|
+
control.flushStderr();
|
|
38065
|
+
control.finish({ exitCode: code, stdout, stderr });
|
|
38066
|
+
}
|
|
38067
|
+
});
|
|
37769
38068
|
};
|
|
37770
38069
|
try {
|
|
37771
|
-
|
|
38070
|
+
const models = await read(["models"]);
|
|
38071
|
+
if (models.exitCode !== 0) {
|
|
38072
|
+
const classified2 = classifyAgyQuotaError(models.stderr || models.stdout, source.epoch, false);
|
|
38073
|
+
return source.finish(classified2 ?? source.error("unavailable", true));
|
|
38074
|
+
}
|
|
38075
|
+
if (!parseAgyModelCatalog(models.stdout))
|
|
37772
38076
|
return source.finish(source.error("unauthorized"));
|
|
37773
|
-
|
|
37774
|
-
|
|
38077
|
+
const usage = await read(["-p", "/usage", "--output-format", "json"]);
|
|
38078
|
+
const parsed = tryParseJson(usage.stdout);
|
|
38079
|
+
if (parsed.ok) {
|
|
38080
|
+
const record8 = asRecord(parsed.value);
|
|
38081
|
+
if (usage.exitCode === 0) {
|
|
38082
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
38083
|
+
}
|
|
38084
|
+
if (record8?.status === "ERROR" && typeof record8.error === "string" && record8.error.trim()) {
|
|
38085
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
38086
|
+
}
|
|
38087
|
+
}
|
|
38088
|
+
if (usage.exitCode === 0) {
|
|
38089
|
+
return source.finish(source.error("invalid_response", true));
|
|
38090
|
+
}
|
|
38091
|
+
const classified = classifyAgyQuotaError(usage.stderr || usage.stdout, source.epoch, false);
|
|
38092
|
+
return source.finish(classified ?? source.error("unavailable", true));
|
|
38093
|
+
} catch (error) {
|
|
38094
|
+
if (error instanceof DiscoveryProcessError && error.code === "output_limit") {
|
|
38095
|
+
return source.finish(source.error("invalid_response", true));
|
|
38096
|
+
}
|
|
37775
38097
|
return source.finish(source.error("unavailable", true));
|
|
37776
38098
|
}
|
|
37777
38099
|
}
|
|
@@ -59875,12 +60197,16 @@ var CommunityAgentSendRequestSchema = exports_external.object({
|
|
|
59875
60197
|
channel: exports_external.string().min(1),
|
|
59876
60198
|
content: CommunityAgentMessageContentSchema,
|
|
59877
60199
|
question: DecisionCardInputSchema.optional(),
|
|
60200
|
+
page: exports_external.strictObject({ id: exports_external.string().regex(/^page_[A-Za-z0-9_-]+$/).max(128) }).optional(),
|
|
59878
60201
|
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
59879
60202
|
seenUpToSeq: CommunityAgentSeqSchema.optional(),
|
|
59880
60203
|
replyToSeq: CommunityAgentPositiveSeqSchema.optional(),
|
|
59881
60204
|
force: exports_external.boolean().optional(),
|
|
59882
60205
|
nonce: exports_external.string().min(1).max(128).optional()
|
|
59883
60206
|
}).superRefine((d, ctx) => {
|
|
60207
|
+
if (d.page && (!d.nonce || d.question)) {
|
|
60208
|
+
ctx.addIssue({ code: "custom", path: ["page"], message: "Page publication requires a nonce and cannot include a decision card" });
|
|
60209
|
+
}
|
|
59884
60210
|
if (d.question !== undefined) {
|
|
59885
60211
|
if (d.attachments.length > 0) {
|
|
59886
60212
|
ctx.addIssue({
|
|
@@ -59993,7 +60319,7 @@ var AuditLogTextPayloadSchema = exports_external.object({
|
|
|
59993
60319
|
var AuditLogTurnInterruptPayloadSchema = exports_external.object({
|
|
59994
60320
|
status: exports_external.literal("accepted")
|
|
59995
60321
|
});
|
|
59996
|
-
var
|
|
60322
|
+
var AuditLogChatWakeTriggerPayloadSchema = exports_external.object({
|
|
59997
60323
|
messageId: exports_external.string().min(1),
|
|
59998
60324
|
channel: exports_external.string().min(1),
|
|
59999
60325
|
seq: CommunityAgentPositiveSeqSchema,
|
|
@@ -60001,6 +60327,27 @@ var AuditLogWakeTriggerPayloadSchema = exports_external.object({
|
|
|
60001
60327
|
senderHandle: exports_external.string().min(1),
|
|
60002
60328
|
reason: exports_external.enum(["unread", "mention"])
|
|
60003
60329
|
});
|
|
60330
|
+
var AuditLogWebhookWakeTriggerPayloadSchema = exports_external.object({
|
|
60331
|
+
reason: exports_external.literal("webhook"),
|
|
60332
|
+
triggerId: exports_external.string().min(1),
|
|
60333
|
+
triggerName: exports_external.string().min(1).max(120),
|
|
60334
|
+
provider: exports_external.string().min(1).max(64),
|
|
60335
|
+
eventType: exports_external.string().min(1).max(120),
|
|
60336
|
+
summary: exports_external.string().min(1).max(240)
|
|
60337
|
+
});
|
|
60338
|
+
var AuditLogScheduleWakeTriggerPayloadSchema = exports_external.object({
|
|
60339
|
+
reason: exports_external.literal("schedule"),
|
|
60340
|
+
scheduleId: exports_external.string().min(1),
|
|
60341
|
+
runId: exports_external.string().min(1),
|
|
60342
|
+
title: exports_external.string().min(1).max(200),
|
|
60343
|
+
channel: exports_external.string().min(1).optional(),
|
|
60344
|
+
seq: CommunityAgentPositiveSeqSchema.optional()
|
|
60345
|
+
});
|
|
60346
|
+
var AuditLogWakeTriggerPayloadSchema = exports_external.union([
|
|
60347
|
+
AuditLogChatWakeTriggerPayloadSchema,
|
|
60348
|
+
AuditLogWebhookWakeTriggerPayloadSchema,
|
|
60349
|
+
AuditLogScheduleWakeTriggerPayloadSchema
|
|
60350
|
+
]);
|
|
60004
60351
|
var AuditLogSessionResetPayloadSchema = exports_external.object({
|
|
60005
60352
|
trigger: exports_external.enum(["single", "reset_all", "idle_timeout"])
|
|
60006
60353
|
});
|
|
@@ -60727,42 +61074,6 @@ var BillingPortalRequestSchema = exports_external.strictObject({
|
|
|
60727
61074
|
var BillingRedirectResponseSchema = exports_external.object({
|
|
60728
61075
|
url: exports_external.url()
|
|
60729
61076
|
});
|
|
60730
|
-
// ../shared/src/utils/day-key.ts
|
|
60731
|
-
function utcDayKey(now) {
|
|
60732
|
-
const d = now instanceof Date ? now : new Date(now);
|
|
60733
|
-
return d.toISOString().slice(0, 10);
|
|
60734
|
-
}
|
|
60735
|
-
function calendarDayKeyDaysAgo(day, days) {
|
|
60736
|
-
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(day);
|
|
60737
|
-
if (!match)
|
|
60738
|
-
throw new RangeError("invalid calendar day key");
|
|
60739
|
-
const year = Number(match[1]);
|
|
60740
|
-
const month = Number(match[2]);
|
|
60741
|
-
const date5 = Number(match[3]);
|
|
60742
|
-
const parsed = new Date(Date.UTC(year, month - 1, date5));
|
|
60743
|
-
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== date5) {
|
|
60744
|
-
throw new RangeError("invalid calendar day key");
|
|
60745
|
-
}
|
|
60746
|
-
parsed.setUTCDate(parsed.getUTCDate() - days);
|
|
60747
|
-
return utcDayKey(parsed);
|
|
60748
|
-
}
|
|
60749
|
-
function dayKeyInTimeZone(now, timeZone) {
|
|
60750
|
-
const date5 = now instanceof Date ? now : new Date(now);
|
|
60751
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
60752
|
-
timeZone,
|
|
60753
|
-
year: "numeric",
|
|
60754
|
-
month: "2-digit",
|
|
60755
|
-
day: "2-digit"
|
|
60756
|
-
}).formatToParts(date5);
|
|
60757
|
-
const values = new Map(parts.map((part) => [part.type, part.value]));
|
|
60758
|
-
const year = values.get("year");
|
|
60759
|
-
const month = values.get("month");
|
|
60760
|
-
const day = values.get("day");
|
|
60761
|
-
if (!year || !month || !day)
|
|
60762
|
-
throw new RangeError("unable to format calendar day key");
|
|
60763
|
-
return `${year}-${month}-${day}`;
|
|
60764
|
-
}
|
|
60765
|
-
|
|
60766
61077
|
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261119.1_@opentelemetry+api@1.10.0_@ty_38fec08cb14afcae8326bba90a769ca2/node_modules/drizzle-orm/entity.js
|
|
60767
61078
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
60768
61079
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
@@ -61564,8 +61875,6 @@ __export(exports_community_schema, {
|
|
|
61564
61875
|
communityChannel: () => communityChannel,
|
|
61565
61876
|
communityCategory: () => communityCategory,
|
|
61566
61877
|
communityBotDailyTokenUsage: () => communityBotDailyTokenUsage,
|
|
61567
|
-
communityBotDailyActivity: () => communityBotDailyActivity,
|
|
61568
|
-
communityBotApprovalRequest: () => communityBotApprovalRequest,
|
|
61569
61878
|
communityBotActivityEvent: () => communityBotActivityEvent,
|
|
61570
61879
|
communityAttachment: () => communityAttachment
|
|
61571
61880
|
});
|
|
@@ -62716,24 +63025,6 @@ var communityPushDevice = sqliteTable("community_push_device", {
|
|
|
62716
63025
|
check2("ck_push_device_android_environment", sql`${t.platform} = 'ios' or ${t.providerEnvironment} = 'production'`),
|
|
62717
63026
|
check2("ck_push_device_token_hash", sql`length(${t.providerTokenHash}) = 64 and ${t.providerTokenHash} not glob '*[^0-9a-f]*'`)
|
|
62718
63027
|
]);
|
|
62719
|
-
var communityBotApprovalRequest = sqliteTable("community_bot_approval_request", {
|
|
62720
|
-
id: text2("id").primaryKey().$defaultFn(() => "bar_" + nanoid3()),
|
|
62721
|
-
botId: text2("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62722
|
-
kind: text2("kind").notNull(),
|
|
62723
|
-
serverId: text2("server_id").references(() => communityServer.id, {
|
|
62724
|
-
onDelete: "cascade"
|
|
62725
|
-
}),
|
|
62726
|
-
requestedByUserId: text2("requested_by_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62727
|
-
dmMessageId: text2("dm_message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
62728
|
-
status: text2("status").notNull().default("pending"),
|
|
62729
|
-
createdAt: text2("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
62730
|
-
resolvedAt: text2("resolved_at")
|
|
62731
|
-
}, (t) => [
|
|
62732
|
-
index("idx_community_bot_approval_bot").on(t.botId, t.status),
|
|
62733
|
-
index("idx_community_bot_approval_server_lookup").on(t.serverId),
|
|
62734
|
-
index("idx_community_bot_approval_requester_lookup").on(t.requestedByUserId),
|
|
62735
|
-
index("idx_community_bot_approval_message_lookup").on(t.dmMessageId)
|
|
62736
|
-
]);
|
|
62737
63028
|
var communityBotActivityEvent = sqliteTable("community_bot_activity_event", {
|
|
62738
63029
|
id: text2("id").primaryKey().$defaultFn(() => "bae_" + nanoid3()),
|
|
62739
63030
|
botId: text2("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
@@ -62745,12 +63036,6 @@ var communityBotActivityEvent = sqliteTable("community_bot_activity_event", {
|
|
|
62745
63036
|
}, (t) => [
|
|
62746
63037
|
index("idx_bot_activity_event_bot_created").on(t.botId, t.createdAt, t.id)
|
|
62747
63038
|
]);
|
|
62748
|
-
var communityBotDailyActivity = sqliteTable("community_bot_daily_activity", {
|
|
62749
|
-
botId: text2("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62750
|
-
day: text2("day").notNull(),
|
|
62751
|
-
handledCount: integer2("handled_count").notNull().default(0),
|
|
62752
|
-
sentCount: integer2("sent_count").notNull().default(0)
|
|
62753
|
-
}, (t) => [primaryKey({ columns: [t.botId, t.day] })]);
|
|
62754
63039
|
var communityBotDailyTokenUsage = sqliteTable("community_bot_daily_token_usage", {
|
|
62755
63040
|
botId: text2("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62756
63041
|
day: text2("day").notNull(),
|
|
@@ -63176,6 +63461,35 @@ var NOTIFY_CONFLICT_TARGET = [
|
|
|
63176
63461
|
communityChannelMember.relation
|
|
63177
63462
|
];
|
|
63178
63463
|
|
|
63464
|
+
// ../shared/src/community-page.ts
|
|
63465
|
+
var pageId = exports_external.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/);
|
|
63466
|
+
var ALOOK_PAGE_EMBED_KIND = "alook_page";
|
|
63467
|
+
var AlookPageEmbedSchema = exports_external.strictObject({
|
|
63468
|
+
kind: exports_external.literal(ALOOK_PAGE_EMBED_KIND),
|
|
63469
|
+
id: pageId,
|
|
63470
|
+
type: exports_external.string().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/),
|
|
63471
|
+
title: exports_external.string().trim().min(1).max(256)
|
|
63472
|
+
});
|
|
63473
|
+
var AlookPageSourceSchema = exports_external.strictObject({ sourceMessageId: exports_external.string().min(1).max(128).optional() });
|
|
63474
|
+
var AlookPageCommentSchema = AlookPageSourceSchema.extend({
|
|
63475
|
+
text: exports_external.string().trim().min(1).max(8000),
|
|
63476
|
+
location: exports_external.string().trim().min(1).max(1024).optional()
|
|
63477
|
+
});
|
|
63478
|
+
var AlookPageViewerSchema = exports_external.strictObject({
|
|
63479
|
+
embedUrl: exports_external.url(),
|
|
63480
|
+
allowedOrigins: exports_external.array(exports_external.url()).min(1).max(2),
|
|
63481
|
+
expiresAt: exports_external.iso.datetime()
|
|
63482
|
+
});
|
|
63483
|
+
var artifactPath = exports_external.string().min(1).max(512).refine((value) => !value.startsWith("/") && !value.includes("\\") && !value.split("/").some((part) => part === ".." || part === "." || part === ""), "A relative artifact path is required");
|
|
63484
|
+
var AlookPageOperationSchema = exports_external.discriminatedUnion("kind", [
|
|
63485
|
+
exports_external.strictObject({ kind: exports_external.literal("actions") }),
|
|
63486
|
+
exports_external.strictObject({ kind: exports_external.literal("manifest") }),
|
|
63487
|
+
exports_external.strictObject({ kind: exports_external.literal("read"), path: artifactPath }),
|
|
63488
|
+
exports_external.strictObject({ kind: exports_external.literal("write"), writes: exports_external.array(exports_external.strictObject({ path: artifactPath, content: exports_external.string().max(1398104).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/).refine((value) => value.length * 3 / 4 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0) <= 1024 * 1024).nullable(), if_match: exports_external.string().max(256).nullable() })).min(1).max(16) }),
|
|
63489
|
+
exports_external.strictObject({ kind: exports_external.literal("action"), name: exports_external.string().min(1).max(128), args: exports_external.record(exports_external.string(), exports_external.unknown()) })
|
|
63490
|
+
]);
|
|
63491
|
+
var PAGE_COVER_MAX_BYTES = 2 * 1024 * 1024;
|
|
63492
|
+
|
|
63179
63493
|
// ../shared/src/db/resilience.ts
|
|
63180
63494
|
var defaultLogger = createLogger({ service: "d1-resilience" });
|
|
63181
63495
|
|
|
@@ -63835,6 +64149,30 @@ var communityBotFeedback = sqliteTable("community_bot_feedback", {
|
|
|
63835
64149
|
check2("bot_feedback_text_bytes", sql`length(cast(${t.text} as blob)) between 1 and ${sql.raw(String(BOT_FEEDBACK_MAX_BYTES))}`)
|
|
63836
64150
|
]);
|
|
63837
64151
|
|
|
64152
|
+
// ../shared/src/db/page-schema.ts
|
|
64153
|
+
var exports_page_schema = {};
|
|
64154
|
+
__export(exports_page_schema, {
|
|
64155
|
+
communityPage: () => communityPage,
|
|
64156
|
+
communityMessagePage: () => communityMessagePage
|
|
64157
|
+
});
|
|
64158
|
+
var communityPage = sqliteTable("community_page", {
|
|
64159
|
+
id: text2("id").primaryKey(),
|
|
64160
|
+
artifactId: text2("artifact_id").notNull(),
|
|
64161
|
+
archiveAttachmentId: text2("archive_attachment_id").notNull().references(() => communityAttachment.id, { onDelete: "restrict" }),
|
|
64162
|
+
botId: text2("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64163
|
+
type: text2("type").notNull(),
|
|
64164
|
+
title: text2("title").notNull(),
|
|
64165
|
+
createdAt: text2("created_at").notNull()
|
|
64166
|
+
}, (t) => [
|
|
64167
|
+
uniqueIndex("uq_community_page_artifact").on(t.artifactId),
|
|
64168
|
+
uniqueIndex("uq_community_page_archive").on(t.archiveAttachmentId),
|
|
64169
|
+
index("idx_community_page_bot_id").on(t.botId, t.createdAt, t.id)
|
|
64170
|
+
]);
|
|
64171
|
+
var communityMessagePage = sqliteTable("community_message_page", {
|
|
64172
|
+
messageId: text2("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
64173
|
+
pageId: text2("page_id").notNull().references(() => communityPage.id, { onDelete: "cascade" })
|
|
64174
|
+
}, (t) => [primaryKey({ columns: [t.messageId, t.pageId] }), index("idx_community_message_page_page").on(t.pageId, t.messageId)]);
|
|
64175
|
+
|
|
63838
64176
|
// ../shared/src/db/community-schedule-schema.ts
|
|
63839
64177
|
var exports_community_schedule_schema = {};
|
|
63840
64178
|
__export(exports_community_schedule_schema, {
|
|
@@ -63885,8 +64223,59 @@ var communityScheduleRun = sqliteTable("community_schedule_run", {
|
|
|
63885
64223
|
index("idx_community_schedule_run_bot_id_lookup").on(t.botUserId)
|
|
63886
64224
|
]);
|
|
63887
64225
|
|
|
64226
|
+
// ../shared/src/db/community-bot-private-inbox-schema.ts
|
|
64227
|
+
var exports_community_bot_private_inbox_schema = {};
|
|
64228
|
+
__export(exports_community_bot_private_inbox_schema, {
|
|
64229
|
+
communityBotPrivateInbox: () => communityBotPrivateInbox
|
|
64230
|
+
});
|
|
64231
|
+
var communityBotPrivateInbox = sqliteTable("community_bot_private_inbox", {
|
|
64232
|
+
id: text2("id").primaryKey(),
|
|
64233
|
+
ownerUserId: text2("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64234
|
+
botUserId: text2("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64235
|
+
sourceKind: text2("source_kind").$type().notNull(),
|
|
64236
|
+
sourceId: text2("source_id").notNull(),
|
|
64237
|
+
sourceRefId: text2("source_ref_id"),
|
|
64238
|
+
dedupeKey: text2("dedupe_key"),
|
|
64239
|
+
eventType: text2("event_type").notNull(),
|
|
64240
|
+
summary: text2("summary").notNull(),
|
|
64241
|
+
promptText: text2("prompt_text").notNull(),
|
|
64242
|
+
status: text2("status").$type().notNull(),
|
|
64243
|
+
lastError: text2("last_error"),
|
|
64244
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
64245
|
+
dispatchedAtMs: integer2("dispatched_at_ms")
|
|
64246
|
+
}, (t) => [
|
|
64247
|
+
uniqueIndex("uq_community_bot_private_inbox_dedupe").on(t.sourceKind, t.sourceId, t.dedupeKey).where(sql`${t.dedupeKey} IS NOT NULL`),
|
|
64248
|
+
index("idx_community_bot_private_inbox_bot_pending").on(t.botUserId, t.status, t.createdAtMs),
|
|
64249
|
+
index("idx_community_bot_private_inbox_source_created").on(t.sourceKind, t.sourceId, t.createdAtMs),
|
|
64250
|
+
index("idx_community_bot_private_inbox_owner").on(t.ownerUserId)
|
|
64251
|
+
]);
|
|
64252
|
+
|
|
64253
|
+
// ../shared/src/db/community-bot-webhook-schema.ts
|
|
64254
|
+
var exports_community_bot_webhook_schema = {};
|
|
64255
|
+
__export(exports_community_bot_webhook_schema, {
|
|
64256
|
+
communityBotWebhook: () => communityBotWebhook
|
|
64257
|
+
});
|
|
64258
|
+
var communityBotWebhook = sqliteTable("community_bot_webhook", {
|
|
64259
|
+
id: text2("id").primaryKey(),
|
|
64260
|
+
ownerUserId: text2("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64261
|
+
botUserId: text2("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64262
|
+
name: text2("name").notNull(),
|
|
64263
|
+
provider: text2("provider").$type().notNull(),
|
|
64264
|
+
tokenHash: text2("token_hash").notNull().unique(),
|
|
64265
|
+
signingSecretEnc: text2("signing_secret_enc"),
|
|
64266
|
+
eventFilterJson: text2("event_filter_json"),
|
|
64267
|
+
instruction: text2("instruction").notNull().default(""),
|
|
64268
|
+
enabled: integer2("enabled", { mode: "boolean" }).notNull().default(true),
|
|
64269
|
+
lastTriggeredAtMs: integer2("last_triggered_at_ms"),
|
|
64270
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
64271
|
+
updatedAtMs: integer2("updated_at_ms").notNull()
|
|
64272
|
+
}, (t) => [
|
|
64273
|
+
index("idx_community_bot_webhook_owner_bot").on(t.ownerUserId, t.botUserId, t.createdAtMs),
|
|
64274
|
+
index("idx_community_bot_webhook_bot").on(t.botUserId)
|
|
64275
|
+
]);
|
|
64276
|
+
|
|
63888
64277
|
// ../shared/src/db/index.ts
|
|
63889
|
-
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_community_schedule_schema };
|
|
64278
|
+
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_page_schema, ...exports_community_schedule_schema, ...exports_community_bot_private_inbox_schema, ...exports_community_bot_webhook_schema };
|
|
63890
64279
|
// ../shared/src/db/queries/native-oauth.ts
|
|
63891
64280
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
63892
64281
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
@@ -63915,6 +64304,9 @@ var metadataProjection = {
|
|
|
63915
64304
|
};
|
|
63916
64305
|
// ../shared/src/db/queries/community/diagnostic-report.ts
|
|
63917
64306
|
var diagnosticOwner = alias(user, "diagnostic_owner");
|
|
64307
|
+
// ../shared/src/db/queries/community/page.ts
|
|
64308
|
+
var channelColumns = { id: communityChannel.id, type: communityChannel.type, serverId: communityChannel.serverId, parentChannelId: communityChannel.parentChannelId };
|
|
64309
|
+
var viewerTicket = exports_external.strictObject({ userId: exports_external.string().min(1), pageId: exports_external.string().min(1), origin: exports_external.url(), sourceMessageId: exports_external.string().min(1) });
|
|
63918
64310
|
// ../shared/src/schedule.ts
|
|
63919
64311
|
var SCHEDULE_TITLE_MAX_LENGTH = 160;
|
|
63920
64312
|
var SCHEDULE_DESCRIPTION_MAX_LENGTH = 4000;
|
|
@@ -64025,6 +64417,107 @@ var ScheduleUpdateRequestSchema = exports_external.strictObject({
|
|
|
64025
64417
|
ack: exports_external.literal(true).optional()
|
|
64026
64418
|
});
|
|
64027
64419
|
var formatterCache = new Map;
|
|
64420
|
+
// ../shared/src/bot-webhook.ts
|
|
64421
|
+
var BOT_WEBHOOK_PROVIDERS = [
|
|
64422
|
+
"github",
|
|
64423
|
+
"linear",
|
|
64424
|
+
"sentry",
|
|
64425
|
+
"stripe",
|
|
64426
|
+
"vercel",
|
|
64427
|
+
"gitlab",
|
|
64428
|
+
"slack",
|
|
64429
|
+
"openai",
|
|
64430
|
+
"resend",
|
|
64431
|
+
"clerk",
|
|
64432
|
+
"polar",
|
|
64433
|
+
"cloudflare",
|
|
64434
|
+
"grafana",
|
|
64435
|
+
"datadog",
|
|
64436
|
+
"n8n",
|
|
64437
|
+
"generic"
|
|
64438
|
+
];
|
|
64439
|
+
var BOT_WEBHOOK_DELIVERY_STATUSES = ["pending", "dispatched", "ignored", "failed"];
|
|
64440
|
+
var BOT_WEBHOOK_NAME_MAX_LENGTH = 80;
|
|
64441
|
+
var BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH = 500;
|
|
64442
|
+
var BOT_WEBHOOK_SECRET_MIN_LENGTH = 8;
|
|
64443
|
+
var BOT_WEBHOOK_SECRET_MAX_LENGTH = 256;
|
|
64444
|
+
var BOT_WEBHOOK_MAX_EVENT_FILTERS = 32;
|
|
64445
|
+
var BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH = 64;
|
|
64446
|
+
var BOT_WEBHOOK_RESYNC_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
64447
|
+
var BotWebhookProviderSchema = exports_external.enum(BOT_WEBHOOK_PROVIDERS);
|
|
64448
|
+
var BotWebhookDeliveryStatusSchema = exports_external.enum(BOT_WEBHOOK_DELIVERY_STATUSES);
|
|
64449
|
+
var EventFilterEntrySchema = exports_external.string().trim().min(1).max(BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH).regex(/^[a-z0-9_.-]+$/i, "Event name may only contain letters, digits, _, ., and -");
|
|
64450
|
+
var BotWebhookEventFilterSchema = exports_external.array(EventFilterEntrySchema).max(BOT_WEBHOOK_MAX_EVENT_FILTERS).transform((items) => [...new Set(items.map((item) => item.toLowerCase()))]);
|
|
64451
|
+
var SigningSecretInputSchema = exports_external.string().trim().min(BOT_WEBHOOK_SECRET_MIN_LENGTH, `Verification key must be at least ${BOT_WEBHOOK_SECRET_MIN_LENGTH} characters`).max(BOT_WEBHOOK_SECRET_MAX_LENGTH, `Verification key must be at most ${BOT_WEBHOOK_SECRET_MAX_LENGTH} characters`);
|
|
64452
|
+
var BotWebhookLastDeliverySchema = exports_external.strictObject({
|
|
64453
|
+
id: exports_external.string().min(1),
|
|
64454
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
64455
|
+
eventType: exports_external.string().min(1),
|
|
64456
|
+
summary: exports_external.string(),
|
|
64457
|
+
lastError: exports_external.string().nullable(),
|
|
64458
|
+
createdAt: exports_external.iso.datetime()
|
|
64459
|
+
});
|
|
64460
|
+
var BotWebhookDeliverySchema = exports_external.strictObject({
|
|
64461
|
+
id: exports_external.string().min(1),
|
|
64462
|
+
webhookId: exports_external.string().min(1),
|
|
64463
|
+
eventType: exports_external.string().min(1),
|
|
64464
|
+
summary: exports_external.string(),
|
|
64465
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
64466
|
+
lastError: exports_external.string().nullable(),
|
|
64467
|
+
externalDeliveryId: exports_external.string().nullable(),
|
|
64468
|
+
createdAt: exports_external.iso.datetime(),
|
|
64469
|
+
dispatchedAt: exports_external.iso.datetime().nullable()
|
|
64470
|
+
});
|
|
64471
|
+
var BotWebhookSummarySchema = exports_external.strictObject({
|
|
64472
|
+
id: exports_external.string().min(1),
|
|
64473
|
+
botId: exports_external.string().min(1),
|
|
64474
|
+
name: exports_external.string().min(1),
|
|
64475
|
+
provider: BotWebhookProviderSchema,
|
|
64476
|
+
hasSigningSecret: exports_external.boolean(),
|
|
64477
|
+
eventFilter: exports_external.array(exports_external.string()).nullable(),
|
|
64478
|
+
instruction: exports_external.string(),
|
|
64479
|
+
enabled: exports_external.boolean(),
|
|
64480
|
+
lastTriggeredAt: exports_external.iso.datetime().nullable(),
|
|
64481
|
+
createdAt: exports_external.iso.datetime(),
|
|
64482
|
+
updatedAt: exports_external.iso.datetime(),
|
|
64483
|
+
lastDelivery: BotWebhookLastDeliverySchema.nullable()
|
|
64484
|
+
});
|
|
64485
|
+
var BotWebhookCreateSchema = exports_external.strictObject({
|
|
64486
|
+
name: exports_external.string().trim().min(1, "Name is required").max(BOT_WEBHOOK_NAME_MAX_LENGTH),
|
|
64487
|
+
provider: BotWebhookProviderSchema,
|
|
64488
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
64489
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional().default(""),
|
|
64490
|
+
requireSecret: exports_external.boolean().optional(),
|
|
64491
|
+
signingSecret: SigningSecretInputSchema.optional()
|
|
64492
|
+
});
|
|
64493
|
+
var BotWebhookUpdateSchema = exports_external.strictObject({
|
|
64494
|
+
name: exports_external.string().trim().min(1).max(BOT_WEBHOOK_NAME_MAX_LENGTH).optional(),
|
|
64495
|
+
enabled: exports_external.boolean().optional(),
|
|
64496
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
64497
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional(),
|
|
64498
|
+
requireSecret: exports_external.boolean().optional(),
|
|
64499
|
+
signingSecret: SigningSecretInputSchema.optional(),
|
|
64500
|
+
rotateCredentials: exports_external.boolean().optional()
|
|
64501
|
+
}).refine((v) => v.name !== undefined || v.enabled !== undefined || v.eventFilter !== undefined || v.instruction !== undefined || v.requireSecret !== undefined || v.signingSecret !== undefined || v.rotateCredentials === true, { message: "At least one field must be provided" });
|
|
64502
|
+
var BotWebhookCreateResponseSchema = exports_external.strictObject({
|
|
64503
|
+
webhook: BotWebhookSummarySchema,
|
|
64504
|
+
webhookUrl: exports_external.url(),
|
|
64505
|
+
signingSecret: exports_external.string().nullable()
|
|
64506
|
+
});
|
|
64507
|
+
var BotWebhookUpdateResponseSchema = exports_external.strictObject({
|
|
64508
|
+
webhook: BotWebhookSummarySchema,
|
|
64509
|
+
webhookUrl: exports_external.url().optional(),
|
|
64510
|
+
signingSecret: exports_external.string().nullable().optional()
|
|
64511
|
+
});
|
|
64512
|
+
var BotWebhookListResponseSchema = exports_external.strictObject({
|
|
64513
|
+
webhooks: exports_external.array(BotWebhookSummarySchema)
|
|
64514
|
+
});
|
|
64515
|
+
var BotWebhookDeliveriesResponseSchema = exports_external.strictObject({
|
|
64516
|
+
deliveries: exports_external.array(BotWebhookDeliverySchema)
|
|
64517
|
+
});
|
|
64518
|
+
var BotWebhookTestResponseSchema = exports_external.strictObject({
|
|
64519
|
+
delivery: BotWebhookDeliverySchema
|
|
64520
|
+
});
|
|
64028
64521
|
// ../shared/src/lib/channel-ref-syntax.ts
|
|
64029
64522
|
var REF_TERM = `.,;:!?)\\]}"'\\u2014\\u2019\\u201D\\u2026\\u3001\\u3002\\u3009\\u300B\\u300D\\u300F\\u3011\\u3015\\u3017\\u3019\\u301B\\uFF01\\uFF02\\uFF07\\uFF09\\uFF0C\\uFF0E\\uFF1A\\uFF1B\\uFF1F\\uFF3D\\uFF5D`;
|
|
64030
64523
|
var REF_SEG = `[^\\s/#${REF_TERM}]+`;
|
|
@@ -64033,6 +64526,41 @@ var CHANNEL_REF_RE = new RegExp(`(?<!/[^\\s${REF_TERM}]*)(?:/${HANDLE_SEG}/${REF
|
|
|
64033
64526
|
var SERVER_REF_RE = new RegExp(`(?<=^|\\s)/${HANDLE_SEG}(?=\\s|$|[${REF_TERM}])`, "gu");
|
|
64034
64527
|
// ../shared/src/utils/email.ts
|
|
64035
64528
|
var DOMAIN = `@${process.env.ALOOK_DOMAIN || "alook.ai"}`;
|
|
64529
|
+
// ../shared/src/utils/day-key.ts
|
|
64530
|
+
function utcDayKey(now) {
|
|
64531
|
+
const d = now instanceof Date ? now : new Date(now);
|
|
64532
|
+
return d.toISOString().slice(0, 10);
|
|
64533
|
+
}
|
|
64534
|
+
function calendarDayKeyDaysAgo(day, days) {
|
|
64535
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(day);
|
|
64536
|
+
if (!match)
|
|
64537
|
+
throw new RangeError("invalid calendar day key");
|
|
64538
|
+
const year = Number(match[1]);
|
|
64539
|
+
const month = Number(match[2]);
|
|
64540
|
+
const date5 = Number(match[3]);
|
|
64541
|
+
const parsed = new Date(Date.UTC(year, month - 1, date5));
|
|
64542
|
+
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== date5) {
|
|
64543
|
+
throw new RangeError("invalid calendar day key");
|
|
64544
|
+
}
|
|
64545
|
+
parsed.setUTCDate(parsed.getUTCDate() - days);
|
|
64546
|
+
return utcDayKey(parsed);
|
|
64547
|
+
}
|
|
64548
|
+
function dayKeyInTimeZone(now, timeZone) {
|
|
64549
|
+
const date5 = now instanceof Date ? now : new Date(now);
|
|
64550
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
64551
|
+
timeZone,
|
|
64552
|
+
year: "numeric",
|
|
64553
|
+
month: "2-digit",
|
|
64554
|
+
day: "2-digit"
|
|
64555
|
+
}).formatToParts(date5);
|
|
64556
|
+
const values = new Map(parts.map((part) => [part.type, part.value]));
|
|
64557
|
+
const year = values.get("year");
|
|
64558
|
+
const month = values.get("month");
|
|
64559
|
+
const day = values.get("day");
|
|
64560
|
+
if (!year || !month || !day)
|
|
64561
|
+
throw new RangeError("unable to format calendar day key");
|
|
64562
|
+
return `${year}-${month}-${day}`;
|
|
64563
|
+
}
|
|
64036
64564
|
// ../shared/src/lib/safe-redirect.ts
|
|
64037
64565
|
var MAX_REDIRECT_BYTES = 2048;
|
|
64038
64566
|
var CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/;
|
|
@@ -78475,6 +79003,7 @@ function messagingSection() {
|
|
|
78475
79003
|
`- Long detail: upload it with \`${CLI} message attachment upload --file <path>.md\`; ` + "add the returned id as `--attachment <id>` on the short stdin send.",
|
|
78476
79004
|
`- Inline HTML: upload a self-contained UTF-8 \`<path>.html\` file with \`${CLI} message attachment upload --file <path>.html\`. ` + "Inline CSS and JavaScript in the file; do not depend on local paths on the sender's computer. " + "Include the returned ID with `--attachment <id>` when sending; see Message formatting for its inline reference syntax. " + "Use the Alook theme CSS variables injected by the host on `:root`: " + "`--background`, `--foreground`, `--card`, `--card-foreground`, `--popover`, `--popover-foreground`, " + "`--primary`, `--primary-foreground`, `--secondary`, `--secondary-foreground`, `--muted`, `--muted-foreground`, " + "`--accent`, `--accent-foreground`, `--border`, `--input`, `--ring`, `--destructive`, `--warning`, " + "`--radius`, `--font-sans`, and `--font-mono`. Use their values directly with `var(...)`; " + "do not hardcode page theme colors to one light or dark scheme. " + "Do not add background colors to `html`, `body`, or the outermost element. Do not add an outer card, " + "border, banner title, or side padding. This rule takes priority over other page-background authoring rules. " + "An internal box that needs a background uses a theme variable, 16px padding, and `var(--radius)` corners. " + "Adapt to the available width and different screen sizes; do not hardcode a desktop page width. " + "Give charts fixed pixel heights. Let content set the page height. Do not use `vh`, `dvh`, `svh`, or `lvh`, " + "and do not set `height:100%` on `html` or `body`. The current preview validator rejects those viewport units; " + "percentage heights on the document roots can cause a measurement loop. " + "Alook measures the frame height automatically in CSS pixels, currently 80–2000px inline. " + "Sending a message requires no height parameter. Keep the original HTML within the current 2 MiB preview limit.",
|
|
78477
79005
|
"- Reuse files: to forward an attachment or send the same file again, pass its existing ID with `--attachment <id>`. " + "Do not download and upload it again. Reuse works across channels, DMs, and threads while you can still read the file. " + "Upload only a new or changed file.",
|
|
79006
|
+
"- Alook Page: for living collaborative artifacts or apps that need persisted cloud state (not one-off inline HTML visuals without saved state), read `@alook-page.md`.",
|
|
78478
79007
|
`- Cite a specific message: add \`--reply "#37"\` — \`--reply\` takes the \`#N\` seq ` + "(within `--target`) of the message you're answering.",
|
|
78479
79008
|
"",
|
|
78480
79009
|
"Write every message body in the stdin/heredoc block; never place it directly on the command line.",
|
|
@@ -78600,7 +79129,7 @@ function cliCommandsSection() {
|
|
|
78600
79129
|
"### Messaging",
|
|
78601
79130
|
"",
|
|
78602
79131
|
`1. \`${CLI} inbox pull\` — fetch unread messages and advance their read waterlines.`,
|
|
78603
|
-
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> [--ask] --stdin\` — Send to a ` + `channel, DM, or thread. ` + `For plain messages, pass up to 1 KiB of UTF-8 text through stdin and use \`--attachment <id>\` for files (repeatable, order matters). ` + `\`--remind-after\` accepts \`0\` or a whole-number duration from \`1m\` to \`24h\`.`,
|
|
79132
|
+
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> [--ask] [--page <page_id>] --stdin\` — Send to a ` + `channel, DM, or thread. ` + `For plain messages, pass up to 1 KiB of UTF-8 text through stdin and use \`--attachment <id>\` for files (repeatable, order matters). ` + `\`--remind-after\` accepts \`0\` or a whole-number duration from \`1m\` to \`24h\`.`,
|
|
78604
79133
|
`3. \`${CLI} message attachment upload --file <path>\` — upload a local file and get a reusable attachment ID. Supports Markdown and inline HTML; see Communication for formatting.`,
|
|
78605
79134
|
`4. \`${CLI} message attachment download --id <id> [--out <path>]\` — download an attachment you can read, including your own unsent uploads.`,
|
|
78606
79135
|
`5. \`${CLI} message property set --target <full-message-ref> --json <json>\` — add a supported property value to a message.`,
|
|
@@ -78658,6 +79187,12 @@ function cliCommandsSection() {
|
|
|
78658
79187
|
`3. \`${CLI} schedule update <id> [fields...] [--message <ref>] [--ack]\` — update a task, or pass \`--ack\` after finishing the triggered run to mark it completed.`,
|
|
78659
79188
|
`4. \`${CLI} schedule delete <id>\` — delete a scheduled task.`,
|
|
78660
79189
|
"",
|
|
79190
|
+
"### Pages",
|
|
79191
|
+
"",
|
|
79192
|
+
"Use an Alook Page only when people need a **persistent, living collaborative artifact or app** (documents, decks, spreadsheets, whiteboards, design boards, dashboards, motion compositions, design systems, or stateful custom apps) that stays editable and reusable across channels after chat moves on. For one-off visuals or ephemeral client-only snippets without saved state, use inline HTML; for read-only prose or logs, use plain text or a Markdown attachment.",
|
|
79193
|
+
"",
|
|
79194
|
+
"Before creating, previewing, uploading, sharing, editing, or deleting any Page, read `@alook-page.md` for all artifact types, authoring workflow, and `$ALOOK_CLI page` commands.",
|
|
79195
|
+
"",
|
|
78661
79196
|
"### Settings",
|
|
78662
79197
|
"",
|
|
78663
79198
|
`1. \`${CLI} setting profile --set-bio <text> --set-avatar <path>\` — update your public bio ` + `and/or avatar. At least one flag is required; pass \`--set-bio ""\` to clear the bio.`,
|
|
@@ -79820,8 +80355,8 @@ class AgentProcessManager {
|
|
|
79820
80355
|
return { deliveryPhase };
|
|
79821
80356
|
return { deliveryPhase, ...snapshotDiagnostics.metrics };
|
|
79822
80357
|
}
|
|
79823
|
-
withFooter(text8) {
|
|
79824
|
-
return this.opts.wakePromptFooter ? `${text8}
|
|
80358
|
+
withFooter(text8, includeWakeFooter = false) {
|
|
80359
|
+
return includeWakeFooter && this.opts.wakePromptFooter ? `${text8}
|
|
79825
80360
|
|
|
79826
80361
|
${this.opts.wakePromptFooter}` : text8;
|
|
79827
80362
|
}
|
|
@@ -79834,7 +80369,7 @@ ${this.opts.wakePromptFooter}` : text8;
|
|
|
79834
80369
|
preparedInput: message.preparedInput ?? {
|
|
79835
80370
|
id: message.id,
|
|
79836
80371
|
kind: "user",
|
|
79837
|
-
text: this.stampNow(this.withFooter(message.text)),
|
|
80372
|
+
text: this.stampNow(this.withFooter(message.text, message.includeWakeFooter)),
|
|
79838
80373
|
sequence: message.seq
|
|
79839
80374
|
}
|
|
79840
80375
|
};
|
|
@@ -80131,7 +80666,7 @@ ${this.opts.wakePromptFooter}` : text8;
|
|
|
80131
80666
|
throw new Error(`AgentProcessManager: spawn for ${agentId} has no command`);
|
|
80132
80667
|
this.dispatch({ type: "queue_delivery", agentId, messages: pending });
|
|
80133
80668
|
const first = this.prepareDelivery(initial);
|
|
80134
|
-
const prompt = this.withFooter(first.text);
|
|
80669
|
+
const prompt = this.withFooter(first.text, first.includeWakeFooter);
|
|
80135
80670
|
const driver = this.opts.driverFor(agentId, this.runtimeConfigs.get(agentId));
|
|
80136
80671
|
this.liveBackendIds.set(agentId, driver.id);
|
|
80137
80672
|
const base = this.opts.baseContextFor(agentId);
|
|
@@ -81044,7 +81579,8 @@ class AgentRouter {
|
|
|
81044
81579
|
const producedEffect = this.opts.manager.deliver(cmd.agentId, {
|
|
81045
81580
|
id: `${cmd.agentId}:wake:${cmd.unreadNotice.channel}:${cmd.unreadNotice.latestSeq}:admission:${this.nextWakeAdmissionOrdinal++}`,
|
|
81046
81581
|
seq: cmd.unreadNotice.latestSeq,
|
|
81047
|
-
text: text8
|
|
81582
|
+
text: text8,
|
|
81583
|
+
includeWakeFooter: true
|
|
81048
81584
|
});
|
|
81049
81585
|
if (producedEffect === false && beforeStatus === "running") {
|
|
81050
81586
|
this.log.info("agent:wake produced no effect (coalesced onto running agent)", {
|
|
@@ -81360,7 +81896,21 @@ var communityProxyRoutes = {
|
|
|
81360
81896
|
avatar: "/api/community/users/me/avatar",
|
|
81361
81897
|
marks: "/api/community/users/me/marks"
|
|
81362
81898
|
};
|
|
81899
|
+
var SCHEDULE_EVENTS_PROXY_PATH_RE = /^\/api\/community\/schedule\/events(?:\/[^/]+)?$/;
|
|
81900
|
+
function isCanonicalCommunityProxyPath(pathname) {
|
|
81901
|
+
return pathname === "/api/community/platform/feedback" || SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname) || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines|pages)(\/|$)/.test(pathname);
|
|
81902
|
+
}
|
|
81363
81903
|
function resolveProxyCapability(method, pathname) {
|
|
81904
|
+
if (/^\/api\/community\/pages\/[^/]+\/cover$/.test(pathname) && method === "PUT")
|
|
81905
|
+
return "attach";
|
|
81906
|
+
if (pathname === "/api/community/pages" && method === "GET")
|
|
81907
|
+
return "read";
|
|
81908
|
+
if (/^\/api\/community\/pages\/[^/]+$/.test(pathname) && method === "DELETE")
|
|
81909
|
+
return "send";
|
|
81910
|
+
if (pathname === "/api/community/pages" && method === "POST")
|
|
81911
|
+
return "attach";
|
|
81912
|
+
if (/^\/api\/community\/pages\/[^/]+\/operations$/.test(pathname) && method === "POST")
|
|
81913
|
+
return "send";
|
|
81364
81914
|
if (pathname === "/api/community/platform/feedback" && method === "POST")
|
|
81365
81915
|
return "send";
|
|
81366
81916
|
if (pathname.startsWith("/api/community/machines"))
|
|
@@ -81369,7 +81919,7 @@ function resolveProxyCapability(method, pathname) {
|
|
|
81369
81919
|
return "read";
|
|
81370
81920
|
if (pathname === "/api/community/bots/creation-requests" && method === "POST")
|
|
81371
81921
|
return "send";
|
|
81372
|
-
if (
|
|
81922
|
+
if (SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname)) {
|
|
81373
81923
|
return method === "GET" ? "read" : "send";
|
|
81374
81924
|
}
|
|
81375
81925
|
if ((method === "GET" || method === "PATCH") && pathname === communityProxyRoutes.profile || method === "POST" && pathname === communityProxyRoutes.avatar)
|
|
@@ -81472,6 +82022,7 @@ function propertyAuditMetadata(method, pathname, requestUrl) {
|
|
|
81472
82022
|
}
|
|
81473
82023
|
function resolveProxyRoute(pathname, method, requestUrl = pathname) {
|
|
81474
82024
|
return {
|
|
82025
|
+
canonicalCommunityDoor: isCanonicalCommunityProxyPath(pathname),
|
|
81475
82026
|
capability: resolveProxyCapability(method ?? "", pathname),
|
|
81476
82027
|
auditOperation: resolveProxyAuditOperation(pathname, method),
|
|
81477
82028
|
propertyMetadata: propertyAuditMetadata(method ?? "", pathname, requestUrl),
|
|
@@ -82172,8 +82723,7 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
82172
82723
|
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
82173
82724
|
return;
|
|
82174
82725
|
}
|
|
82175
|
-
|
|
82176
|
-
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
82726
|
+
if (pathname === "/api" || pathname.startsWith("/api/") && !route.canonicalCommunityDoor) {
|
|
82177
82727
|
res.writeHead(404, { "content-type": "application/json" });
|
|
82178
82728
|
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
82179
82729
|
req.resume();
|
|
@@ -83996,7 +84546,7 @@ class PiiStore {
|
|
|
83996
84546
|
}
|
|
83997
84547
|
|
|
83998
84548
|
// src/daemon/createDaemon.ts
|
|
83999
|
-
import { appendFileSync as appendFileSync2, mkdirSync as
|
|
84549
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync10 } from "node:fs";
|
|
84000
84550
|
|
|
84001
84551
|
// src/util/rotatingFileSink.ts
|
|
84002
84552
|
import {
|
|
@@ -86637,6 +87187,81 @@ function createDaemonAgentDriverHost(ctx, onRawLine, onRawStderr) {
|
|
|
86637
87187
|
};
|
|
86638
87188
|
}
|
|
86639
87189
|
|
|
87190
|
+
// src/drivers/alookPageGuide.ts
|
|
87191
|
+
import { mkdirSync as mkdirSync9, readFileSync as readFileSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
87192
|
+
import { join as join25 } from "node:path";
|
|
87193
|
+
var ALOOK_PAGE_GUIDE_FILENAME = "alook-page.md";
|
|
87194
|
+
var ALOOK_PAGE_GUIDE_CONTENT = [
|
|
87195
|
+
"# Alook Page Guide",
|
|
87196
|
+
"",
|
|
87197
|
+
"Use this guide whenever you create, preview, upload, share, edit, or delete an Alook Page.",
|
|
87198
|
+
"",
|
|
87199
|
+
"## Choosing the right surface",
|
|
87200
|
+
"",
|
|
87201
|
+
"| Surface | Use when | State & collaboration |",
|
|
87202
|
+
"|---|---|---|",
|
|
87203
|
+
"| Plain text / `.md` attachment | Plans, reviews, logs, summaries, code diffs | Read-only prose in chat |",
|
|
87204
|
+
"| Inline HTML (`[alook-html-preview](id)`) | One-off charts, diagrams, sequence flows, UI mockups, or client-only interactive snippets | **Ephemeral** — no persisted cloud state |",
|
|
87205
|
+
"| **Alook Page** | Living documents, decks, spreadsheets, whiteboards, design boards, dashboards, or custom apps that stay editable over time | **Persistent cloud state** — collaborative editing, reusable across channels |",
|
|
87206
|
+
"",
|
|
87207
|
+
"## Artifact types",
|
|
87208
|
+
"",
|
|
87209
|
+
"Pick a built-in collaborative editor whenever it fits; use `page` only when you need a custom HTML/CSS/JS app.",
|
|
87210
|
+
"",
|
|
87211
|
+
"| `type` | Purpose |",
|
|
87212
|
+
"|---|---|",
|
|
87213
|
+
"| `docs` | Multi-tab collaborative rich-text documents (specs, PRDs, briefs, meeting notes) |",
|
|
87214
|
+
"| `slides` | Collaborative slide decks and presentations |",
|
|
87215
|
+
"| `sheets` | Spreadsheets with formulas and tabular modeling |",
|
|
87216
|
+
"| `whiteboard` | Infinite-canvas whiteboards, architecture diagrams, brainstorming |",
|
|
87217
|
+
"| `design` | Vector and UI layout design boards |",
|
|
87218
|
+
"| `data` | Live data dashboards and interactive metric reports backed by datasets |",
|
|
87219
|
+
"| `motion` | Timeline motion graphics and short video compositions |",
|
|
87220
|
+
"| `design-system` | Brand and UI design systems (colors, typography, component tokens) |",
|
|
87221
|
+
"| `page` | Custom stateful multi-file HTML/CSS/JS interactive web app (requires root `.artifact.json` + `index.html`) |",
|
|
87222
|
+
"",
|
|
87223
|
+
"## CLI commands",
|
|
87224
|
+
"",
|
|
87225
|
+
"### Local authoring, visual check, and upload",
|
|
87226
|
+
"",
|
|
87227
|
+
"1. `$ALOOK_CLI page guide [--type <type>] [--ref <file>]` — ensure the shared local Open Artifact runtime (`~/.alook/page-runtime/`) and read the official `SKILL.md` / `reference/*.md` authoring spec for any of the 9 types. Always read the target type's guide before authoring a built-in artifact.",
|
|
87228
|
+
"2. `$ALOOK_CLI page local <command> [args...]` — run native local Open Artifact authoring and validation commands (`create`, `update`, `read`, `batch`, `write-db`, `read-db`, `check`, `generate`, `upload`, `info`) on your local artifact directory; forwards piped stdin (e.g. `- <<'EOF'`) and all upstream flags verbatim.",
|
|
87229
|
+
"3. `$ALOOK_CLI page preview --dir <dir> --out <img.png>` — render your local artifact directory (all 9 types) at 16:10, save a screenshot to `--out` for visual inspection before upload, and automatically stop the temporary browser and local server on exit.",
|
|
87230
|
+
"4. `$ALOOK_CLI page upload --dir <dir> [--cover <img-path>]` — validate and auto-zip the local directory (auto-detects built-in markers like `doc/doc.json`, `sheet/sheet.json`, `project/deck.json`, `db/board/meta.json` or root `.artifact.json`; generic `page` requires `.artifact.json` + `index.html`; auto-excludes `.git`, `node_modules`, `.DS_Store`, `_agent`; rejects symlinks; limits: 16 MiB compressed, 32 MiB unpacked, 2,000 files), capture its 16:10 homepage cover locally before any network call (or upload `--cover <img-path>`, PNG/JPEG/WebP, ≤ 2 MiB), and return its reusable `page_id`.",
|
|
87231
|
+
"",
|
|
87232
|
+
"### Sharing, listing, live editing, and deleting cloud Pages",
|
|
87233
|
+
"",
|
|
87234
|
+
"5. `$ALOOK_CLI message send --target <ref> --page <page_id> --remind-after <0|Nm|Nh> --stdin` — attach or forward an uploaded `page_id` across channels without re-uploading (all linked cards share one live cloud Page; reader comments return to the opening conversation).",
|
|
87235
|
+
"6. `$ALOOK_CLI page list [--limit <1..100>] [--cursor <cursor>]` — list Pages created by this bot (including unused uploads) with `total` and each Page's `messageCount`.",
|
|
87236
|
+
'7. `$ALOOK_CLI page --id <id> --stdin [--out <path>]` — read or live-edit an accessible cloud Page via JSON on stdin: `{"kind":"manifest"}`, `{"kind":"read","path":"..."}` (use `--out` to write locally), `{"kind":"write","writes":[{"path":"...","content":"<base64>","if_match":"<etag>"}]}` (use JSON `null` for `if_match` when creating a new file), `{"kind":"actions"}` (inspect native editor action schemas), or `{"kind":"action","name":"...","args":{...}}`.',
|
|
87237
|
+
"8. `$ALOOK_CLI page delete --id <id>` — permanently delete a Page created by this bot, destroy its cloud data and cover, and unlink all messages (deleting a message removes only that link).",
|
|
87238
|
+
"",
|
|
87239
|
+
"## Authoring rules & safe collaboration",
|
|
87240
|
+
"",
|
|
87241
|
+
"- **Read the type guide first**: never guess schemas for built-in types; fetch `SKILL.md` and `reference/*.md` via `page guide`.",
|
|
87242
|
+
"- **Use native tools for structured types**: `docs` and `sheets` must be authored through `page local` commands (never hand-edit `doc/doc.json` or `sheet/edits.jsonl`), and `whiteboard`, `data`, and `motion` use `page local write-db` + `page local check`.",
|
|
87243
|
+
"- **Visually verify before upload**: run `page preview --dir <dir> --out preview.png` and inspect the rendered image to confirm layout, legibility, and calculated values before running `page upload`.",
|
|
87244
|
+
'- **Edit safely alongside humans**: for built-in editors, query `{"kind":"actions"}` and prefer native editor actions over raw file overwrites. For `{"kind":"write"}`, always `read` first and pass `if_match` with the returned etag so concurrent human edits are never clobbered.',
|
|
87245
|
+
"- **Comments**: reader comments posted from a Page return as normal messages in the exact conversation where the reader opened the card, mentioning that entry message's author bot.",
|
|
87246
|
+
""
|
|
87247
|
+
].join(`
|
|
87248
|
+
`);
|
|
87249
|
+
function syncAlookPageGuide(workingDirectory) {
|
|
87250
|
+
if (!workingDirectory)
|
|
87251
|
+
return false;
|
|
87252
|
+
mkdirSync9(workingDirectory, { recursive: true });
|
|
87253
|
+
const target2 = join25(workingDirectory, ALOOK_PAGE_GUIDE_FILENAME);
|
|
87254
|
+
try {
|
|
87255
|
+
if (readFileSync8(target2, "utf8") === ALOOK_PAGE_GUIDE_CONTENT)
|
|
87256
|
+
return false;
|
|
87257
|
+
} catch (error62) {
|
|
87258
|
+
if (error62?.code !== "ENOENT")
|
|
87259
|
+
throw error62;
|
|
87260
|
+
}
|
|
87261
|
+
writeFileSync11(target2, ALOOK_PAGE_GUIDE_CONTENT, "utf8");
|
|
87262
|
+
return true;
|
|
87263
|
+
}
|
|
87264
|
+
|
|
86640
87265
|
// src/daemon/daemonSelfSleep.ts
|
|
86641
87266
|
var DAEMON_SELF_SLEEP_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1000;
|
|
86642
87267
|
var systemClock = {
|
|
@@ -86711,7 +87336,7 @@ class DaemonSelfSleepScheduler {
|
|
|
86711
87336
|
|
|
86712
87337
|
// src/telemetry/dailyTokenUsage.ts
|
|
86713
87338
|
import { chmod, mkdir, open as open3, readFile as readFile4, rename, rm } from "node:fs/promises";
|
|
86714
|
-
import { dirname as dirname6, join as
|
|
87339
|
+
import { dirname as dirname6, join as join26 } from "node:path";
|
|
86715
87340
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
86716
87341
|
var TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
86717
87342
|
var TOKEN_USAGE_RECOVERY_DAYS = 2;
|
|
@@ -86772,7 +87397,7 @@ class DailyTokenUsageStore {
|
|
|
86772
87397
|
this.now = now;
|
|
86773
87398
|
this.resolveTimeZone = typeof timeZone === "string" ? () => timeZone : timeZone;
|
|
86774
87399
|
this.timeZone;
|
|
86775
|
-
this.filePath =
|
|
87400
|
+
this.filePath = join26(workingDirectoryBase, ".telemetry", "daily-token-usage.json");
|
|
86776
87401
|
}
|
|
86777
87402
|
get timeZone() {
|
|
86778
87403
|
const timeZone = this.resolveTimeZone();
|
|
@@ -87091,7 +87716,7 @@ function createRuntimeRawLineTap(args) {
|
|
|
87091
87716
|
let sink = sinks.get(agentId);
|
|
87092
87717
|
if (!sink) {
|
|
87093
87718
|
try {
|
|
87094
|
-
|
|
87719
|
+
mkdirSync10(traceDir, { recursive: true });
|
|
87095
87720
|
} catch (error62) {
|
|
87096
87721
|
warnOnce(agentId, path17, "mkdir", error62);
|
|
87097
87722
|
}
|
|
@@ -87120,6 +87745,7 @@ function emitImplicitTypingStopOnSend(args) {
|
|
|
87120
87745
|
}
|
|
87121
87746
|
function createBuiltinDaemonSessionFactory(onRuntimeRawLine, onRuntimeStderr) {
|
|
87122
87747
|
return async ({ ctx, runtimeConfig }) => {
|
|
87748
|
+
syncAlookPageGuide(ctx.workingDirectory);
|
|
87123
87749
|
const selected = toAgentBackendSelection(runtimeConfig);
|
|
87124
87750
|
const sdk = createAgentDriverSdk({
|
|
87125
87751
|
host: createDaemonAgentDriverHost(ctx, onRuntimeRawLine?.bind(null, ctx.agentId), onRuntimeStderr?.bind(null, ctx.agentId))
|
|
@@ -87571,7 +88197,7 @@ async function createDaemon(opts) {
|
|
|
87571
88197
|
if (!opts.fsmTraceDir)
|
|
87572
88198
|
return { source: null };
|
|
87573
88199
|
try {
|
|
87574
|
-
|
|
88200
|
+
mkdirSync10(opts.fsmTraceDir, { recursive: true });
|
|
87575
88201
|
} catch {}
|
|
87576
88202
|
const source = createRotatingFileSink(`${opts.fsmTraceDir}/fsm-trace.jsonl`, DEFAULT_TRACE_FILE_MAX_BYTES);
|
|
87577
88203
|
const sampler = createTraceSampler((rec) => source.write(JSON.stringify(rec)));
|