@alook/daemon 0.1.70 → 0.1.72
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/cli/index.js +1058 -489
- package/dist/index.js +948 -438
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -13521,13 +13521,13 @@ var require_sourcemap_codec_umd = __commonJS((exports, module) => {
|
|
|
13521
13521
|
});
|
|
13522
13522
|
});
|
|
13523
13523
|
|
|
13524
|
-
// ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.
|
|
13524
|
+
// ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.3/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
|
|
13525
13525
|
var require_resolve_uri_umd = __commonJS((exports, module) => {
|
|
13526
13526
|
(function(global, factory) {
|
|
13527
13527
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.resolveURI = factory());
|
|
13528
13528
|
})(exports, function() {
|
|
13529
13529
|
const schemeRegex = /^[\w+.-]+:\/\//;
|
|
13530
|
-
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
13530
|
+
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
13531
13531
|
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
13532
13532
|
function isAbsoluteUrl(input2) {
|
|
13533
13533
|
return schemeRegex.test(input2);
|
|
@@ -24216,9 +24216,11 @@ function parseNativeExecution(data) {
|
|
|
24216
24216
|
|
|
24217
24217
|
class NativeExecutionReader {
|
|
24218
24218
|
readRows;
|
|
24219
|
+
continuations;
|
|
24219
24220
|
path;
|
|
24220
|
-
constructor(home, sessionId, readRows = queryExecutionRows) {
|
|
24221
|
+
constructor(home, sessionId, readRows = queryExecutionRows, continuations = false) {
|
|
24221
24222
|
this.readRows = readRows;
|
|
24223
|
+
this.continuations = continuations;
|
|
24222
24224
|
if (!/^[a-zA-Z0-9_-]{1,100}$/.test(sessionId))
|
|
24223
24225
|
throw new Error("Invalid native execution session identity");
|
|
24224
24226
|
this.path = join4(home, "antigravity-cli", "conversations", `${sessionId}.db`);
|
|
@@ -24234,20 +24236,28 @@ class NativeExecutionReader {
|
|
|
24234
24236
|
return { index: row.idx, executionId: execution.executionId, lastStepIndex: execution.lastStepIndex };
|
|
24235
24237
|
}
|
|
24236
24238
|
async terminal(checkpoint) {
|
|
24237
|
-
const
|
|
24238
|
-
|
|
24239
|
+
const max = this.continuations ? 32 : 1;
|
|
24240
|
+
const rows = await this.readRows(this.path, checkpoint.index, checkpoint.lastStepIndex, undefined, max + 1);
|
|
24241
|
+
if (!rows.length || rows.length > max)
|
|
24239
24242
|
throw new Error("Native execution terminal unavailable or ambiguous");
|
|
24240
|
-
|
|
24241
|
-
const
|
|
24242
|
-
|
|
24243
|
-
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24243
|
+
let lastStep = checkpoint.lastStepIndex;
|
|
24244
|
+
const identities = new Set([checkpoint.executionId]);
|
|
24245
|
+
let outcome = "success";
|
|
24246
|
+
for (let index = 0;index < rows.length; index++) {
|
|
24247
|
+
const row = this.validate(rows[index]);
|
|
24248
|
+
const execution = parseNativeExecution(Buffer.from(row.data, "hex"));
|
|
24249
|
+
if (row.has_children !== 0)
|
|
24250
|
+
throw new Error("Native executor subtrajectory ownership cannot be verified");
|
|
24251
|
+
if (row.idx !== checkpoint.index + index + 1 || identities.has(execution.executionId) || this.continuations && execution.lastStepIndex <= lastStep)
|
|
24252
|
+
throw new Error("Native execution terminal does not belong to the new root");
|
|
24253
|
+
identities.add(execution.executionId);
|
|
24254
|
+
lastStep = execution.lastStepIndex;
|
|
24255
|
+
if (execution.hasError || execution.reason !== 2 && execution.reason !== 4)
|
|
24256
|
+
outcome = "failed";
|
|
24257
|
+
else if (execution.reason === 2 && outcome !== "failed")
|
|
24258
|
+
outcome = "interrupted";
|
|
24259
|
+
}
|
|
24260
|
+
return outcome;
|
|
24251
24261
|
}
|
|
24252
24262
|
validate(row) {
|
|
24253
24263
|
if (!Number.isSafeInteger(row.idx) || row.idx < 0 || !/^(?:[a-f0-9]{2})+$/i.test(row.data) || row.data.length > 2 * 1024 * 1024)
|
|
@@ -24269,10 +24279,12 @@ async function openNativeExecutionDatabase(path4, loadBuiltin = async () => {
|
|
|
24269
24279
|
}
|
|
24270
24280
|
return new sqlite.DatabaseSync(path4, { readOnly: true });
|
|
24271
24281
|
}
|
|
24272
|
-
async function queryExecutionRows(path4, after, afterStep = -1, openDatabase = openNativeExecutionDatabase) {
|
|
24282
|
+
async function queryExecutionRows(path4, after, afterStep = -1, openDatabase = openNativeExecutionDatabase, maxRows = 2) {
|
|
24273
24283
|
if (after !== undefined && (!Number.isSafeInteger(after) || after < -1) || !Number.isSafeInteger(afterStep) || afterStep < -1)
|
|
24274
24284
|
throw new Error("Invalid native execution cursor");
|
|
24275
|
-
|
|
24285
|
+
if (!Number.isSafeInteger(maxRows) || maxRows < 1 || maxRows > 33)
|
|
24286
|
+
throw new Error("Invalid native execution read limit");
|
|
24287
|
+
const query = `SELECT idx,hex(substr(data,1,1048577)) AS data,${after === undefined ? "(SELECT EXISTS(SELECT 1 FROM steps WHERE idx<0 AND has_subtrajectory=1))" : `(SELECT EXISTS(SELECT 1 FROM steps WHERE idx>${afterStep} AND has_subtrajectory=1))`} AS has_children FROM executor_metadata ${after === undefined ? "ORDER BY idx DESC LIMIT 1" : `WHERE idx>${after} ORDER BY idx LIMIT ${maxRows}`}`;
|
|
24276
24288
|
const db = await openDatabase(path4);
|
|
24277
24289
|
try {
|
|
24278
24290
|
return db.prepare(query).all();
|
|
@@ -24281,6 +24293,37 @@ async function queryExecutionRows(path4, after, afterStep = -1, openDatabase = o
|
|
|
24281
24293
|
}
|
|
24282
24294
|
}
|
|
24283
24295
|
|
|
24296
|
+
class NativeSessionActivityReader {
|
|
24297
|
+
sessionId;
|
|
24298
|
+
version;
|
|
24299
|
+
openDatabase;
|
|
24300
|
+
path;
|
|
24301
|
+
constructor(home, sessionId, version, openDatabase = openNativeExecutionDatabase) {
|
|
24302
|
+
this.sessionId = sessionId;
|
|
24303
|
+
this.version = version;
|
|
24304
|
+
this.openDatabase = openDatabase;
|
|
24305
|
+
if (!/^[a-zA-Z0-9_-]{1,100}$/.test(sessionId))
|
|
24306
|
+
throw new Error("Invalid native activity session identity");
|
|
24307
|
+
this.path = join4(home, "antigravity-cli", "conversation_summaries.db");
|
|
24308
|
+
}
|
|
24309
|
+
async activity() {
|
|
24310
|
+
if (this.version !== "1.5.16")
|
|
24311
|
+
return "unknown";
|
|
24312
|
+
const db = await this.openDatabase(this.path);
|
|
24313
|
+
try {
|
|
24314
|
+
const rows = db.prepare("SELECT status,not_fully_idle FROM conversation_summaries WHERE conversation_id = ? LIMIT 1").all(this.sessionId);
|
|
24315
|
+
const row = rows[0];
|
|
24316
|
+
if (!row || row.not_fully_idle !== 0 && row.not_fully_idle !== 1)
|
|
24317
|
+
return "unknown";
|
|
24318
|
+
if (row.status === "CASCADE_RUN_STATUS_RUNNING")
|
|
24319
|
+
return "running";
|
|
24320
|
+
return row.status === "CASCADE_RUN_STATUS_IDLE" ? row.not_fully_idle ? "running" : "idle" : "unknown";
|
|
24321
|
+
} finally {
|
|
24322
|
+
db.close();
|
|
24323
|
+
}
|
|
24324
|
+
}
|
|
24325
|
+
}
|
|
24326
|
+
|
|
24284
24327
|
// agent-driver/dist/internal/model-observation.js
|
|
24285
24328
|
function id(value) {
|
|
24286
24329
|
if (typeof value !== "string")
|
|
@@ -24498,6 +24541,18 @@ class AgyAcpLane {
|
|
|
24498
24541
|
events = new EventEmitter;
|
|
24499
24542
|
pending = new Map;
|
|
24500
24543
|
toolCalls = new Map;
|
|
24544
|
+
completedTools = new Set;
|
|
24545
|
+
unownedContent = false;
|
|
24546
|
+
activityReader;
|
|
24547
|
+
activityRead;
|
|
24548
|
+
activityTimer;
|
|
24549
|
+
nativeActivity = "unknown";
|
|
24550
|
+
publishedActivity;
|
|
24551
|
+
activityRevision = 0;
|
|
24552
|
+
nativeVersion = "";
|
|
24553
|
+
contentOwner;
|
|
24554
|
+
executionIsolated = true;
|
|
24555
|
+
nativeClose = false;
|
|
24501
24556
|
process = null;
|
|
24502
24557
|
requestSequence = 0;
|
|
24503
24558
|
started = false;
|
|
@@ -24573,10 +24628,13 @@ class AgyAcpLane {
|
|
|
24573
24628
|
const sessionId = this.sessionId;
|
|
24574
24629
|
if (!sessionId)
|
|
24575
24630
|
throw new Error("Agy ACP handshake completed without a session id");
|
|
24576
|
-
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId);
|
|
24631
|
+
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, this.nativeVersion === "1.5.16");
|
|
24577
24632
|
this.processActivated = true;
|
|
24578
24633
|
this.ready = true;
|
|
24579
24634
|
this.events.emit("runtime_event", { kind: "session_init", sessionId, acquisition: { status: input.sessionId ? "resumed" : "created", evidence: "native_api" } });
|
|
24635
|
+
this.activityReader = this.options.activityReader ?? new NativeSessionActivityReader(this.stateHome, sessionId, this.nativeVersion);
|
|
24636
|
+
await this.refreshActivity();
|
|
24637
|
+
this.scheduleActivity();
|
|
24580
24638
|
const admission = await this.admitRoot(input.text, input.inputs);
|
|
24581
24639
|
if (!admission.ok)
|
|
24582
24640
|
throw new AgyAcpIncompatibleError(admission.error ?? "Native execution state unavailable");
|
|
@@ -24621,6 +24679,8 @@ class AgyAcpLane {
|
|
|
24621
24679
|
stop(input = {}) {
|
|
24622
24680
|
this.requestedStopReason ??= input.reason ?? "requested_stop";
|
|
24623
24681
|
this.ready = false;
|
|
24682
|
+
if (this.activityTimer)
|
|
24683
|
+
clearTimeout(this.activityTimer);
|
|
24624
24684
|
this.currentPromptRequestId = null;
|
|
24625
24685
|
this.terminalOwner = null;
|
|
24626
24686
|
this.toolCalls.clear();
|
|
@@ -24638,20 +24698,29 @@ class AgyAcpLane {
|
|
|
24638
24698
|
return this.stopPromise;
|
|
24639
24699
|
}
|
|
24640
24700
|
async stopPhysicalOnce(input) {
|
|
24701
|
+
const deadline = Date.now() + (input.forceAfterMs ?? SESSION_STOP_GRACE_MS);
|
|
24641
24702
|
await this.spawnPromise?.catch(() => {
|
|
24642
24703
|
return;
|
|
24643
24704
|
});
|
|
24644
24705
|
const proc = this.process;
|
|
24645
24706
|
if (!proc)
|
|
24646
24707
|
return;
|
|
24708
|
+
let closeAcknowledged = false;
|
|
24709
|
+
if (this.nativeClose && this.sessionId && !this.isClosed() && deadline > Date.now()) {
|
|
24710
|
+
try {
|
|
24711
|
+
await this.request("session/close", { sessionId: this.sessionId }, Math.max(1, deadline - Date.now())).promise;
|
|
24712
|
+
closeAcknowledged = true;
|
|
24713
|
+
} catch {}
|
|
24714
|
+
}
|
|
24647
24715
|
if (proc.pid) {
|
|
24648
|
-
await killProcessTree(proc.pid, { graceMs:
|
|
24716
|
+
await killProcessTree(proc.pid, { graceMs: closeAcknowledged ? 0 : Math.max(0, deadline - Date.now()) });
|
|
24649
24717
|
} else if (!this.isClosed()) {
|
|
24650
24718
|
proc.kill(input.signal ?? "SIGTERM");
|
|
24651
24719
|
}
|
|
24652
24720
|
await this.executionRead?.catch(() => {
|
|
24653
24721
|
return;
|
|
24654
24722
|
});
|
|
24723
|
+
await this.activityRead;
|
|
24655
24724
|
}
|
|
24656
24725
|
async handshake(ctx) {
|
|
24657
24726
|
const initialize = record2(await this.call("initialize", {
|
|
@@ -24666,6 +24735,7 @@ class AgyAcpLane {
|
|
|
24666
24735
|
throw new AgyAcpIncompatibleError("Installed Agy ACP does not support protocol version 1");
|
|
24667
24736
|
}
|
|
24668
24737
|
const capabilities = record2(initialize.agentCapabilities);
|
|
24738
|
+
this.nativeClose = record2(record2(capabilities?.sessionCapabilities)?.close) !== null;
|
|
24669
24739
|
if (capabilities?.loadSession !== true) {
|
|
24670
24740
|
throw new AgyAcpIncompatibleError("Installed Agy ACP does not support persistent session loading");
|
|
24671
24741
|
}
|
|
@@ -24673,6 +24743,7 @@ class AgyAcpLane {
|
|
|
24673
24743
|
throw new AgyAcpIncompatibleError("Expected the native Antigravity CLI ACP server");
|
|
24674
24744
|
}
|
|
24675
24745
|
const version = record2(initialize.agentInfo)?.version;
|
|
24746
|
+
this.nativeVersion = typeof version === "string" ? version : "";
|
|
24676
24747
|
this.usageProfile = version === "1.4.12" ? { inputIncludesCache: true, outputIncludesReasoning: false } : version === "1.5.9" ? { inputIncludesCache: false, outputIncludesReasoning: true } : undefined;
|
|
24677
24748
|
if (!record2(record2(initialize.agentCapabilities)?.sessionCapabilities)?.resume) {
|
|
24678
24749
|
throw new AgyAcpIncompatibleError("Antigravity CLI ACP does not support native session resume");
|
|
@@ -24879,6 +24950,7 @@ class AgyAcpLane {
|
|
|
24879
24950
|
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
24880
24951
|
return { ok: false, reason: "closed" };
|
|
24881
24952
|
this.executionCheckpoint = checkpoint;
|
|
24953
|
+
this.executionIsolated = !this.unownedContent && !this.hasPendingTools();
|
|
24882
24954
|
return this.admitPrompt(text, "prompt", inputs);
|
|
24883
24955
|
} catch {
|
|
24884
24956
|
return { ok: false, reason: "runtime_error", error: "Antigravity CLI native execution state cannot be verified. A readable native conversation database and the packaged SQLite runtime are required." };
|
|
@@ -24905,7 +24977,7 @@ class AgyAcpLane {
|
|
|
24905
24977
|
this.terminalOwner = prompt.receipt;
|
|
24906
24978
|
this.currentPromptRequestId = requestId;
|
|
24907
24979
|
if (delivery === "prompt") {
|
|
24908
|
-
this.
|
|
24980
|
+
this.contentOwner = !this.unownedContent && !this.hasPendingTools() ? prompt.receipt : undefined;
|
|
24909
24981
|
this.promptOutcomes.clear();
|
|
24910
24982
|
this.observedPrompts.clear();
|
|
24911
24983
|
this.loopStartedAt = new Date().toISOString();
|
|
@@ -24972,13 +25044,22 @@ class AgyAcpLane {
|
|
|
24972
25044
|
const read = this.executionReader.terminal(this.executionCheckpoint);
|
|
24973
25045
|
this.executionRead = read;
|
|
24974
25046
|
nativeOutcome = await read;
|
|
25047
|
+
if (!this.executionIsolated)
|
|
25048
|
+
nativeOutcome = "unknown";
|
|
24975
25049
|
} catch {
|
|
24976
|
-
|
|
25050
|
+
if (this.executionIsolated)
|
|
25051
|
+
verificationError = new Error("Antigravity CLI native execution terminal could not be verified");
|
|
25052
|
+
else
|
|
25053
|
+
nativeOutcome = "unknown";
|
|
24977
25054
|
} finally {
|
|
24978
25055
|
this.executionRead = undefined;
|
|
24979
25056
|
}
|
|
24980
25057
|
if (this.terminalOwner !== owner || this.requestedStopReason || this.processTerminal)
|
|
24981
25058
|
return;
|
|
25059
|
+
if (this.hasPendingTools())
|
|
25060
|
+
this.unownedContent = true;
|
|
25061
|
+
this.observeOutsideWork();
|
|
25062
|
+
this.refreshActivity();
|
|
24982
25063
|
this.finishing = false;
|
|
24983
25064
|
const outcomes = [...this.promptOutcomes].sort(([a], [b]) => b - a);
|
|
24984
25065
|
let latest = outcomes.find(([, outcome]) => outcome.error)?.[1] ?? outcomes[0]?.[1];
|
|
@@ -25011,7 +25092,7 @@ class AgyAcpLane {
|
|
|
25011
25092
|
this.usage.reset();
|
|
25012
25093
|
this.currentPromptRequestId = null;
|
|
25013
25094
|
this.terminalOwner = null;
|
|
25014
|
-
this.
|
|
25095
|
+
this.contentOwner = undefined;
|
|
25015
25096
|
this.promptOutcomes.clear();
|
|
25016
25097
|
this.observedPrompts.clear();
|
|
25017
25098
|
if (!latest) {
|
|
@@ -25023,7 +25104,7 @@ class AgyAcpLane {
|
|
|
25023
25104
|
kind: "turn_end",
|
|
25024
25105
|
sessionId: this.sessionId ?? undefined,
|
|
25025
25106
|
turnOwner: terminalOwner,
|
|
25026
|
-
outcome: latest?.stopReason === "cancelled" ? "interrupted" : latest?.stopReason === "end_turn" ? "success" : "failed",
|
|
25107
|
+
outcome: latest?.stopReason === "cancelled" ? "interrupted" : latest?.stopReason === "end_turn" ? nativeOutcome === "unknown" ? "unknown" : "success" : "failed",
|
|
25027
25108
|
stopReason: latest?.stopReason,
|
|
25028
25109
|
...latest?.stopReason === "cancelled" ? { pendingContent: "discard" } : {}
|
|
25029
25110
|
});
|
|
@@ -25255,24 +25336,38 @@ class AgyAcpLane {
|
|
|
25255
25336
|
this.rememberConfig(configuration, true);
|
|
25256
25337
|
return;
|
|
25257
25338
|
}
|
|
25258
|
-
if (!this.ready || this.
|
|
25259
|
-
this.diagnostic("warning", "Agy ACP emitted a session update without an active prompt");
|
|
25339
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25260
25340
|
return;
|
|
25261
|
-
}
|
|
25262
25341
|
const update = record2(payload.update) ?? {};
|
|
25263
25342
|
const updateType = update?.sessionUpdate;
|
|
25264
25343
|
switch (updateType) {
|
|
25265
25344
|
case "agent_message_chunk": {
|
|
25266
25345
|
const content = record2(update.content);
|
|
25267
25346
|
if (content?.type === "text" && typeof content.text === "string") {
|
|
25268
|
-
this.
|
|
25347
|
+
if (!this.contentOwner || this.contentOwner !== this.terminalOwner) {
|
|
25348
|
+
this.unownedContent = true;
|
|
25349
|
+
this.observeOutsideWork();
|
|
25350
|
+
}
|
|
25351
|
+
this.events.emit("runtime_event", {
|
|
25352
|
+
kind: "assistant_message_delta",
|
|
25353
|
+
text: content.text,
|
|
25354
|
+
...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
|
|
25355
|
+
});
|
|
25269
25356
|
}
|
|
25270
25357
|
return;
|
|
25271
25358
|
}
|
|
25272
25359
|
case "agent_thought_chunk": {
|
|
25273
25360
|
const content = record2(update.content);
|
|
25274
25361
|
if (content?.type === "text" && typeof content.text === "string") {
|
|
25275
|
-
this.
|
|
25362
|
+
if (!this.contentOwner || this.contentOwner !== this.terminalOwner) {
|
|
25363
|
+
this.unownedContent = true;
|
|
25364
|
+
this.observeOutsideWork();
|
|
25365
|
+
}
|
|
25366
|
+
this.events.emit("runtime_event", {
|
|
25367
|
+
kind: "assistant_reasoning_delta",
|
|
25368
|
+
text: content.text,
|
|
25369
|
+
...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
|
|
25370
|
+
});
|
|
25276
25371
|
}
|
|
25277
25372
|
return;
|
|
25278
25373
|
}
|
|
@@ -25296,56 +25391,67 @@ class AgyAcpLane {
|
|
|
25296
25391
|
this.diagnostic("warning", "Agy ACP emitted a malformed tool_call update");
|
|
25297
25392
|
return;
|
|
25298
25393
|
}
|
|
25299
|
-
if (
|
|
25300
|
-
|
|
25301
|
-
|
|
25394
|
+
if (this.completedTools.has(update.toolCallId))
|
|
25395
|
+
return;
|
|
25396
|
+
let tool = this.toolCalls.get(update.toolCallId);
|
|
25397
|
+
if (!tool) {
|
|
25398
|
+
tool = {
|
|
25399
|
+
name: typeof update.name === "string" ? update.name : update.title,
|
|
25400
|
+
owner: this.contentOwner
|
|
25401
|
+
};
|
|
25402
|
+
this.toolCalls.set(update.toolCallId, tool);
|
|
25302
25403
|
this.events.emit("runtime_event", {
|
|
25303
25404
|
kind: "tool_call",
|
|
25304
25405
|
callId: update.toolCallId,
|
|
25305
|
-
name,
|
|
25306
|
-
input: update.rawInput
|
|
25307
|
-
|
|
25308
|
-
}
|
|
25309
|
-
if ((update.status === "completed" || update.status === "failed") && this.toolCalls.get(update.toolCallId) !== null) {
|
|
25310
|
-
const name = this.toolCalls.get(update.toolCallId) ?? update.title;
|
|
25311
|
-
this.toolCalls.set(update.toolCallId, null);
|
|
25312
|
-
this.events.emit("runtime_event", {
|
|
25313
|
-
kind: "tool_output",
|
|
25314
|
-
callId: update.toolCallId,
|
|
25315
|
-
name,
|
|
25316
|
-
outcome: update.status === "failed" ? "failed" : "success",
|
|
25317
|
-
output: update.rawOutput
|
|
25406
|
+
name: tool.name,
|
|
25407
|
+
input: update.rawInput,
|
|
25408
|
+
...tool.owner && tool.owner === this.terminalOwner ? {} : { attribution: { scope: "session" } }
|
|
25318
25409
|
});
|
|
25319
25410
|
}
|
|
25411
|
+
this.observeOutsideWork();
|
|
25412
|
+
if (update.status === "completed" || update.status === "failed")
|
|
25413
|
+
this.finishTool(update, tool);
|
|
25320
25414
|
return;
|
|
25321
25415
|
}
|
|
25322
25416
|
case "tool_call_update": {
|
|
25323
|
-
if (typeof update.toolCallId
|
|
25324
|
-
|
|
25325
|
-
|
|
25326
|
-
|
|
25327
|
-
|
|
25328
|
-
|
|
25329
|
-
|
|
25330
|
-
callId: update.toolCallId,
|
|
25331
|
-
outcome: update.status === "failed" ? "failed" : "success",
|
|
25332
|
-
output: update.rawOutput,
|
|
25333
|
-
name
|
|
25334
|
-
});
|
|
25335
|
-
}
|
|
25417
|
+
if (typeof update.toolCallId !== "string")
|
|
25418
|
+
return;
|
|
25419
|
+
const tool = this.toolCalls.get(update.toolCallId);
|
|
25420
|
+
if (!tool)
|
|
25421
|
+
return;
|
|
25422
|
+
if (update.status === "completed" || update.status === "failed")
|
|
25423
|
+
this.finishTool(update, tool);
|
|
25336
25424
|
return;
|
|
25337
25425
|
}
|
|
25338
25426
|
case "plan":
|
|
25339
25427
|
this.events.emit("runtime_event", {
|
|
25340
25428
|
kind: "internal_progress",
|
|
25341
25429
|
source: "agy.acp",
|
|
25342
|
-
itemType: "plan"
|
|
25430
|
+
itemType: "plan",
|
|
25431
|
+
...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
|
|
25343
25432
|
});
|
|
25344
25433
|
return;
|
|
25345
25434
|
default:
|
|
25346
25435
|
this.diagnostic("warning", `Unsupported Agy ACP session update: ${safeLabel(updateType)}`);
|
|
25347
25436
|
}
|
|
25348
25437
|
}
|
|
25438
|
+
finishTool(update, tool) {
|
|
25439
|
+
this.toolCalls.delete(update.toolCallId);
|
|
25440
|
+
this.completedTools.add(update.toolCallId);
|
|
25441
|
+
if (this.completedTools.size > 4096)
|
|
25442
|
+
this.completedTools.delete(this.completedTools.values().next().value);
|
|
25443
|
+
if (!tool.owner || tool.owner !== this.terminalOwner)
|
|
25444
|
+
this.unownedContent = true;
|
|
25445
|
+
this.observeOutsideWork();
|
|
25446
|
+
this.events.emit("runtime_event", {
|
|
25447
|
+
kind: "tool_output",
|
|
25448
|
+
callId: update.toolCallId,
|
|
25449
|
+
name: tool.name,
|
|
25450
|
+
outcome: update.status === "failed" ? "failed" : "success",
|
|
25451
|
+
output: update.rawOutput ?? update.content,
|
|
25452
|
+
...tool.owner && tool.owner === this.terminalOwner ? {} : { attribution: { scope: "session" } }
|
|
25453
|
+
});
|
|
25454
|
+
}
|
|
25349
25455
|
diagnostic(severity, message) {
|
|
25350
25456
|
this.events.emit("runtime_event", {
|
|
25351
25457
|
kind: "runtime_diagnostic",
|
|
@@ -25354,6 +25460,58 @@ class AgyAcpLane {
|
|
|
25354
25460
|
message
|
|
25355
25461
|
});
|
|
25356
25462
|
}
|
|
25463
|
+
hasPendingTools() {
|
|
25464
|
+
return this.toolCalls.size > 0;
|
|
25465
|
+
}
|
|
25466
|
+
publishActivity() {
|
|
25467
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25468
|
+
return;
|
|
25469
|
+
const status = this.hasPendingTools() ? "running" : this.nativeActivity;
|
|
25470
|
+
if (status === this.publishedActivity)
|
|
25471
|
+
return;
|
|
25472
|
+
this.publishedActivity = status;
|
|
25473
|
+
this.events.emit("runtime_event", { kind: "session_activity", observation: { status, source: "agy.native" } });
|
|
25474
|
+
}
|
|
25475
|
+
observeOutsideWork() {
|
|
25476
|
+
this.activityRevision += 1;
|
|
25477
|
+
this.nativeActivity = "unknown";
|
|
25478
|
+
this.publishActivity();
|
|
25479
|
+
}
|
|
25480
|
+
refreshActivity() {
|
|
25481
|
+
if (this.activityRead)
|
|
25482
|
+
return this.activityRead;
|
|
25483
|
+
if (!this.ready || !this.activityReader || this.requestedStopReason || this.processTerminal)
|
|
25484
|
+
return Promise.resolve();
|
|
25485
|
+
const revision = this.activityRevision;
|
|
25486
|
+
const reading = (async () => {
|
|
25487
|
+
let status = "unknown";
|
|
25488
|
+
try {
|
|
25489
|
+
status = await this.activityReader.activity();
|
|
25490
|
+
} catch {}
|
|
25491
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25492
|
+
return;
|
|
25493
|
+
if (revision === this.activityRevision)
|
|
25494
|
+
this.nativeActivity = status;
|
|
25495
|
+
if (status === "running" && this.currentPromptRequestId === null)
|
|
25496
|
+
this.unownedContent = true;
|
|
25497
|
+
this.publishActivity();
|
|
25498
|
+
})();
|
|
25499
|
+
this.activityRead = reading;
|
|
25500
|
+
reading.finally(() => {
|
|
25501
|
+
if (this.activityRead === reading)
|
|
25502
|
+
this.activityRead = undefined;
|
|
25503
|
+
});
|
|
25504
|
+
return reading;
|
|
25505
|
+
}
|
|
25506
|
+
scheduleActivity() {
|
|
25507
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25508
|
+
return;
|
|
25509
|
+
this.activityTimer = setTimeout(() => {
|
|
25510
|
+
this.activityTimer = undefined;
|
|
25511
|
+
this.refreshActivity().then(() => this.scheduleActivity());
|
|
25512
|
+
}, this.options.activityPollMs ?? 1000);
|
|
25513
|
+
this.activityTimer.unref?.();
|
|
25514
|
+
}
|
|
25357
25515
|
protocolFailure(message) {
|
|
25358
25516
|
const error = new Error(message);
|
|
25359
25517
|
this.rejectAllPending(error);
|
|
@@ -35356,6 +35514,10 @@ class LogicalAgentSession {
|
|
|
35356
35514
|
events;
|
|
35357
35515
|
closed;
|
|
35358
35516
|
state = "new";
|
|
35517
|
+
activity;
|
|
35518
|
+
sessionMessage = emptySemanticAssembler();
|
|
35519
|
+
sessionReasoning = emptySemanticAssembler();
|
|
35520
|
+
sessionContentTimer;
|
|
35359
35521
|
backendSessionId;
|
|
35360
35522
|
acquisition;
|
|
35361
35523
|
configuration;
|
|
@@ -35556,11 +35718,12 @@ class LogicalAgentSession {
|
|
|
35556
35718
|
}
|
|
35557
35719
|
snapshot() {
|
|
35558
35720
|
return {
|
|
35721
|
+
...this.activity ? { activity: this.activity } : {},
|
|
35559
35722
|
...this.acquisition ? { acquisition: this.acquisition } : {},
|
|
35560
35723
|
...this.configuration ? { configuration: this.configuration } : {},
|
|
35561
35724
|
...this.observedModel ? { observedModel: { ...this.observedModel } } : {},
|
|
35562
35725
|
sessionInstanceId: this.sessionInstanceId,
|
|
35563
|
-
state: this.state,
|
|
35726
|
+
state: this.state === "idle" && this.activity && this.activity.status === "running" ? "working" : this.state,
|
|
35564
35727
|
backendSessionId: this.backendSessionId,
|
|
35565
35728
|
activeTurn: this.activeTurn ? { turnId: this.activeTurn.turnId, commandIds: this.activeTurn.commandIds } : undefined,
|
|
35566
35729
|
queuedCommands: this.queued.map(({ message }) => ({
|
|
@@ -35886,6 +36049,13 @@ class LogicalAgentSession {
|
|
|
35886
36049
|
return;
|
|
35887
36050
|
if (this.isClosedPerTurnLaneTail(physicalOwner, generation))
|
|
35888
36051
|
return;
|
|
36052
|
+
if (event.kind === "session_activity") {
|
|
36053
|
+
if (event.observation.status === "idle")
|
|
36054
|
+
this.flushSessionContent();
|
|
36055
|
+
this.activity = event.observation;
|
|
36056
|
+
this.emit({ type: "session_activity", observation: event.observation });
|
|
36057
|
+
return;
|
|
36058
|
+
}
|
|
35889
36059
|
const observation = event.kind === "model_observed" ? modelObservation(event.observation.model, event.observation.source, event.observation.provider, event.observation.responseId) : event.kind === "configuration_observed" && event.observation.evidence === "observed" && event.observation.effective === "current" ? modelObservation(event.observation.model, "session") : undefined;
|
|
35890
36060
|
if (observation)
|
|
35891
36061
|
this.emit({
|
|
@@ -35896,7 +36066,19 @@ class LogicalAgentSession {
|
|
|
35896
36066
|
});
|
|
35897
36067
|
if (event.kind === "model_observed")
|
|
35898
36068
|
return;
|
|
35899
|
-
if (event.attribution?.scope === "
|
|
36069
|
+
if (event.attribution?.scope === "session" && (event.kind === "assistant_message_delta" || event.kind === "assistant_reasoning_delta")) {
|
|
36070
|
+
appendSemanticFragment(event.kind === "assistant_message_delta" ? this.sessionMessage : this.sessionReasoning, event.text);
|
|
36071
|
+
if (event.text && !this.sessionContentTimer) {
|
|
36072
|
+
this.sessionContentTimer = setTimeout(() => {
|
|
36073
|
+
this.sessionContentTimer = undefined;
|
|
36074
|
+
if (this.state !== "closed" && this.state !== "stopping")
|
|
36075
|
+
this.flushSessionContent();
|
|
36076
|
+
}, 500);
|
|
36077
|
+
this.sessionContentTimer.unref?.();
|
|
36078
|
+
}
|
|
36079
|
+
return;
|
|
36080
|
+
}
|
|
36081
|
+
if (event.attribution?.scope === "child" || event.attribution?.scope === "unknown" || event.attribution?.scope === "session") {
|
|
35900
36082
|
this.emit({
|
|
35901
36083
|
type: "activity",
|
|
35902
36084
|
attribution: event.attribution,
|
|
@@ -35904,6 +36086,7 @@ class LogicalAgentSession {
|
|
|
35904
36086
|
..."text" in event ? { text: boundedSemanticCompletion(event.text).text } : {},
|
|
35905
36087
|
..."callId" in event ? { callId: event.callId } : {},
|
|
35906
36088
|
..."name" in event ? { name: event.name } : {},
|
|
36089
|
+
..."input" in event ? { input: jsonValue(event.input) } : {},
|
|
35907
36090
|
..."outcome" in event ? { outcome: event.outcome } : {},
|
|
35908
36091
|
..."output" in event ? { output: jsonValue(event.output) } : {}
|
|
35909
36092
|
});
|
|
@@ -36114,10 +36297,23 @@ class LogicalAgentSession {
|
|
|
36114
36297
|
this.emit({ type: "assistant_message_completed", turnId, ...message });
|
|
36115
36298
|
}
|
|
36116
36299
|
}
|
|
36300
|
+
this.flushSessionContent();
|
|
36117
36301
|
this.completeTurn(event.sessionId, physicalOwner, generation, event.turnOwner);
|
|
36118
36302
|
return;
|
|
36119
36303
|
}
|
|
36120
36304
|
}
|
|
36305
|
+
flushSessionContent() {
|
|
36306
|
+
if (this.sessionContentTimer)
|
|
36307
|
+
clearTimeout(this.sessionContentTimer);
|
|
36308
|
+
this.sessionContentTimer = undefined;
|
|
36309
|
+
for (const [kind, buffer] of [["assistant_reasoning_completed", this.sessionReasoning], ["assistant_message_completed", this.sessionMessage]]) {
|
|
36310
|
+
const completion = finishSemanticAssembler(buffer);
|
|
36311
|
+
if (completion.text)
|
|
36312
|
+
this.emit({ type: "activity", attribution: { scope: "session" }, kind, ...completion });
|
|
36313
|
+
}
|
|
36314
|
+
this.sessionMessage = emptySemanticAssembler();
|
|
36315
|
+
this.sessionReasoning = emptySemanticAssembler();
|
|
36316
|
+
}
|
|
36121
36317
|
isClosedPerTurnLaneTail(physicalOwner, generation) {
|
|
36122
36318
|
if (this.adapter.execution.lifetime !== "turn" || this.activeTurn)
|
|
36123
36319
|
return false;
|
|
@@ -36645,6 +36841,7 @@ class LogicalAgentSession {
|
|
|
36645
36841
|
const cleanup = hostCleanup.status === "failed" || hostCleanup.status === "timed_out" ? hostCleanup : this.laneCleanupFailure ?? hostCleanup;
|
|
36646
36842
|
const result = buildResult(cleanup);
|
|
36647
36843
|
this.terminalResult = result;
|
|
36844
|
+
this.flushSessionContent();
|
|
36648
36845
|
this.state = "closed";
|
|
36649
36846
|
this.emit({ type: "session_closed", result });
|
|
36650
36847
|
this.eventQueue.close();
|
|
@@ -38508,7 +38705,10 @@ function compactTraceData(data) {
|
|
|
38508
38705
|
}
|
|
38509
38706
|
// src/manager/managerPolicy.ts
|
|
38510
38707
|
function isActivelyWorking(agent) {
|
|
38511
|
-
return agent.status === "running" && (leaseIsWorking(agent.execution.lease) || agent.pendingAdmissions.length > 0 || agent.inbox.length > 0);
|
|
38708
|
+
return agent.status === "running" && (agent.sessionActivity?.status === "running" || leaseIsWorking(agent.execution.lease) || agent.pendingAdmissions.length > 0 || agent.inbox.length > 0);
|
|
38709
|
+
}
|
|
38710
|
+
function sessionBlocksIdleCleanup(agent) {
|
|
38711
|
+
return agent.sessionActivity !== undefined && agent.sessionActivity.status !== "idle";
|
|
38512
38712
|
}
|
|
38513
38713
|
var DEFAULT_STALE_THRESHOLD_MS = 120000;
|
|
38514
38714
|
var DEFAULT_TURN_SILENCE_POLICY = {
|
|
@@ -38534,6 +38734,19 @@ function createInitialManagerState(staleThresholdMs = DEFAULT_STALE_THRESHOLD_MS
|
|
|
38534
38734
|
}
|
|
38535
38735
|
function reduceManager(state, event) {
|
|
38536
38736
|
switch (event.type) {
|
|
38737
|
+
case "session_activity": {
|
|
38738
|
+
const current = state.agents[event.agentId];
|
|
38739
|
+
if (!current || !matchesSession(current, event.sessionInstanceId) || current.status === "stopping")
|
|
38740
|
+
return { state, effects: [] };
|
|
38741
|
+
const agent = clone(current);
|
|
38742
|
+
const changed = agent.sessionActivity?.status !== event.observation.status;
|
|
38743
|
+
agent.sessionActivity = event.observation;
|
|
38744
|
+
if (sessionBlocksIdleCleanup(agent))
|
|
38745
|
+
agent.idleSince = null;
|
|
38746
|
+
else if (changed && !leaseIsWorking(agent.execution.lease) && agent.pendingAdmissions.length === 0 && agent.inbox.length === 0)
|
|
38747
|
+
agent.idleSince = event.nowMs;
|
|
38748
|
+
return commit(state, agent, []);
|
|
38749
|
+
}
|
|
38537
38750
|
case "register":
|
|
38538
38751
|
return withAgent(state, event.agentId, (a) => a ?? freshAgent(event.agentId), []);
|
|
38539
38752
|
case "wake":
|
|
@@ -38583,6 +38796,7 @@ function reduceManager(state, event) {
|
|
|
38583
38796
|
{
|
|
38584
38797
|
const a = agent;
|
|
38585
38798
|
a.execution = { sessionInstanceId: event.sessionInstanceId, lease: { state: "none", lastTerminal: null } };
|
|
38799
|
+
a.sessionActivity = undefined;
|
|
38586
38800
|
a.turnSilence = event.turnSilence ?? {
|
|
38587
38801
|
...DEFAULT_TURN_SILENCE_POLICY,
|
|
38588
38802
|
nativeIdleTimeoutMs: state.staleThresholdMs,
|
|
@@ -38784,6 +38998,7 @@ function reduceManager(state, event) {
|
|
|
38784
38998
|
const closing = agent.pendingAdmissions.filter((entry) => entry.sessionInstanceId === event.sessionInstanceId);
|
|
38785
38999
|
agent.pendingAdmissions = agent.pendingAdmissions.filter((entry) => entry.sessionInstanceId !== event.sessionInstanceId);
|
|
38786
39000
|
agent.execution = { sessionInstanceId: null, lease: { state: "detached" } };
|
|
39001
|
+
agent.sessionActivity = undefined;
|
|
38787
39002
|
syncExecutionProjection(agent);
|
|
38788
39003
|
return commit(state, agent, recoveryEffects(agent, closing));
|
|
38789
39004
|
}
|
|
@@ -38912,7 +39127,7 @@ function onTurnCompleted(state, agentId, sessionInstanceId, nowMs, turnId, endRe
|
|
|
38912
39127
|
...messages.map((queued) => ({ type: "send", agentId, message: queued, mode: "idle" }))
|
|
38913
39128
|
]);
|
|
38914
39129
|
}
|
|
38915
|
-
agent.idleSince = agent.status === "running" && !agent.resetting ? nowMs : null;
|
|
39130
|
+
agent.idleSince = agent.status === "running" && !agent.resetting && !sessionBlocksIdleCleanup(agent) ? nowMs : null;
|
|
38916
39131
|
return commit(state, agent, clearEffects);
|
|
38917
39132
|
}
|
|
38918
39133
|
function onTurnToolLifecycle(state, event, lifecycle) {
|
|
@@ -39062,13 +39277,13 @@ function onTick(state, nowMs) {
|
|
|
39062
39277
|
effects.push({ type: "force_exit", agentId: id2, reason: "stopping_stuck" });
|
|
39063
39278
|
continue;
|
|
39064
39279
|
}
|
|
39065
|
-
const idleResetEligible = a.idleSince !== null && a.sessionId !== null && a.inbox.length === 0 && a.pendingAdmissions.length === 0 && !a.resetting && state.idleResetTimeoutMs > 0 && Number.isFinite(state.idleResetTimeoutMs) && (a.status === "idle" && lease.state === "detached" || a.status === "running" && lease.state === "none" && lease.lastTerminal !== null);
|
|
39280
|
+
const idleResetEligible = !sessionBlocksIdleCleanup(a) && a.idleSince !== null && a.sessionId !== null && a.inbox.length === 0 && a.pendingAdmissions.length === 0 && !a.resetting && state.idleResetTimeoutMs > 0 && Number.isFinite(state.idleResetTimeoutMs) && (a.status === "idle" && lease.state === "detached" || a.status === "running" && lease.state === "none" && lease.lastTerminal !== null);
|
|
39066
39281
|
if (idleResetEligible && nowMs - a.idleSince >= state.idleResetTimeoutMs) {
|
|
39067
39282
|
agents[id2] = { ...a, idleSince: nowMs };
|
|
39068
39283
|
effects.push({ type: "maintain_idle_memory", agentId: id2, sessionId: a.sessionId });
|
|
39069
39284
|
continue;
|
|
39070
39285
|
}
|
|
39071
|
-
const idleEligible = a.status === "running" && lease.state === "none" && a.pendingAdmissions.length === 0 && lease.lastTerminal !== null && a.inbox.length === 0 && state.idleTimeoutMs > 0 && Number.isFinite(state.idleTimeoutMs);
|
|
39286
|
+
const idleEligible = !sessionBlocksIdleCleanup(a) && a.status === "running" && lease.state === "none" && a.pendingAdmissions.length === 0 && lease.lastTerminal !== null && a.inbox.length === 0 && state.idleTimeoutMs > 0 && Number.isFinite(state.idleTimeoutMs);
|
|
39072
39287
|
if (idleEligible && a.idleSince !== null && nowMs - a.idleSince >= state.idleTimeoutMs) {
|
|
39073
39288
|
agents[id2] = { ...a, status: "stopping", stoppingSince: nowMs };
|
|
39074
39289
|
effects.push({ type: "stop", agentId: id2, reason: "idle_timeout" });
|
|
@@ -39102,6 +39317,8 @@ function freshAgent(agentId) {
|
|
|
39102
39317
|
}
|
|
39103
39318
|
function enterStable(agent, status) {
|
|
39104
39319
|
agent.status = status;
|
|
39320
|
+
if (status === "idle")
|
|
39321
|
+
agent.sessionActivity = undefined;
|
|
39105
39322
|
agent.resetting = false;
|
|
39106
39323
|
agent.resettingSince = null;
|
|
39107
39324
|
agent.stoppingSince = null;
|
|
@@ -59061,7 +59278,7 @@ var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
|
59061
59278
|
statusText: exports_external.string().nullable().optional()
|
|
59062
59279
|
});
|
|
59063
59280
|
// ../shared/src/business-schema-version.ts
|
|
59064
|
-
var BUSINESS_SCHEMA_VERSION =
|
|
59281
|
+
var BUSINESS_SCHEMA_VERSION = 11;
|
|
59065
59282
|
|
|
59066
59283
|
// ../shared/src/community-contract.ts
|
|
59067
59284
|
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
@@ -59094,7 +59311,130 @@ var AgentModelReportSchema = exports_external.object({
|
|
|
59094
59311
|
provider: identity2.optional(),
|
|
59095
59312
|
source: exports_external.enum(["response", "session"]),
|
|
59096
59313
|
responseId: identity2.optional(),
|
|
59097
|
-
observedAt: exports_external.
|
|
59314
|
+
observedAt: exports_external.iso.datetime({ offset: true })
|
|
59315
|
+
});
|
|
59316
|
+
|
|
59317
|
+
// ../shared/src/community-decision-card.ts
|
|
59318
|
+
var DECISION_CARD_EMBED_KIND = "decision_card";
|
|
59319
|
+
var DECISION_CARD_EMBED_VERSION = 1;
|
|
59320
|
+
var DECISION_CARD_MAX_BYTES = 8 * 1024;
|
|
59321
|
+
var DECISION_CARD_MAX_MENTIONS = 20;
|
|
59322
|
+
var DECISION_CARD_MIN_QUESTIONS = 1;
|
|
59323
|
+
var DECISION_CARD_MAX_QUESTIONS = 4;
|
|
59324
|
+
var DECISION_CARD_MIN_OPTIONS = 2;
|
|
59325
|
+
var DECISION_CARD_MAX_OPTIONS = 6;
|
|
59326
|
+
var DECISION_CARD_ID_MAX_LENGTH = 40;
|
|
59327
|
+
var DECISION_CARD_SUMMARY_MAX_LENGTH = 240;
|
|
59328
|
+
var DECISION_CARD_HEADER_MAX_LENGTH = 24;
|
|
59329
|
+
var DECISION_CARD_QUESTION_MAX_LENGTH = 300;
|
|
59330
|
+
var DECISION_CARD_OPTION_LABEL_MAX_LENGTH = 120;
|
|
59331
|
+
var DECISION_CARD_OPTION_DESC_MAX_LENGTH = 240;
|
|
59332
|
+
var DECISION_CARD_OTHER_TEXT_MAX_LENGTH = 500;
|
|
59333
|
+
function decisionCardUtf8Bytes(value) {
|
|
59334
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
59335
|
+
}
|
|
59336
|
+
var idFieldSchema = exports_external.string().trim().min(1).max(DECISION_CARD_ID_MAX_LENGTH).regex(/^[a-zA-Z0-9_-]+$/, "id must contain only letters, digits, hyphens, or underscores");
|
|
59337
|
+
var optionalTrimmedText = (max) => exports_external.string().trim().max(max).transform((value) => value.length > 0 ? value : undefined).optional();
|
|
59338
|
+
var requiredSummarySchema = exports_external.string().trim().min(1, "summary is required").max(DECISION_CARD_SUMMARY_MAX_LENGTH);
|
|
59339
|
+
var DecisionCardOptionInputSchema = exports_external.strictObject({
|
|
59340
|
+
id: idFieldSchema.optional(),
|
|
59341
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
59342
|
+
description: optionalTrimmedText(DECISION_CARD_OPTION_DESC_MAX_LENGTH),
|
|
59343
|
+
recommended: exports_external.boolean().optional()
|
|
59344
|
+
});
|
|
59345
|
+
var DecisionCardQuestionInputSchema = exports_external.strictObject({
|
|
59346
|
+
id: idFieldSchema.optional(),
|
|
59347
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
59348
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59349
|
+
multiSelect: exports_external.boolean().optional(),
|
|
59350
|
+
allowOther: exports_external.boolean().optional(),
|
|
59351
|
+
options: exports_external.array(DecisionCardOptionInputSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59352
|
+
});
|
|
59353
|
+
function hasDuplicateIds(ids) {
|
|
59354
|
+
return new Set(ids).size !== ids.length;
|
|
59355
|
+
}
|
|
59356
|
+
var mentionHandleSchema = exports_external.string().trim().min(1).max(128).refine((value) => parseNameAndTag(value.startsWith("@") ? value.slice(1) : value) !== null, { message: 'mention must be a handle like "@alice#0001"' });
|
|
59357
|
+
var DecisionCardInputSchema = exports_external.strictObject({
|
|
59358
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
59359
|
+
summary: requiredSummarySchema,
|
|
59360
|
+
questions: exports_external.array(DecisionCardQuestionInputSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59361
|
+
}).superRefine((value, ctx) => {
|
|
59362
|
+
const qIds = value.questions.map((q, index) => q.id ?? `q${index + 1}`);
|
|
59363
|
+
if (hasDuplicateIds(qIds)) {
|
|
59364
|
+
ctx.addIssue({
|
|
59365
|
+
code: "custom",
|
|
59366
|
+
path: ["questions"],
|
|
59367
|
+
message: "question ids must be unique"
|
|
59368
|
+
});
|
|
59369
|
+
}
|
|
59370
|
+
value.questions.forEach((q, qIndex) => {
|
|
59371
|
+
const optIds = q.options.map((opt, oIndex) => opt.id ?? `o${oIndex + 1}`);
|
|
59372
|
+
if (hasDuplicateIds(optIds)) {
|
|
59373
|
+
ctx.addIssue({
|
|
59374
|
+
code: "custom",
|
|
59375
|
+
path: ["questions", qIndex, "options"],
|
|
59376
|
+
message: "option ids must be unique within a question"
|
|
59377
|
+
});
|
|
59378
|
+
}
|
|
59379
|
+
});
|
|
59380
|
+
if (decisionCardUtf8Bytes(value) > DECISION_CARD_MAX_BYTES) {
|
|
59381
|
+
ctx.addIssue({
|
|
59382
|
+
code: "custom",
|
|
59383
|
+
path: [],
|
|
59384
|
+
message: `decision card exceeds ${DECISION_CARD_MAX_BYTES} bytes`
|
|
59385
|
+
});
|
|
59386
|
+
}
|
|
59387
|
+
});
|
|
59388
|
+
var DecisionCardCliOptionSchema = exports_external.union([
|
|
59389
|
+
exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH).transform((label2) => ({ label: label2 })),
|
|
59390
|
+
DecisionCardOptionInputSchema
|
|
59391
|
+
]);
|
|
59392
|
+
var DecisionCardCliInputSchema = exports_external.strictObject({
|
|
59393
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
59394
|
+
summary: requiredSummarySchema,
|
|
59395
|
+
questions: exports_external.array(exports_external.strictObject({
|
|
59396
|
+
id: idFieldSchema.optional(),
|
|
59397
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
59398
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59399
|
+
multiSelect: exports_external.boolean().optional(),
|
|
59400
|
+
allowOther: exports_external.boolean().optional(),
|
|
59401
|
+
options: exports_external.array(DecisionCardCliOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59402
|
+
})).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59403
|
+
});
|
|
59404
|
+
var DecisionCardAssigneeSchema = exports_external.strictObject({
|
|
59405
|
+
userId: exports_external.string().min(1),
|
|
59406
|
+
handle: exports_external.string().min(1)
|
|
59407
|
+
});
|
|
59408
|
+
var DecisionCardNormalizedOptionSchema = exports_external.strictObject({
|
|
59409
|
+
id: idFieldSchema,
|
|
59410
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
59411
|
+
description: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_DESC_MAX_LENGTH).optional(),
|
|
59412
|
+
recommended: exports_external.boolean().optional()
|
|
59413
|
+
});
|
|
59414
|
+
var DecisionCardNormalizedQuestionSchema = exports_external.strictObject({
|
|
59415
|
+
id: idFieldSchema,
|
|
59416
|
+
header: exports_external.string().trim().min(1).max(DECISION_CARD_HEADER_MAX_LENGTH).optional(),
|
|
59417
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59418
|
+
multiSelect: exports_external.boolean(),
|
|
59419
|
+
allowOther: exports_external.boolean(),
|
|
59420
|
+
options: exports_external.array(DecisionCardNormalizedOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59421
|
+
});
|
|
59422
|
+
var DecisionCardEmbedSchema = exports_external.strictObject({
|
|
59423
|
+
kind: exports_external.literal(DECISION_CARD_EMBED_KIND),
|
|
59424
|
+
version: exports_external.literal(DECISION_CARD_EMBED_VERSION),
|
|
59425
|
+
summary: exports_external.string().trim().min(1).max(DECISION_CARD_SUMMARY_MAX_LENGTH).optional(),
|
|
59426
|
+
assignees: exports_external.array(DecisionCardAssigneeSchema).max(DECISION_CARD_MAX_MENTIONS),
|
|
59427
|
+
questions: exports_external.array(DecisionCardNormalizedQuestionSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS),
|
|
59428
|
+
respondedUserIds: exports_external.array(exports_external.string().min(1)).optional(),
|
|
59429
|
+
viewerDismissed: exports_external.boolean().optional()
|
|
59430
|
+
});
|
|
59431
|
+
var DecisionCardAnswerItemSchema = exports_external.strictObject({
|
|
59432
|
+
questionId: idFieldSchema,
|
|
59433
|
+
selectedOptionIds: exports_external.array(idFieldSchema).max(DECISION_CARD_MAX_OPTIONS).optional(),
|
|
59434
|
+
otherText: exports_external.string().trim().max(DECISION_CARD_OTHER_TEXT_MAX_LENGTH).optional()
|
|
59435
|
+
});
|
|
59436
|
+
var DecisionCardAnswerInputSchema = exports_external.strictObject({
|
|
59437
|
+
answers: exports_external.array(DecisionCardAnswerItemSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59098
59438
|
});
|
|
59099
59439
|
|
|
59100
59440
|
// ../shared/src/provider-telemetry.ts
|
|
@@ -59173,8 +59513,8 @@ var QuotaLimitSchema = exports_external.object({
|
|
|
59173
59513
|
model: QuotaModelIdentitySchema,
|
|
59174
59514
|
window: QuotaWindowIdentitySchema
|
|
59175
59515
|
}).strict(),
|
|
59176
|
-
usedPercent: exports_external.number().
|
|
59177
|
-
resetsAt: exports_external.
|
|
59516
|
+
usedPercent: exports_external.number().min(0).max(100),
|
|
59517
|
+
resetsAt: exports_external.iso.datetime({ offset: true }).optional()
|
|
59178
59518
|
}).strict();
|
|
59179
59519
|
function quotaIdentity(limit) {
|
|
59180
59520
|
const { product, model, window: window2, limitId } = limit.bucket;
|
|
@@ -59521,12 +59861,38 @@ var CommunityAgentCursorSchema = exports_external.object({
|
|
|
59521
59861
|
var CommunityAgentSendRequestSchema = exports_external.object({
|
|
59522
59862
|
channel: exports_external.string().min(1),
|
|
59523
59863
|
content: CommunityAgentMessageContentSchema,
|
|
59864
|
+
question: DecisionCardInputSchema.optional(),
|
|
59524
59865
|
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
59525
59866
|
seenUpToSeq: CommunityAgentSeqSchema.optional(),
|
|
59526
59867
|
replyToSeq: CommunityAgentPositiveSeqSchema.optional(),
|
|
59527
59868
|
force: exports_external.boolean().optional(),
|
|
59528
59869
|
nonce: exports_external.string().min(1).max(128).optional()
|
|
59529
|
-
}).
|
|
59870
|
+
}).superRefine((d, ctx) => {
|
|
59871
|
+
if (d.question !== undefined) {
|
|
59872
|
+
if (d.attachments.length > 0) {
|
|
59873
|
+
ctx.addIssue({
|
|
59874
|
+
code: "custom",
|
|
59875
|
+
path: ["attachments"],
|
|
59876
|
+
message: "decision card messages cannot include attachments"
|
|
59877
|
+
});
|
|
59878
|
+
}
|
|
59879
|
+
if (d.content.text.trim().length > 0) {
|
|
59880
|
+
ctx.addIssue({
|
|
59881
|
+
code: "custom",
|
|
59882
|
+
path: ["content", "text"],
|
|
59883
|
+
message: "decision card messages must omit content.text"
|
|
59884
|
+
});
|
|
59885
|
+
}
|
|
59886
|
+
return;
|
|
59887
|
+
}
|
|
59888
|
+
if (d.content.text.trim().length === 0 && d.attachments.length === 0) {
|
|
59889
|
+
ctx.addIssue({
|
|
59890
|
+
code: "custom",
|
|
59891
|
+
path: [],
|
|
59892
|
+
message: "message must have text or attachments"
|
|
59893
|
+
});
|
|
59894
|
+
}
|
|
59895
|
+
});
|
|
59530
59896
|
var CommunityAgentAttachmentUploadResponseSchema = exports_external.object({
|
|
59531
59897
|
id: exports_external.string(),
|
|
59532
59898
|
filename: exports_external.string(),
|
|
@@ -59671,7 +60037,7 @@ var BotAuditEventKindSchema = exports_external.enum([
|
|
|
59671
60037
|
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
59672
60038
|
type: exports_external.literal("bot_audit_event"),
|
|
59673
60039
|
eventId: exports_external.string().min(1).max(128).optional(),
|
|
59674
|
-
occurredAt: exports_external.
|
|
60040
|
+
occurredAt: exports_external.iso.datetime({ offset: true }).optional(),
|
|
59675
60041
|
agentId: exports_external.string().min(1),
|
|
59676
60042
|
sessionId: exports_external.string().nullable().optional(),
|
|
59677
60043
|
launchId: exports_external.string().nullable().optional(),
|
|
@@ -59819,7 +60185,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
59819
60185
|
seq: exports_external.number().int().nonnegative(),
|
|
59820
60186
|
authorId: id2,
|
|
59821
60187
|
createdAt: exports_external.string(),
|
|
59822
|
-
type: exports_external.enum(["chat", "system"]),
|
|
60188
|
+
type: exports_external.enum(["chat", "system", "question"]),
|
|
59823
60189
|
content: exports_external.string(),
|
|
59824
60190
|
replyToId: nullableId,
|
|
59825
60191
|
clientNonce: exports_external.string().nullable(),
|
|
@@ -59912,11 +60278,18 @@ var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
|
59912
60278
|
servers: exports_external.array(CommunityServerResourceSchema),
|
|
59913
60279
|
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
59914
60280
|
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
59915
|
-
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
60281
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema),
|
|
60282
|
+
categories: exports_external.array(CommunityCategoryResourceSchema).optional(),
|
|
60283
|
+
dmPeers: exports_external.array(exports_external.strictObject({ channelId: id2, userId: id2 })).optional()
|
|
59916
60284
|
}).superRefine((bundle, ctx) => {
|
|
59917
60285
|
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
59918
60286
|
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
59919
|
-
|
|
60287
|
+
const categories = bundle.categories ?? [];
|
|
60288
|
+
const dmPeers = bundle.dmPeers ?? [];
|
|
60289
|
+
const dmChannels = new Set(bundle.channels.filter((row) => row.type === "dm").map((row) => row.id));
|
|
60290
|
+
const profiles = new Set(bundle.profiles.map((row) => row.id));
|
|
60291
|
+
const readableCategories = new Map(bundle.channels.flatMap((row) => row.categoryId ? [[row.categoryId, row.serverId]] : []));
|
|
60292
|
+
if (channels.size !== bundle.channels.length || servers.size !== bundle.servers.length || new Set(categories.map((row) => row.id)).size !== categories.length || categories.some((row) => readableCategories.get(row.id) !== row.serverId) || new Set(dmPeers.map((row) => row.channelId)).size !== dmPeers.length || dmPeers.some((row) => !dmChannels.has(row.channelId) || row.userId === bundle.viewerId || !profiles.has(row.userId)) || new Set(bundle.messages.map((row) => row.id)).size !== bundle.messages.length || profiles.size !== bundle.profiles.length || new Set(bundle.memberships.map((row) => `${row.channelId}:${row.userId}:${row.relation}`)).size !== bundle.memberships.length || new Set(bundle.serverMemberships.map((row) => `${row.serverId}:${row.userId}`)).size !== bundle.serverMemberships.length || bundle.messages.some((row) => !channels.has(row.channelId)) || bundle.servers.some((row) => !bundle.serverMemberships.some((member) => member.serverId === row.id && member.userId === bundle.viewerId)) || bundle.channels.some((row) => !bundle.memberships.some((member) => member.channelId === row.id && member.userId === bundle.viewerId && member.relation === "access")) || bundle.channels.some((row) => row.serverId !== null && !servers.has(row.serverId) || row.parentChannelId !== null && !channels.has(row.parentChannelId)) || bundle.memberships.some((row) => row.userId !== bundle.viewerId || !channels.has(row.channelId)) || bundle.serverMemberships.some((row) => row.userId !== bundle.viewerId || !servers.has(row.serverId)))
|
|
59920
60293
|
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
59921
60294
|
});
|
|
59922
60295
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
@@ -60039,7 +60412,7 @@ var AttentionScopeSchema = exports_external.strictObject({
|
|
|
60039
60412
|
});
|
|
60040
60413
|
var AttentionItemSchema = exports_external.strictObject({
|
|
60041
60414
|
id: id3,
|
|
60042
|
-
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
60415
|
+
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post", "question"]),
|
|
60043
60416
|
sourceId: id3,
|
|
60044
60417
|
scopeId: id3.nullable().optional(),
|
|
60045
60418
|
messageId: id3.nullable().optional(),
|
|
@@ -60074,7 +60447,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
60074
60447
|
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
60075
60448
|
}
|
|
60076
60449
|
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
60077
|
-
ctx.addIssue({ code: "custom", message: "
|
|
60450
|
+
ctx.addIssue({ code: "custom", message: "message attention cannot carry forum presentation refs" });
|
|
60078
60451
|
}
|
|
60079
60452
|
});
|
|
60080
60453
|
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
@@ -60130,6 +60503,7 @@ var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
|
60130
60503
|
items: exports_external.array(AttentionItemSchema),
|
|
60131
60504
|
limit: exports_external.number().int().positive(),
|
|
60132
60505
|
truncated: exports_external.boolean(),
|
|
60506
|
+
todosTruncated: exports_external.boolean().optional(),
|
|
60133
60507
|
included: AttentionIncludedSchema
|
|
60134
60508
|
});
|
|
60135
60509
|
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
@@ -60192,7 +60566,7 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
60192
60566
|
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
60193
60567
|
}
|
|
60194
60568
|
itemIds.add(item.id);
|
|
60195
|
-
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
60569
|
+
if (item.kind !== "question" && item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
60196
60570
|
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
60197
60571
|
}
|
|
60198
60572
|
if (item.kind === "friend_request") {
|
|
@@ -60201,6 +60575,16 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
60201
60575
|
}
|
|
60202
60576
|
continue;
|
|
60203
60577
|
}
|
|
60578
|
+
if (item.kind === "question") {
|
|
60579
|
+
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
60580
|
+
const channel = item.scopeId ? channelById.get(item.scopeId) : undefined;
|
|
60581
|
+
const dm = item.scopeId ? dmById.get(item.scopeId) : undefined;
|
|
60582
|
+
const ownerValid = Boolean(channel && serverById.has(channel.serverId) || dm && profileById.has(dm.userId));
|
|
60583
|
+
if (!item.scopeId || !message2 || message2.channelId !== item.scopeId || !item.actorUserId || !profileById.has(item.actorUserId) || !ownerValid) {
|
|
60584
|
+
ctx.addIssue({ code: "custom", message: `question attention references incomplete owners: ${item.id}` });
|
|
60585
|
+
}
|
|
60586
|
+
continue;
|
|
60587
|
+
}
|
|
60204
60588
|
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
60205
60589
|
const message = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
60206
60590
|
if (!scope || !message) {
|
|
@@ -60224,7 +60608,7 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
60224
60608
|
var EntitlementValueSchema = exports_external.lazy(() => exports_external.union([
|
|
60225
60609
|
exports_external.null(),
|
|
60226
60610
|
exports_external.boolean(),
|
|
60227
|
-
exports_external.number()
|
|
60611
|
+
exports_external.number(),
|
|
60228
60612
|
exports_external.string(),
|
|
60229
60613
|
exports_external.array(EntitlementValueSchema),
|
|
60230
60614
|
exports_external.record(exports_external.string(), EntitlementValueSchema)
|
|
@@ -60251,11 +60635,11 @@ var BillingOfferSchema = exports_external.object({
|
|
|
60251
60635
|
var BillingSubscriptionSchema = exports_external.object({
|
|
60252
60636
|
plan: BillingPlanSchema,
|
|
60253
60637
|
status: exports_external.string().min(1),
|
|
60254
|
-
currentPeriodEnd: exports_external.
|
|
60255
|
-
cancelAt: exports_external.
|
|
60638
|
+
currentPeriodEnd: exports_external.iso.datetime().nullable(),
|
|
60639
|
+
cancelAt: exports_external.iso.datetime().nullable(),
|
|
60256
60640
|
scheduledChange: exports_external.object({
|
|
60257
60641
|
plan: BillingPlanSchema,
|
|
60258
|
-
effectiveAt: exports_external.
|
|
60642
|
+
effectiveAt: exports_external.iso.datetime()
|
|
60259
60643
|
}).nullable()
|
|
60260
60644
|
});
|
|
60261
60645
|
var PublicPricingSchema = exports_external.object({
|
|
@@ -60280,7 +60664,7 @@ var BillingPortalRequestSchema = exports_external.strictObject({
|
|
|
60280
60664
|
priceId: exports_external.string().min(1).max(255).optional()
|
|
60281
60665
|
});
|
|
60282
60666
|
var BillingRedirectResponseSchema = exports_external.object({
|
|
60283
|
-
url: exports_external.
|
|
60667
|
+
url: exports_external.url()
|
|
60284
60668
|
});
|
|
60285
60669
|
// ../shared/src/utils/day-key.ts
|
|
60286
60670
|
function utcDayKey(now) {
|
|
@@ -60318,7 +60702,7 @@ function dayKeyInTimeZone(now, timeZone) {
|
|
|
60318
60702
|
return `${year}-${month}-${day}`;
|
|
60319
60703
|
}
|
|
60320
60704
|
|
|
60321
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60705
|
+
// ../../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
|
|
60322
60706
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
60323
60707
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
60324
60708
|
function is(value, type) {
|
|
@@ -60343,7 +60727,7 @@ function is(value, type) {
|
|
|
60343
60727
|
return false;
|
|
60344
60728
|
}
|
|
60345
60729
|
|
|
60346
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60730
|
+
// ../../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/column.js
|
|
60347
60731
|
class Column {
|
|
60348
60732
|
constructor(table, config2) {
|
|
60349
60733
|
this.table = table;
|
|
@@ -60393,7 +60777,7 @@ class Column {
|
|
|
60393
60777
|
}
|
|
60394
60778
|
}
|
|
60395
60779
|
|
|
60396
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60780
|
+
// ../../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/column-builder.js
|
|
60397
60781
|
class ColumnBuilder {
|
|
60398
60782
|
static [entityKind] = "ColumnBuilder";
|
|
60399
60783
|
config;
|
|
@@ -60449,20 +60833,20 @@ class ColumnBuilder {
|
|
|
60449
60833
|
}
|
|
60450
60834
|
}
|
|
60451
60835
|
|
|
60452
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60836
|
+
// ../../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/table.utils.js
|
|
60453
60837
|
var TableName = Symbol.for("drizzle:Name");
|
|
60454
60838
|
|
|
60455
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60839
|
+
// ../../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/tracing-utils.js
|
|
60456
60840
|
function iife(fn, ...args) {
|
|
60457
60841
|
return fn(...args);
|
|
60458
60842
|
}
|
|
60459
60843
|
|
|
60460
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60844
|
+
// ../../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/pg-core/unique-constraint.js
|
|
60461
60845
|
function uniqueKeyName(table, columns) {
|
|
60462
60846
|
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
60463
60847
|
}
|
|
60464
60848
|
|
|
60465
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60849
|
+
// ../../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/pg-core/columns/common.js
|
|
60466
60850
|
class PgColumn extends Column {
|
|
60467
60851
|
constructor(table, config2) {
|
|
60468
60852
|
if (!config2.uniqueName) {
|
|
@@ -60511,7 +60895,7 @@ class ExtraConfigColumn extends PgColumn {
|
|
|
60511
60895
|
}
|
|
60512
60896
|
}
|
|
60513
60897
|
|
|
60514
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60898
|
+
// ../../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/pg-core/columns/enum.js
|
|
60515
60899
|
class PgEnumObjectColumn extends PgColumn {
|
|
60516
60900
|
static [entityKind] = "PgEnumObjectColumn";
|
|
60517
60901
|
enum;
|
|
@@ -60541,7 +60925,7 @@ class PgEnumColumn extends PgColumn {
|
|
|
60541
60925
|
}
|
|
60542
60926
|
}
|
|
60543
60927
|
|
|
60544
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60928
|
+
// ../../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/subquery.js
|
|
60545
60929
|
class Subquery {
|
|
60546
60930
|
static [entityKind] = "Subquery";
|
|
60547
60931
|
constructor(sql, fields2, alias, isWith = false, usedTables = []) {
|
|
@@ -60556,10 +60940,10 @@ class Subquery {
|
|
|
60556
60940
|
}
|
|
60557
60941
|
}
|
|
60558
60942
|
|
|
60559
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60943
|
+
// ../../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/version.js
|
|
60560
60944
|
var version2 = "0.45.4";
|
|
60561
60945
|
|
|
60562
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60946
|
+
// ../../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/tracing.js
|
|
60563
60947
|
var otel;
|
|
60564
60948
|
var rawTracer;
|
|
60565
60949
|
var tracer = {
|
|
@@ -60586,10 +60970,10 @@ var tracer = {
|
|
|
60586
60970
|
}
|
|
60587
60971
|
};
|
|
60588
60972
|
|
|
60589
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60973
|
+
// ../../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/view-common.js
|
|
60590
60974
|
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
60591
60975
|
|
|
60592
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
60976
|
+
// ../../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/table.js
|
|
60593
60977
|
var Schema = Symbol.for("drizzle:Schema");
|
|
60594
60978
|
var Columns = Symbol.for("drizzle:Columns");
|
|
60595
60979
|
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
@@ -60627,7 +61011,7 @@ class Table {
|
|
|
60627
61011
|
}
|
|
60628
61012
|
}
|
|
60629
61013
|
|
|
60630
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61014
|
+
// ../../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/sql/sql.js
|
|
60631
61015
|
function isSQLWrapper(value) {
|
|
60632
61016
|
return value !== null && value !== undefined && typeof value.getSQL === "function";
|
|
60633
61017
|
}
|
|
@@ -60990,7 +61374,7 @@ Subquery.prototype.getSQL = function() {
|
|
|
60990
61374
|
return new SQL([this]);
|
|
60991
61375
|
};
|
|
60992
61376
|
|
|
60993
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61377
|
+
// ../../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/alias.js
|
|
60994
61378
|
class ColumnAliasProxyHandler {
|
|
60995
61379
|
constructor(table) {
|
|
60996
61380
|
this.table = table;
|
|
@@ -61046,7 +61430,7 @@ class TableAliasProxyHandler {
|
|
|
61046
61430
|
}
|
|
61047
61431
|
}
|
|
61048
61432
|
|
|
61049
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61433
|
+
// ../../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/utils.js
|
|
61050
61434
|
function getColumnNameAndConfig(a, b) {
|
|
61051
61435
|
return {
|
|
61052
61436
|
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
@@ -61055,7 +61439,7 @@ function getColumnNameAndConfig(a, b) {
|
|
|
61055
61439
|
}
|
|
61056
61440
|
var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
|
|
61057
61441
|
|
|
61058
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61442
|
+
// ../../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/sql/expressions/conditions.js
|
|
61059
61443
|
function bindIfParam(value, column) {
|
|
61060
61444
|
if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
|
|
61061
61445
|
return new Param(value, column);
|
|
@@ -61079,11 +61463,14 @@ function and(...unfilteredConditions) {
|
|
|
61079
61463
|
new StringChunk(")")
|
|
61080
61464
|
]);
|
|
61081
61465
|
}
|
|
61466
|
+
function isNull(value) {
|
|
61467
|
+
return sql`${value} is null`;
|
|
61468
|
+
}
|
|
61082
61469
|
function isNotNull(value) {
|
|
61083
61470
|
return sql`${value} is not null`;
|
|
61084
61471
|
}
|
|
61085
61472
|
|
|
61086
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61473
|
+
// ../../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/sql/expressions/select.js
|
|
61087
61474
|
function desc(column) {
|
|
61088
61475
|
return sql`${column} desc`;
|
|
61089
61476
|
}
|
|
@@ -61101,6 +61488,7 @@ __export(exports_community_schema, {
|
|
|
61101
61488
|
communityReadStateRevision: () => communityReadStateRevision,
|
|
61102
61489
|
communityReadState: () => communityReadState,
|
|
61103
61490
|
communityReaction: () => communityReaction,
|
|
61491
|
+
communityQuestionTodo: () => communityQuestionTodo,
|
|
61104
61492
|
communityPushDevice: () => communityPushDevice,
|
|
61105
61493
|
communityPin: () => communityPin,
|
|
61106
61494
|
communityNotificationSetting: () => communityNotificationSetting,
|
|
@@ -61121,12 +61509,12 @@ __export(exports_community_schema, {
|
|
|
61121
61509
|
communityAttachment: () => communityAttachment
|
|
61122
61510
|
});
|
|
61123
61511
|
|
|
61124
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61512
|
+
// ../../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/sqlite-core/alias.js
|
|
61125
61513
|
function alias(table, alias2) {
|
|
61126
61514
|
return new Proxy(table, new TableAliasProxyHandler(alias2, false));
|
|
61127
61515
|
}
|
|
61128
61516
|
|
|
61129
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61517
|
+
// ../../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/sqlite-core/checks.js
|
|
61130
61518
|
class CheckBuilder {
|
|
61131
61519
|
constructor(name, value) {
|
|
61132
61520
|
this.name = name;
|
|
@@ -61153,7 +61541,7 @@ function check2(name, value) {
|
|
|
61153
61541
|
return new CheckBuilder(name, value);
|
|
61154
61542
|
}
|
|
61155
61543
|
|
|
61156
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61544
|
+
// ../../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/sqlite-core/foreign-keys.js
|
|
61157
61545
|
class ForeignKeyBuilder {
|
|
61158
61546
|
static [entityKind] = "SQLiteForeignKeyBuilder";
|
|
61159
61547
|
reference;
|
|
@@ -61207,7 +61595,7 @@ class ForeignKey {
|
|
|
61207
61595
|
}
|
|
61208
61596
|
}
|
|
61209
61597
|
|
|
61210
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61598
|
+
// ../../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/sqlite-core/unique-constraint.js
|
|
61211
61599
|
function uniqueKeyName2(table, columns) {
|
|
61212
61600
|
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
61213
61601
|
}
|
|
@@ -61252,7 +61640,7 @@ class UniqueConstraint {
|
|
|
61252
61640
|
}
|
|
61253
61641
|
}
|
|
61254
61642
|
|
|
61255
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61643
|
+
// ../../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/sqlite-core/columns/common.js
|
|
61256
61644
|
class SQLiteColumnBuilder extends ColumnBuilder {
|
|
61257
61645
|
static [entityKind] = "SQLiteColumnBuilder";
|
|
61258
61646
|
foreignKeyConfigs = [];
|
|
@@ -61303,7 +61691,7 @@ class SQLiteColumn extends Column {
|
|
|
61303
61691
|
static [entityKind] = "SQLiteColumn";
|
|
61304
61692
|
}
|
|
61305
61693
|
|
|
61306
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61694
|
+
// ../../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/sqlite-core/columns/blob.js
|
|
61307
61695
|
class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
|
|
61308
61696
|
static [entityKind] = "SQLiteBigIntBuilder";
|
|
61309
61697
|
constructor(name) {
|
|
@@ -61391,7 +61779,7 @@ function blob(a, b) {
|
|
|
61391
61779
|
return new SQLiteBlobBufferBuilder(name);
|
|
61392
61780
|
}
|
|
61393
61781
|
|
|
61394
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61782
|
+
// ../../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/sqlite-core/columns/custom.js
|
|
61395
61783
|
class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
|
|
61396
61784
|
static [entityKind] = "SQLiteCustomColumnBuilder";
|
|
61397
61785
|
constructor(name, fieldConfig, customTypeParams) {
|
|
@@ -61432,7 +61820,7 @@ function customType(customTypeParams) {
|
|
|
61432
61820
|
};
|
|
61433
61821
|
}
|
|
61434
61822
|
|
|
61435
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61823
|
+
// ../../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/sqlite-core/columns/integer.js
|
|
61436
61824
|
class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
|
|
61437
61825
|
static [entityKind] = "SQLiteBaseIntegerBuilder";
|
|
61438
61826
|
constructor(name, dataType, columnType) {
|
|
@@ -61534,7 +61922,7 @@ function integer2(a, b) {
|
|
|
61534
61922
|
return new SQLiteIntegerBuilder(name);
|
|
61535
61923
|
}
|
|
61536
61924
|
|
|
61537
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61925
|
+
// ../../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/sqlite-core/columns/numeric.js
|
|
61538
61926
|
class SQLiteNumericBuilder extends SQLiteColumnBuilder {
|
|
61539
61927
|
static [entityKind] = "SQLiteNumericBuilder";
|
|
61540
61928
|
constructor(name) {
|
|
@@ -61604,7 +61992,7 @@ function numeric(a, b) {
|
|
|
61604
61992
|
return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
|
|
61605
61993
|
}
|
|
61606
61994
|
|
|
61607
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
61995
|
+
// ../../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/sqlite-core/columns/real.js
|
|
61608
61996
|
class SQLiteRealBuilder extends SQLiteColumnBuilder {
|
|
61609
61997
|
static [entityKind] = "SQLiteRealBuilder";
|
|
61610
61998
|
constructor(name) {
|
|
@@ -61625,7 +62013,7 @@ function real(name) {
|
|
|
61625
62013
|
return new SQLiteRealBuilder(name ?? "");
|
|
61626
62014
|
}
|
|
61627
62015
|
|
|
61628
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
62016
|
+
// ../../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/sqlite-core/columns/text.js
|
|
61629
62017
|
class SQLiteTextBuilder extends SQLiteColumnBuilder {
|
|
61630
62018
|
static [entityKind] = "SQLiteTextBuilder";
|
|
61631
62019
|
constructor(name, config2) {
|
|
@@ -61680,7 +62068,7 @@ function text2(a, b = {}) {
|
|
|
61680
62068
|
return new SQLiteTextBuilder(name, config2);
|
|
61681
62069
|
}
|
|
61682
62070
|
|
|
61683
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
62071
|
+
// ../../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/sqlite-core/columns/all.js
|
|
61684
62072
|
function getSQLiteColumnBuilders() {
|
|
61685
62073
|
return {
|
|
61686
62074
|
blob,
|
|
@@ -61692,7 +62080,7 @@ function getSQLiteColumnBuilders() {
|
|
|
61692
62080
|
};
|
|
61693
62081
|
}
|
|
61694
62082
|
|
|
61695
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
62083
|
+
// ../../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/sqlite-core/table.js
|
|
61696
62084
|
var InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
61697
62085
|
|
|
61698
62086
|
class SQLiteTable extends Table {
|
|
@@ -61726,7 +62114,7 @@ var sqliteTable = (name, columns, extraConfig) => {
|
|
|
61726
62114
|
return sqliteTableBase(name, columns, extraConfig);
|
|
61727
62115
|
};
|
|
61728
62116
|
|
|
61729
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
62117
|
+
// ../../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/sqlite-core/indexes.js
|
|
61730
62118
|
class IndexBuilderOn {
|
|
61731
62119
|
constructor(name, unique2) {
|
|
61732
62120
|
this.name = name;
|
|
@@ -61772,7 +62160,7 @@ function uniqueIndex(name) {
|
|
|
61772
62160
|
return new IndexBuilderOn(name, true);
|
|
61773
62161
|
}
|
|
61774
62162
|
|
|
61775
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.
|
|
62163
|
+
// ../../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/sqlite-core/primary-keys.js
|
|
61776
62164
|
function primaryKey(...config2) {
|
|
61777
62165
|
if (config2[0].columns) {
|
|
61778
62166
|
return new PrimaryKeyBuilder(config2[0].columns, config2[0].name);
|
|
@@ -62068,7 +62456,20 @@ var communityMessage = sqliteTable("community_message", {
|
|
|
62068
62456
|
}, (t) => [
|
|
62069
62457
|
index("idx_community_message_author_id_lookup").on(t.authorId),
|
|
62070
62458
|
index("idx_message_channel_created").on(t.channelId, t.createdAt),
|
|
62071
|
-
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt)
|
|
62459
|
+
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt),
|
|
62460
|
+
index("idx_community_message_channel_reply_author").on(t.channelId, t.replyToId, t.authorId).where(sql`${t.replyToId} IS NOT NULL`)
|
|
62461
|
+
]);
|
|
62462
|
+
var communityQuestionTodo = sqliteTable("community_question_todo", {
|
|
62463
|
+
userId: text2("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62464
|
+
messageId: text2("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
62465
|
+
channelId: text2("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
62466
|
+
createdAt: text2("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
62467
|
+
dismissedAt: text2("dismissed_at")
|
|
62468
|
+
}, (t) => [
|
|
62469
|
+
primaryKey({ columns: [t.userId, t.messageId] }),
|
|
62470
|
+
index("idx_community_question_todo_user_active").on(t.userId, desc(t.createdAt), desc(t.messageId)).where(isNull(t.dismissedAt)),
|
|
62471
|
+
index("idx_community_question_todo_message_id_lookup").on(t.messageId),
|
|
62472
|
+
index("idx_community_question_todo_channel_id_lookup").on(t.channelId)
|
|
62072
62473
|
]);
|
|
62073
62474
|
var communityMessageSeq = sqliteTable("community_message_seq", {
|
|
62074
62475
|
channelId: text2("channel_id").primaryKey().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
@@ -62447,19 +62848,18 @@ class Logger {
|
|
|
62447
62848
|
entry[k] = { message: v.message, stack: v.stack };
|
|
62448
62849
|
}
|
|
62449
62850
|
}
|
|
62450
|
-
|
|
62451
|
-
if (this.pretty) {
|
|
62851
|
+
const output2 = this.pretty ? (() => {
|
|
62452
62852
|
const ts = entry.ts.replace("T", " ").replace("Z", "");
|
|
62453
62853
|
const lvl = entry.level.toUpperCase().padEnd(5);
|
|
62454
62854
|
const pairs = Object.entries(entry).filter(([k]) => k !== "level" && k !== "msg" && k !== "service" && k !== "ts").map(([k, v]) => `${k}=${typeof v === "object" ? JSON.stringify(v) : v}`).join(" ");
|
|
62455
|
-
|
|
62456
|
-
}
|
|
62457
|
-
line = JSON.stringify(entry);
|
|
62458
|
-
}
|
|
62855
|
+
return `${ts} ${lvl} [${entry.service}] ${entry.msg}${pairs ? " " + pairs : ""}`;
|
|
62856
|
+
})() : entry;
|
|
62459
62857
|
if (level === "error") {
|
|
62460
|
-
console.error(
|
|
62858
|
+
console.error(output2);
|
|
62859
|
+
} else if (level === "warn") {
|
|
62860
|
+
console.warn(output2);
|
|
62461
62861
|
} else {
|
|
62462
|
-
console.log(
|
|
62862
|
+
console.log(output2);
|
|
62463
62863
|
}
|
|
62464
62864
|
}
|
|
62465
62865
|
}
|
|
@@ -62735,7 +63135,9 @@ var AGENT_MESSAGE_COLUMNS = {
|
|
|
62735
63135
|
createdAt: communityMessage.createdAt,
|
|
62736
63136
|
channelId: communityMessage.channelId,
|
|
62737
63137
|
seq: communityMessage.seq,
|
|
62738
|
-
replyToId: communityMessage.replyToId
|
|
63138
|
+
replyToId: communityMessage.replyToId,
|
|
63139
|
+
type: communityMessage.type,
|
|
63140
|
+
embeds: communityMessage.embeds
|
|
62739
63141
|
};
|
|
62740
63142
|
var channelJoinBaselineGuard = sql`${communityMessage.createdAt} > COALESCE(${communityChannelMember.addedAt}, ${communityServerMember.joinedAt}, '')`;
|
|
62741
63143
|
var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
@@ -62983,6 +63385,7 @@ var communityInboxChangedSchema = exports_external.strictObject({
|
|
|
62983
63385
|
"read_all",
|
|
62984
63386
|
"mention_read_all",
|
|
62985
63387
|
"mention_dismiss",
|
|
63388
|
+
"todo_dismiss",
|
|
62986
63389
|
"notification_policy"
|
|
62987
63390
|
])
|
|
62988
63391
|
});
|
|
@@ -71567,7 +71970,7 @@ function toResult(value) {
|
|
|
71567
71970
|
}
|
|
71568
71971
|
return value === null || value === undefined ? empty : [value];
|
|
71569
71972
|
}
|
|
71570
|
-
// ../../node_modules/.pnpm/mdast-util-find-and-replace@3.0.
|
|
71973
|
+
// ../../node_modules/.pnpm/mdast-util-find-and-replace@3.0.5/node_modules/mdast-util-find-and-replace/lib/index.js
|
|
71571
71974
|
function findAndReplace(tree, list2, options) {
|
|
71572
71975
|
const settings = options || {};
|
|
71573
71976
|
const ignored = convert(settings.ignore || []);
|
|
@@ -71603,9 +72006,7 @@ function findAndReplace(tree, list2, options) {
|
|
|
71603
72006
|
if (typeof value === "string") {
|
|
71604
72007
|
value = value.length > 0 ? { type: "text", value } : undefined;
|
|
71605
72008
|
}
|
|
71606
|
-
if (value
|
|
71607
|
-
find.lastIndex = position2 + 1;
|
|
71608
|
-
} else {
|
|
72009
|
+
if (value !== false) {
|
|
71609
72010
|
if (start !== position2) {
|
|
71610
72011
|
add({ type: "text", value: node3.value.slice(start, position2) });
|
|
71611
72012
|
}
|
|
@@ -71618,6 +72019,10 @@ function findAndReplace(tree, list2, options) {
|
|
|
71618
72019
|
start = position2 + match[0].length;
|
|
71619
72020
|
change = true;
|
|
71620
72021
|
}
|
|
72022
|
+
if (value === false || match[0].length === 0) {
|
|
72023
|
+
const code = node3.value.codePointAt(position2) || 0;
|
|
72024
|
+
find.lastIndex = position2 + (/[uv]/.test(find.flags) && code > 65535 ? 2 : 1);
|
|
72025
|
+
}
|
|
71621
72026
|
if (!find.global) {
|
|
71622
72027
|
break;
|
|
71623
72028
|
}
|
|
@@ -71663,7 +72068,7 @@ function toFunction(replace) {
|
|
|
71663
72068
|
return replace;
|
|
71664
72069
|
};
|
|
71665
72070
|
}
|
|
71666
|
-
// ../../node_modules/.pnpm/mdast-util-gfm-autolink-literal@2.0
|
|
72071
|
+
// ../../node_modules/.pnpm/mdast-util-gfm-autolink-literal@2.1.0/node_modules/mdast-util-gfm-autolink-literal/lib/index.js
|
|
71667
72072
|
var inConstruct = "phrasing";
|
|
71668
72073
|
var notInConstruct = ["autolink", "link", "image", "label"];
|
|
71669
72074
|
function gfmAutolinkLiteralFromMarkdown() {
|
|
@@ -71711,7 +72116,7 @@ function gfmAutolinkLiteralToMarkdown() {
|
|
|
71711
72116
|
};
|
|
71712
72117
|
}
|
|
71713
72118
|
function enterLiteralAutolink(token) {
|
|
71714
|
-
this.enter({ type: "link", title: null, url: "", children: [] }, token);
|
|
72119
|
+
this.enter({ type: "link", title: null, url: "", children: [], position: undefined }, token);
|
|
71715
72120
|
}
|
|
71716
72121
|
function enterLiteralAutolinkValue(token) {
|
|
71717
72122
|
this.config.enter.autolinkProtocol.call(this, token);
|
|
@@ -71733,62 +72138,107 @@ function exitLiteralAutolink(token) {
|
|
|
71733
72138
|
}
|
|
71734
72139
|
function transformGfmAutolinkLiterals(tree) {
|
|
71735
72140
|
findAndReplace(tree, [
|
|
71736
|
-
[
|
|
71737
|
-
|
|
72141
|
+
[
|
|
72142
|
+
/(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,
|
|
72143
|
+
findUrl
|
|
72144
|
+
],
|
|
72145
|
+
[
|
|
72146
|
+
/(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,
|
|
72147
|
+
findXmpp
|
|
72148
|
+
],
|
|
72149
|
+
[/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g, findMailto],
|
|
72150
|
+
[
|
|
72151
|
+
/(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,
|
|
72152
|
+
findEmail
|
|
72153
|
+
]
|
|
71738
72154
|
], { ignore: ["link", "linkReference"] });
|
|
71739
72155
|
}
|
|
71740
72156
|
function findUrl(_, protocol, domain2, path13, match) {
|
|
71741
|
-
let prefix = "";
|
|
71742
72157
|
if (!previous2(match)) {
|
|
71743
72158
|
return false;
|
|
71744
72159
|
}
|
|
72160
|
+
let prefix = "";
|
|
71745
72161
|
if (/^w/i.test(protocol)) {
|
|
71746
72162
|
domain2 = protocol + domain2;
|
|
71747
72163
|
protocol = "";
|
|
71748
72164
|
prefix = "http://";
|
|
71749
72165
|
}
|
|
71750
|
-
if (!isCorrectDomain(domain2)) {
|
|
72166
|
+
if (unicodePunctuation(domain2.charCodeAt(0)) || !isCorrectDomain(domain2)) {
|
|
71751
72167
|
return false;
|
|
71752
72168
|
}
|
|
71753
72169
|
const parts = splitUrl(domain2 + path13);
|
|
71754
|
-
if (!parts[0])
|
|
71755
|
-
return false;
|
|
71756
72170
|
const result = {
|
|
71757
72171
|
type: "link",
|
|
71758
72172
|
title: null,
|
|
71759
72173
|
url: prefix + protocol + parts[0],
|
|
71760
|
-
children: [{ type: "text", value: protocol + parts[0] }]
|
|
72174
|
+
children: [{ type: "text", value: protocol + parts[0], position: undefined }],
|
|
72175
|
+
position: undefined
|
|
71761
72176
|
};
|
|
71762
72177
|
if (parts[1]) {
|
|
71763
|
-
return [result, { type: "text", value: parts[1] }];
|
|
72178
|
+
return [result, { type: "text", value: parts[1], position: undefined }];
|
|
71764
72179
|
}
|
|
71765
72180
|
return result;
|
|
71766
72181
|
}
|
|
71767
|
-
function findEmail(_, atext, label2
|
|
71768
|
-
if (
|
|
72182
|
+
function findEmail(_, atext, label2) {
|
|
72183
|
+
if (/[\d\-_]$/.test(label2)) {
|
|
71769
72184
|
return false;
|
|
71770
72185
|
}
|
|
71771
72186
|
return {
|
|
71772
72187
|
type: "link",
|
|
71773
72188
|
title: null,
|
|
71774
72189
|
url: "mailto:" + atext + "@" + label2,
|
|
71775
|
-
children: [{ type: "text", value: atext + "@" + label2 }]
|
|
72190
|
+
children: [{ type: "text", value: atext + "@" + label2, position: undefined }],
|
|
72191
|
+
position: undefined
|
|
72192
|
+
};
|
|
72193
|
+
}
|
|
72194
|
+
function findMailto(_, atext, label2) {
|
|
72195
|
+
if (/[\d\-_]$/.test(label2)) {
|
|
72196
|
+
return false;
|
|
72197
|
+
}
|
|
72198
|
+
const value = "mailto:" + atext + "@" + label2;
|
|
72199
|
+
return {
|
|
72200
|
+
type: "link",
|
|
72201
|
+
title: null,
|
|
72202
|
+
url: value,
|
|
72203
|
+
children: [{ type: "text", value, position: undefined }],
|
|
72204
|
+
position: undefined
|
|
72205
|
+
};
|
|
72206
|
+
}
|
|
72207
|
+
function findXmpp(matchValue, atext, label2, resource, match) {
|
|
72208
|
+
if (/[\d\-_]$/.test(label2) || resource && (!/[A-Za-z]$/.test(resource) || match.input.charAt(match.index + matchValue.length) === "@")) {
|
|
72209
|
+
return false;
|
|
72210
|
+
}
|
|
72211
|
+
const value = "xmpp:" + atext + "@" + label2 + (resource || "");
|
|
72212
|
+
return {
|
|
72213
|
+
type: "link",
|
|
72214
|
+
title: null,
|
|
72215
|
+
url: value,
|
|
72216
|
+
children: [{ type: "text", value, position: undefined }],
|
|
72217
|
+
position: undefined
|
|
71776
72218
|
};
|
|
71777
72219
|
}
|
|
71778
72220
|
function isCorrectDomain(domain2) {
|
|
71779
72221
|
const parts = domain2.split(".");
|
|
71780
|
-
if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[
|
|
72222
|
+
if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[\dA-Za-z]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[\dA-Za-z]/.test(parts[parts.length - 2]))) {
|
|
71781
72223
|
return false;
|
|
71782
72224
|
}
|
|
71783
72225
|
return true;
|
|
71784
72226
|
}
|
|
71785
72227
|
function splitUrl(url2) {
|
|
71786
|
-
|
|
71787
|
-
|
|
72228
|
+
let index3 = url2.length;
|
|
72229
|
+
while (index3 > 0) {
|
|
72230
|
+
const code = url2.charCodeAt(index3 - 1);
|
|
72231
|
+
if (code === 33 || code === 34 || code === 38 || code === 39 || code === 41 || code === 44 || code === 46 || code === 58 || code === 59 || code === 60 || code === 62 || code === 63 || code === 93 || code === 125) {
|
|
72232
|
+
index3--;
|
|
72233
|
+
} else {
|
|
72234
|
+
break;
|
|
72235
|
+
}
|
|
72236
|
+
}
|
|
72237
|
+
if (index3 === url2.length) {
|
|
71788
72238
|
return [url2, undefined];
|
|
71789
72239
|
}
|
|
71790
|
-
|
|
71791
|
-
|
|
72240
|
+
let trail = url2.slice(index3);
|
|
72241
|
+
url2 = url2.slice(0, index3);
|
|
71792
72242
|
let closingParenIndex = trail.indexOf(")");
|
|
71793
72243
|
const openingParens = ccount(url2, "(");
|
|
71794
72244
|
let closingParens = ccount(url2, ")");
|
|
@@ -71800,9 +72250,9 @@ function splitUrl(url2) {
|
|
|
71800
72250
|
}
|
|
71801
72251
|
return [url2, trail];
|
|
71802
72252
|
}
|
|
71803
|
-
function previous2(match
|
|
72253
|
+
function previous2(match) {
|
|
71804
72254
|
const code = match.input.charCodeAt(match.index - 1);
|
|
71805
|
-
return
|
|
72255
|
+
return match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code);
|
|
71806
72256
|
}
|
|
71807
72257
|
// ../../node_modules/.pnpm/mdast-util-gfm-footnote@2.1.0/node_modules/mdast-util-gfm-footnote/lib/index.js
|
|
71808
72258
|
footnoteReference.peek = footnoteReferencePeek;
|
|
@@ -72335,25 +72785,37 @@ function emphasisPeek(_, _1, state) {
|
|
|
72335
72785
|
return state.options.emphasis || "*";
|
|
72336
72786
|
}
|
|
72337
72787
|
|
|
72338
|
-
// ../../node_modules/.pnpm/unist-util-visit@5.
|
|
72339
|
-
function visit2(tree,
|
|
72788
|
+
// ../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
|
|
72789
|
+
function visit2(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
|
|
72790
|
+
let check3;
|
|
72791
|
+
let visitors;
|
|
72340
72792
|
let reverse;
|
|
72341
|
-
|
|
72342
|
-
|
|
72343
|
-
|
|
72344
|
-
test = undefined;
|
|
72345
|
-
visitor = testOrVisitor;
|
|
72346
|
-
reverse = visitorOrReverse;
|
|
72347
|
-
} else {
|
|
72348
|
-
test = testOrVisitor;
|
|
72349
|
-
visitor = visitorOrReverse;
|
|
72793
|
+
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
72794
|
+
check3 = testOrEnterOrVisitors;
|
|
72795
|
+
visitors = enterOrVisitorsOrReverse;
|
|
72350
72796
|
reverse = maybeReverse;
|
|
72797
|
+
} else {
|
|
72798
|
+
visitors = testOrEnterOrVisitors;
|
|
72799
|
+
reverse = enterOrVisitorsOrReverse;
|
|
72351
72800
|
}
|
|
72352
|
-
|
|
72353
|
-
|
|
72354
|
-
|
|
72355
|
-
|
|
72356
|
-
|
|
72801
|
+
if (typeof visitors === "function") {
|
|
72802
|
+
visitParents(tree, check3, wrap2(visitors), reverse);
|
|
72803
|
+
} else {
|
|
72804
|
+
visitParents(tree, check3, wrapVisitors(visitors), reverse);
|
|
72805
|
+
}
|
|
72806
|
+
}
|
|
72807
|
+
function wrapVisitors(visitors) {
|
|
72808
|
+
if (!visitors || typeof visitors !== "object")
|
|
72809
|
+
return visitors;
|
|
72810
|
+
return {
|
|
72811
|
+
enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
|
|
72812
|
+
exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
|
|
72813
|
+
};
|
|
72814
|
+
}
|
|
72815
|
+
function wrap2(visitor) {
|
|
72816
|
+
return overload;
|
|
72817
|
+
function overload(node3, parents, index3) {
|
|
72818
|
+
return visitor(node3, index3, parents[parents.length - 1]);
|
|
72357
72819
|
}
|
|
72358
72820
|
}
|
|
72359
72821
|
// ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
@@ -75430,43 +75892,10 @@ function peek(_, _1, state) {
|
|
|
75430
75892
|
return state.options.emphasis || "*";
|
|
75431
75893
|
}
|
|
75432
75894
|
|
|
75433
|
-
// ../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
|
|
75434
|
-
function visit3(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
|
|
75435
|
-
let check4;
|
|
75436
|
-
let visitors;
|
|
75437
|
-
let reverse;
|
|
75438
|
-
if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
|
|
75439
|
-
check4 = testOrEnterOrVisitors;
|
|
75440
|
-
visitors = enterOrVisitorsOrReverse;
|
|
75441
|
-
reverse = maybeReverse;
|
|
75442
|
-
} else {
|
|
75443
|
-
visitors = testOrEnterOrVisitors;
|
|
75444
|
-
reverse = enterOrVisitorsOrReverse;
|
|
75445
|
-
}
|
|
75446
|
-
if (typeof visitors === "function") {
|
|
75447
|
-
visitParents(tree, check4, wrap2(visitors), reverse);
|
|
75448
|
-
} else {
|
|
75449
|
-
visitParents(tree, check4, wrapVisitors(visitors), reverse);
|
|
75450
|
-
}
|
|
75451
|
-
}
|
|
75452
|
-
function wrapVisitors(visitors) {
|
|
75453
|
-
if (!visitors || typeof visitors !== "object")
|
|
75454
|
-
return visitors;
|
|
75455
|
-
return {
|
|
75456
|
-
enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
|
|
75457
|
-
exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
|
|
75458
|
-
};
|
|
75459
|
-
}
|
|
75460
|
-
function wrap2(visitor) {
|
|
75461
|
-
return overload;
|
|
75462
|
-
function overload(node3, parents, index3) {
|
|
75463
|
-
return visitor(node3, index3, parents[parents.length - 1]);
|
|
75464
|
-
}
|
|
75465
|
-
}
|
|
75466
75895
|
// ../../node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
|
|
75467
75896
|
function formatHeadingAsSetext2(node3, state) {
|
|
75468
75897
|
let literalWithBreak = false;
|
|
75469
|
-
|
|
75898
|
+
visit2(node3, function(node4) {
|
|
75470
75899
|
if ("value" in node4 && /\r?\n|\r/.test(node4.value) || node4.type === "break") {
|
|
75471
75900
|
literalWithBreak = true;
|
|
75472
75901
|
return EXIT;
|
|
@@ -77855,6 +78284,19 @@ function messagingSection() {
|
|
|
77855
78284
|
"ALOOK_MESSAGE_7F3C",
|
|
77856
78285
|
"```",
|
|
77857
78286
|
"",
|
|
78287
|
+
"#### Ask for a decision",
|
|
78288
|
+
"",
|
|
78289
|
+
`Whenever you would use your native Ask Question tool, use Alook’s \`${CLI} message send --ask --remind-after 5m\` in the current conversation instead. People on Alook can only see the question you send there.`,
|
|
78290
|
+
"",
|
|
78291
|
+
"When you ask a question and can offer options, use a decision card. " + "Use a normal Alook message for updates and questions without options.",
|
|
78292
|
+
"",
|
|
78293
|
+
"Pass JSON on stdin (max 8 KiB).",
|
|
78294
|
+
"Include a required non-empty `summary` (1–240 chars). Recommend at least one option per question to help the user decide. Use `recommended: true`. Use `mentions` to name respondents, and short `header` values for multi-question tabs. Answers arrive in your inbox as replies to the original question.",
|
|
78295
|
+
"",
|
|
78296
|
+
"```json",
|
|
78297
|
+
`{"mentions":["@alice#0001"],"summary":"Confirm today's release","questions":[{"question":"Ship today?","options":[{"label":"Ship","recommended":true},"Wait"]}]}`,
|
|
78298
|
+
"```",
|
|
78299
|
+
"",
|
|
77858
78300
|
"#### Pulled messages",
|
|
77859
78301
|
"",
|
|
77860
78302
|
"```json",
|
|
@@ -77924,7 +78366,7 @@ function cliCommandsSection() {
|
|
|
77924
78366
|
"### Messaging",
|
|
77925
78367
|
"",
|
|
77926
78368
|
`1. \`${CLI} inbox pull\` — fetch unread messages and advance their read waterlines.`,
|
|
77927
|
-
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> --stdin\` —
|
|
78369
|
+
`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\`.`,
|
|
77928
78370
|
`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.`,
|
|
77929
78371
|
`4. \`${CLI} message attachment download --id <id> [--out <path>]\` — download an attachment you can read, including your own unsent uploads.`,
|
|
77930
78372
|
`5. \`${CLI} message property set --target <full-message-ref> --json <json>\` — add a supported property value to a message.`,
|
|
@@ -79804,6 +80246,9 @@ ${this.opts.wakePromptFooter}` : text8;
|
|
|
79804
80246
|
return;
|
|
79805
80247
|
}
|
|
79806
80248
|
const sessionSuperseded = owner.superseded;
|
|
80249
|
+
if (event.type === "session_activity" && !sessionSuperseded) {
|
|
80250
|
+
this.dispatch({ type: "session_activity", agentId, sessionInstanceId: event.sessionInstanceId, observation: event.observation, nowMs: this.now() }, owner);
|
|
80251
|
+
}
|
|
79807
80252
|
const runtimeError = event.type === "session_failed" ? event.error : event.type === "turn_completed" && event.result.outcome === "failed" ? event.result.error : undefined;
|
|
79808
80253
|
if (runtimeError !== undefined && !sessionSuperseded) {
|
|
79809
80254
|
this.emitErrorAudit(agentId, "runtime", runtimeError.code, runtimeError.message);
|
|
@@ -79820,12 +80265,12 @@ ${this.opts.wakePromptFooter}` : text8;
|
|
|
79820
80265
|
}
|
|
79821
80266
|
}
|
|
79822
80267
|
if (this.opts.onBotAuditEvent) {
|
|
79823
|
-
if (event.type === "assistant_message_completed" && event.text.length > 0) {
|
|
80268
|
+
if ((event.type === "assistant_message_completed" || event.type === "activity" && event.kind === "assistant_message_completed") && event.text && event.text.length > 0) {
|
|
79824
80269
|
const { text: text8, truncated, chars } = truncateAuditText(event.text);
|
|
79825
80270
|
try {
|
|
79826
80271
|
this.opts.onBotAuditEvent(agentId, {
|
|
79827
80272
|
kind: "text",
|
|
79828
|
-
payload: { text: text8, truncated: truncated || event.truncated, chars }
|
|
80273
|
+
payload: { text: text8, truncated: truncated || event.truncated === true, chars }
|
|
79829
80274
|
}, {
|
|
79830
80275
|
sessionId: this.liveSessions.get(agentId) ?? null,
|
|
79831
80276
|
launchId: this.launchIds.get(agentId) ?? null
|
|
@@ -81059,12 +81504,75 @@ async function handleLocalPii(request, response, botId, pii) {
|
|
|
81059
81504
|
writePiiError(response, error62);
|
|
81060
81505
|
}
|
|
81061
81506
|
}
|
|
81507
|
+
async function filterQuestionPii(rawQuestion, botId, pii) {
|
|
81508
|
+
const parsed = DecisionCardInputSchema.safeParse(rawQuestion);
|
|
81509
|
+
if (!parsed.success)
|
|
81510
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
81511
|
+
const triggeredById = new Map;
|
|
81512
|
+
const runField = async (value) => {
|
|
81513
|
+
const result2 = await pii.filterWithResult(botId, value);
|
|
81514
|
+
for (const filter of result2.triggeredFilters) {
|
|
81515
|
+
if (!triggeredById.has(filter.id))
|
|
81516
|
+
triggeredById.set(filter.id, filter);
|
|
81517
|
+
}
|
|
81518
|
+
return result2.text;
|
|
81519
|
+
};
|
|
81520
|
+
const source = parsed.data;
|
|
81521
|
+
const summary = await runField(source.summary);
|
|
81522
|
+
const questions = [];
|
|
81523
|
+
for (const question of source.questions) {
|
|
81524
|
+
const header = question.header !== undefined ? await runField(question.header) : undefined;
|
|
81525
|
+
const prompt = await runField(question.question);
|
|
81526
|
+
const options = [];
|
|
81527
|
+
for (const option of question.options) {
|
|
81528
|
+
const label2 = await runField(option.label);
|
|
81529
|
+
const description = option.description !== undefined ? await runField(option.description) : undefined;
|
|
81530
|
+
options.push({
|
|
81531
|
+
...option.id !== undefined ? { id: option.id } : {},
|
|
81532
|
+
label: label2,
|
|
81533
|
+
...description !== undefined ? { description } : {},
|
|
81534
|
+
...option.recommended !== undefined ? { recommended: option.recommended } : {}
|
|
81535
|
+
});
|
|
81536
|
+
}
|
|
81537
|
+
questions.push({
|
|
81538
|
+
...question.id !== undefined ? { id: question.id } : {},
|
|
81539
|
+
...header !== undefined ? { header } : {},
|
|
81540
|
+
question: prompt,
|
|
81541
|
+
...question.multiSelect !== undefined ? { multiSelect: question.multiSelect } : {},
|
|
81542
|
+
...question.allowOther !== undefined ? { allowOther: question.allowOther } : {},
|
|
81543
|
+
options
|
|
81544
|
+
});
|
|
81545
|
+
}
|
|
81546
|
+
const filtered = {
|
|
81547
|
+
...source.mentions !== undefined ? { mentions: source.mentions } : {},
|
|
81548
|
+
summary,
|
|
81549
|
+
questions
|
|
81550
|
+
};
|
|
81551
|
+
if (decisionCardUtf8Bytes(filtered) > DECISION_CARD_MAX_BYTES) {
|
|
81552
|
+
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
|
81553
|
+
}
|
|
81554
|
+
const validated = DecisionCardInputSchema.safeParse(filtered);
|
|
81555
|
+
if (!validated.success)
|
|
81556
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
81557
|
+
return { question: validated.data, triggeredFilters: [...triggeredById.values()] };
|
|
81558
|
+
}
|
|
81062
81559
|
async function filterPiiRequest(request, botId, pii) {
|
|
81063
81560
|
const body = await readJson2(request);
|
|
81064
81561
|
const content3 = body.content;
|
|
81065
81562
|
if (!content3 || typeof content3 !== "object" || Array.isArray(content3) || content3.text !== undefined && typeof content3.text !== "string") {
|
|
81066
81563
|
throw new PiiError("PII_INVALID_REQUEST");
|
|
81067
81564
|
}
|
|
81565
|
+
if (body.question !== undefined) {
|
|
81566
|
+
if ((content3.text ?? "").trim().length > 0) {
|
|
81567
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
81568
|
+
}
|
|
81569
|
+
const filteredQuestion = await filterQuestionPii(body.question, botId, pii);
|
|
81570
|
+
body.content = { ...content3, text: "" };
|
|
81571
|
+
body.question = filteredQuestion.question;
|
|
81572
|
+
if (!CommunityAgentSendRequestSchema.safeParse(body).success)
|
|
81573
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
81574
|
+
return { body: Buffer.from(JSON.stringify(body)), triggeredFilters: filteredQuestion.triggeredFilters };
|
|
81575
|
+
}
|
|
81068
81576
|
const { text: text8, triggeredFilters } = await pii.filterWithResult(botId, content3.text ?? "");
|
|
81069
81577
|
if (Buffer.byteLength(text8, "utf8") > PII_TEXT_MAX_BYTES)
|
|
81070
81578
|
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
|
@@ -81340,212 +81848,233 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
81340
81848
|
return;
|
|
81341
81849
|
}
|
|
81342
81850
|
};
|
|
81343
|
-
const server = http.createServer(
|
|
81344
|
-
|
|
81345
|
-
|
|
81346
|
-
|
|
81347
|
-
if (
|
|
81348
|
-
|
|
81349
|
-
|
|
81851
|
+
const server = http.createServer((req, res) => {
|
|
81852
|
+
(async () => {
|
|
81853
|
+
const requestUrl = new URL2(req.url ?? "/", "http://placeholder");
|
|
81854
|
+
const pathname = requestUrl.pathname;
|
|
81855
|
+
if (pathname === LOCAL_MEMORY_COMMIT_PATH) {
|
|
81856
|
+
if (req.method !== "POST" || req.url !== LOCAL_MEMORY_COMMIT_PATH) {
|
|
81857
|
+
writeJson(res, 405, { error: "method not allowed" });
|
|
81858
|
+
req.resume();
|
|
81859
|
+
return;
|
|
81860
|
+
}
|
|
81861
|
+
const verdict2 = broker.check(req.headers["authorization"], "send");
|
|
81862
|
+
if (!verdict2.ok) {
|
|
81863
|
+
writeJson(res, verdict2.status, { error: verdict2.error, code: verdict2.code });
|
|
81864
|
+
req.resume();
|
|
81865
|
+
return;
|
|
81866
|
+
}
|
|
81867
|
+
await handleLocalMemoryCommit(req, res, verdict2.reg, options.onMemoryCommit, options.onMemoryCommitResetError);
|
|
81350
81868
|
return;
|
|
81351
81869
|
}
|
|
81352
|
-
|
|
81353
|
-
|
|
81354
|
-
|
|
81355
|
-
|
|
81870
|
+
if (pathname === LOCAL_PII_PATH && (req.method === "GET" || req.method === "POST")) {
|
|
81871
|
+
const localVerdict = broker.check(req.headers["authorization"], req.method === "GET" ? "read" : "send");
|
|
81872
|
+
if (!localVerdict.ok) {
|
|
81873
|
+
writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
|
|
81874
|
+
req.resume();
|
|
81875
|
+
return;
|
|
81876
|
+
}
|
|
81877
|
+
await handleLocalPii(req, res, localVerdict.reg.agentId, options.pii);
|
|
81356
81878
|
return;
|
|
81357
81879
|
}
|
|
81358
|
-
|
|
81359
|
-
|
|
81360
|
-
|
|
81361
|
-
|
|
81362
|
-
|
|
81363
|
-
|
|
81364
|
-
|
|
81365
|
-
|
|
81880
|
+
if (pathname.startsWith("/__alook/local/")) {
|
|
81881
|
+
if (req.url !== LOCAL_MESSAGE_REMINDER_PATH) {
|
|
81882
|
+
writeJson(res, 404, { error: "unknown local route", code: "not_found" });
|
|
81883
|
+
req.resume();
|
|
81884
|
+
return;
|
|
81885
|
+
}
|
|
81886
|
+
if (req.method !== "PUT") {
|
|
81887
|
+
writeJson(res, 405, { error: "method not allowed", code: "method_not_allowed" });
|
|
81888
|
+
req.resume();
|
|
81889
|
+
return;
|
|
81890
|
+
}
|
|
81891
|
+
const localVerdict = broker.check(req.headers["authorization"], "send");
|
|
81892
|
+
if (!localVerdict.ok) {
|
|
81893
|
+
writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
|
|
81894
|
+
req.resume();
|
|
81895
|
+
return;
|
|
81896
|
+
}
|
|
81897
|
+
handleLocalMessageReminder(req, res, localVerdict.reg.agentId, options.onMessageReminderArm);
|
|
81366
81898
|
return;
|
|
81367
81899
|
}
|
|
81368
|
-
|
|
81369
|
-
|
|
81370
|
-
|
|
81371
|
-
|
|
81372
|
-
|
|
81373
|
-
|
|
81900
|
+
const route = resolveProxyRoute(pathname, req.method ?? "GET", req.url ?? pathname);
|
|
81901
|
+
const requiredCap = resolveCap ? resolveCap(req.method ?? "GET", pathname) : route.capability;
|
|
81902
|
+
const verdict = broker.check(req.headers["authorization"], requiredCap);
|
|
81903
|
+
if (!verdict.ok) {
|
|
81904
|
+
res.writeHead(verdict.status, { "content-type": "application/json" });
|
|
81905
|
+
res.end(JSON.stringify({ error: verdict.error, code: verdict.code }));
|
|
81374
81906
|
req.resume();
|
|
81375
81907
|
return;
|
|
81376
81908
|
}
|
|
81377
|
-
if (req.method
|
|
81378
|
-
writeJson(res,
|
|
81379
|
-
req.resume();
|
|
81909
|
+
if (pathname.startsWith("/api/community/machines") && !(req.method === "GET" && /^\/api\/community\/machines(?:\/[^/]+(?:\/models)?)?$/.test(pathname) || req.method === "POST" && /^\/api\/community\/machines\/[^/]+\/discover-models$/.test(pathname))) {
|
|
81910
|
+
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
81380
81911
|
return;
|
|
81381
81912
|
}
|
|
81382
|
-
const
|
|
81383
|
-
if (
|
|
81384
|
-
|
|
81913
|
+
const canonicalCommunityDoor = pathname === "/api/community/platform/feedback" || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
81914
|
+
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
81915
|
+
res.writeHead(404, { "content-type": "application/json" });
|
|
81916
|
+
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
81385
81917
|
req.resume();
|
|
81386
81918
|
return;
|
|
81387
81919
|
}
|
|
81388
|
-
|
|
81389
|
-
|
|
81390
|
-
|
|
81391
|
-
const route = resolveProxyRoute(pathname, req.method ?? "GET", req.url ?? pathname);
|
|
81392
|
-
const requiredCap = resolveCap ? resolveCap(req.method ?? "GET", pathname) : route.capability;
|
|
81393
|
-
const verdict = broker.check(req.headers["authorization"], requiredCap);
|
|
81394
|
-
if (!verdict.ok) {
|
|
81395
|
-
res.writeHead(verdict.status, { "content-type": "application/json" });
|
|
81396
|
-
res.end(JSON.stringify({ error: verdict.error, code: verdict.code }));
|
|
81397
|
-
req.resume();
|
|
81398
|
-
return;
|
|
81399
|
-
}
|
|
81400
|
-
if (pathname.startsWith("/api/community/machines") && !(req.method === "GET" && /^\/api\/community\/machines(?:\/[^/]+(?:\/models)?)?$/.test(pathname) || req.method === "POST" && /^\/api\/community\/machines\/[^/]+\/discover-models$/.test(pathname))) {
|
|
81401
|
-
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
81402
|
-
return;
|
|
81403
|
-
}
|
|
81404
|
-
const canonicalCommunityDoor = pathname === "/api/community/platform/feedback" || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
81405
|
-
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
81406
|
-
res.writeHead(404, { "content-type": "application/json" });
|
|
81407
|
-
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
81408
|
-
req.resume();
|
|
81409
|
-
return;
|
|
81410
|
-
}
|
|
81411
|
-
if (/^\/api\/community\/bots\/me\/nap(?:\/|$)/.test(pathname)) {
|
|
81412
|
-
writeJson(res, 410, { error: "nap was removed; use local commit to record a memory review", code: "command_removed" });
|
|
81413
|
-
req.resume();
|
|
81414
|
-
return;
|
|
81415
|
-
}
|
|
81416
|
-
const reg = verdict.reg;
|
|
81417
|
-
if (/^\/api\/community\/bots\/[^/]+\/pii\/?$/.test(pathname)) {
|
|
81418
|
-
writeJson(res, 403, { error: "PII management requires a human owner session", code: "forbidden" });
|
|
81419
|
-
req.resume();
|
|
81420
|
-
return;
|
|
81421
|
-
}
|
|
81422
|
-
let filteredBody;
|
|
81423
|
-
let piiTriggeredFilters = [];
|
|
81424
|
-
if (options.pii && route.filterPiiSend) {
|
|
81425
|
-
try {
|
|
81426
|
-
const filtered = await filterPiiRequest(req, reg.agentId, options.pii);
|
|
81427
|
-
filteredBody = filtered.body;
|
|
81428
|
-
piiTriggeredFilters = filtered.triggeredFilters;
|
|
81429
|
-
} catch (error62) {
|
|
81430
|
-
writePiiError(res, error62);
|
|
81920
|
+
if (/^\/api\/community\/bots\/me\/nap(?:\/|$)/.test(pathname)) {
|
|
81921
|
+
writeJson(res, 410, { error: "nap was removed; use local commit to record a memory review", code: "command_removed" });
|
|
81922
|
+
req.resume();
|
|
81431
81923
|
return;
|
|
81432
81924
|
}
|
|
81433
|
-
|
|
81925
|
+
const reg = verdict.reg;
|
|
81926
|
+
if (/^\/api\/community\/bots\/[^/]+\/pii\/?$/.test(pathname)) {
|
|
81927
|
+
writeJson(res, 403, { error: "PII management requires a human owner session", code: "forbidden" });
|
|
81928
|
+
req.resume();
|
|
81434
81929
|
return;
|
|
81435
|
-
}
|
|
81436
|
-
const isInboxPull = route.inboxObservation === "pull";
|
|
81437
|
-
const isInboxAck = route.inboxObservation === "ack";
|
|
81438
|
-
const shouldObserveInboxPull = Boolean(isInboxPull && onPull);
|
|
81439
|
-
const shouldObserveInboxAck = Boolean(isInboxAck && onAck);
|
|
81440
|
-
let inboxPullObservationToken;
|
|
81441
|
-
let inboxAckObservationToken;
|
|
81442
|
-
if (shouldObserveInboxPull) {
|
|
81443
|
-
try {
|
|
81444
|
-
inboxPullObservationToken = options.onInboxPullStart?.(reg.agentId);
|
|
81445
|
-
} catch {
|
|
81446
|
-
reportInboxPullObservationError({
|
|
81447
|
-
agentId: reg.agentId,
|
|
81448
|
-
reason: "observer_failed",
|
|
81449
|
-
contentEncoding: "identity"
|
|
81450
|
-
});
|
|
81451
81930
|
}
|
|
81452
|
-
|
|
81453
|
-
|
|
81454
|
-
|
|
81455
|
-
|
|
81456
|
-
|
|
81457
|
-
|
|
81458
|
-
|
|
81459
|
-
|
|
81460
|
-
|
|
81461
|
-
|
|
81931
|
+
let filteredBody;
|
|
81932
|
+
let piiTriggeredFilters = [];
|
|
81933
|
+
if (options.pii && route.filterPiiSend) {
|
|
81934
|
+
try {
|
|
81935
|
+
const filtered = await filterPiiRequest(req, reg.agentId, options.pii);
|
|
81936
|
+
filteredBody = filtered.body;
|
|
81937
|
+
piiTriggeredFilters = filtered.triggeredFilters;
|
|
81938
|
+
} catch (error62) {
|
|
81939
|
+
writePiiError(res, error62);
|
|
81940
|
+
return;
|
|
81941
|
+
}
|
|
81942
|
+
if (res.destroyed)
|
|
81943
|
+
return;
|
|
81462
81944
|
}
|
|
81463
|
-
|
|
81464
|
-
|
|
81465
|
-
|
|
81466
|
-
|
|
81467
|
-
|
|
81468
|
-
|
|
81469
|
-
|
|
81470
|
-
|
|
81471
|
-
|
|
81472
|
-
|
|
81473
|
-
|
|
81474
|
-
|
|
81475
|
-
|
|
81476
|
-
|
|
81477
|
-
|
|
81478
|
-
|
|
81479
|
-
|
|
81480
|
-
|
|
81481
|
-
|
|
81482
|
-
|
|
81483
|
-
|
|
81484
|
-
|
|
81485
|
-
|
|
81486
|
-
|
|
81487
|
-
|
|
81488
|
-
|
|
81489
|
-
|
|
81490
|
-
|
|
81491
|
-
|
|
81492
|
-
|
|
81493
|
-
|
|
81494
|
-
|
|
81495
|
-
|
|
81496
|
-
|
|
81497
|
-
const
|
|
81498
|
-
|
|
81499
|
-
|
|
81500
|
-
}
|
|
81501
|
-
|
|
81502
|
-
|
|
81503
|
-
|
|
81504
|
-
|
|
81505
|
-
|
|
81506
|
-
|
|
81507
|
-
|
|
81508
|
-
|
|
81509
|
-
|
|
81510
|
-
|
|
81511
|
-
|
|
81512
|
-
|
|
81513
|
-
|
|
81514
|
-
|
|
81515
|
-
|
|
81516
|
-
|
|
81517
|
-
|
|
81518
|
-
|
|
81519
|
-
|
|
81520
|
-
|
|
81521
|
-
|
|
81522
|
-
|
|
81523
|
-
|
|
81524
|
-
|
|
81525
|
-
|
|
81526
|
-
|
|
81527
|
-
|
|
81945
|
+
const isInboxPull = route.inboxObservation === "pull";
|
|
81946
|
+
const isInboxAck = route.inboxObservation === "ack";
|
|
81947
|
+
const shouldObserveInboxPull = Boolean(isInboxPull && onPull);
|
|
81948
|
+
const shouldObserveInboxAck = Boolean(isInboxAck && onAck);
|
|
81949
|
+
let inboxPullObservationToken;
|
|
81950
|
+
let inboxAckObservationToken;
|
|
81951
|
+
if (shouldObserveInboxPull) {
|
|
81952
|
+
try {
|
|
81953
|
+
inboxPullObservationToken = options.onInboxPullStart?.(reg.agentId);
|
|
81954
|
+
} catch {
|
|
81955
|
+
reportInboxPullObservationError({
|
|
81956
|
+
agentId: reg.agentId,
|
|
81957
|
+
reason: "observer_failed",
|
|
81958
|
+
contentEncoding: "identity"
|
|
81959
|
+
});
|
|
81960
|
+
}
|
|
81961
|
+
}
|
|
81962
|
+
if (shouldObserveInboxAck) {
|
|
81963
|
+
try {
|
|
81964
|
+
inboxAckObservationToken = options.onInboxAckStart?.(reg.agentId);
|
|
81965
|
+
} catch {
|
|
81966
|
+
reportInboxAckObservationError({
|
|
81967
|
+
agentId: reg.agentId,
|
|
81968
|
+
reason: "observer_failed",
|
|
81969
|
+
contentEncoding: "identity"
|
|
81970
|
+
});
|
|
81971
|
+
}
|
|
81972
|
+
}
|
|
81973
|
+
if (onProxyRequest) {
|
|
81974
|
+
try {
|
|
81975
|
+
const method = req.method ?? "GET";
|
|
81976
|
+
onProxyRequest(reg.agentId, method, pathname, route.propertyMetadata, route.auditOperation);
|
|
81977
|
+
} catch {}
|
|
81978
|
+
}
|
|
81979
|
+
const outHeaders = { ...req.headers };
|
|
81980
|
+
delete outHeaders["authorization"];
|
|
81981
|
+
delete outHeaders["host"];
|
|
81982
|
+
outHeaders["authorization"] = `Bearer ${reg.runnerKey}`;
|
|
81983
|
+
outHeaders[broker.headerNames.agentId.toLowerCase()] = reg.agentId;
|
|
81984
|
+
outHeaders[broker.headerNames.client.toLowerCase()] = broker.clientLabel;
|
|
81985
|
+
outHeaders[broker.headerNames.capabilities.toLowerCase()] = [...reg.capabilities].join(",");
|
|
81986
|
+
if (isInboxPull || isInboxAck)
|
|
81987
|
+
outHeaders["accept-encoding"] = "identity";
|
|
81988
|
+
if (filteredBody) {
|
|
81989
|
+
delete outHeaders["transfer-encoding"];
|
|
81990
|
+
outHeaders["content-length"] = filteredBody.byteLength;
|
|
81991
|
+
}
|
|
81992
|
+
let responded = false;
|
|
81993
|
+
if (piiTriggeredFilters.length)
|
|
81994
|
+
outHeaders["accept-encoding"] = "identity";
|
|
81995
|
+
let upstreamRes;
|
|
81996
|
+
const upstreamReq = upstreamClient.request({
|
|
81997
|
+
protocol: upstream.protocol,
|
|
81998
|
+
hostname: upstream.hostname,
|
|
81999
|
+
port: upstream.port || (upstream.protocol === "https:" ? 443 : 80),
|
|
82000
|
+
method: req.method,
|
|
82001
|
+
path: joinPath(upstream.pathname, req.url ?? "/"),
|
|
82002
|
+
headers: outHeaders
|
|
82003
|
+
}, (res_) => {
|
|
82004
|
+
responded = true;
|
|
82005
|
+
upstreamRes = res_;
|
|
82006
|
+
const destroyResIfIncomplete = () => {
|
|
82007
|
+
if (!res_.complete)
|
|
82008
|
+
res.destroy();
|
|
82009
|
+
};
|
|
82010
|
+
res_.on("error", destroyResIfIncomplete);
|
|
82011
|
+
res_.on("close", destroyResIfIncomplete);
|
|
82012
|
+
if ((shouldObserveInboxPull || shouldObserveInboxAck) && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300) {
|
|
82013
|
+
const chunks = [];
|
|
82014
|
+
res_.on("data", (chunk2) => chunks.push(chunk2));
|
|
82015
|
+
res_.on("end", () => {
|
|
82016
|
+
const body = Buffer.concat(chunks);
|
|
82017
|
+
const contentEncoding = normalizeContentEncoding(res_.headers["content-encoding"]);
|
|
82018
|
+
if (contentEncoding !== "identity") {
|
|
81528
82019
|
if (shouldObserveInboxPull) {
|
|
81529
|
-
reportInboxPullObservationError({
|
|
82020
|
+
reportInboxPullObservationError({
|
|
82021
|
+
agentId: reg.agentId,
|
|
82022
|
+
reason: "unexpected_content_encoding",
|
|
82023
|
+
contentEncoding
|
|
82024
|
+
});
|
|
81530
82025
|
} else {
|
|
81531
|
-
reportInboxAckObservationError({
|
|
82026
|
+
reportInboxAckObservationError({
|
|
82027
|
+
agentId: reg.agentId,
|
|
82028
|
+
reason: "unexpected_content_encoding",
|
|
82029
|
+
contentEncoding
|
|
82030
|
+
});
|
|
81532
82031
|
}
|
|
81533
|
-
}
|
|
81534
|
-
|
|
81535
|
-
|
|
81536
|
-
|
|
81537
|
-
|
|
82032
|
+
} else {
|
|
82033
|
+
let parsed;
|
|
82034
|
+
try {
|
|
82035
|
+
parsed = JSON.parse(body.toString("utf8"));
|
|
82036
|
+
} catch {
|
|
82037
|
+
if (shouldObserveInboxPull) {
|
|
82038
|
+
reportInboxPullObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
|
|
82039
|
+
} else {
|
|
82040
|
+
reportInboxAckObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
|
|
82041
|
+
}
|
|
82042
|
+
}
|
|
82043
|
+
if (parsed !== undefined) {
|
|
82044
|
+
if (shouldObserveInboxPull) {
|
|
82045
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.messages)) {
|
|
82046
|
+
reportInboxPullObservationError({
|
|
82047
|
+
agentId: reg.agentId,
|
|
82048
|
+
reason: "invalid_inbox_shape",
|
|
82049
|
+
contentEncoding
|
|
82050
|
+
});
|
|
82051
|
+
} else {
|
|
82052
|
+
const messages = parsed.messages;
|
|
82053
|
+
if (messages.length > 0) {
|
|
82054
|
+
try {
|
|
82055
|
+
onPull(reg.agentId, messages, inboxPullObservationToken);
|
|
82056
|
+
} catch {
|
|
82057
|
+
reportInboxPullObservationError({
|
|
82058
|
+
agentId: reg.agentId,
|
|
82059
|
+
reason: "observer_failed",
|
|
82060
|
+
contentEncoding
|
|
82061
|
+
});
|
|
82062
|
+
}
|
|
82063
|
+
}
|
|
82064
|
+
}
|
|
82065
|
+
} else if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.applied) || !parsed.applied.every((cursor) => Boolean(cursor) && typeof cursor === "object" && !Array.isArray(cursor) && typeof cursor.channel === "string" && cursor.channel.length > 0 && typeof cursor.seq === "number" && Number.isSafeInteger(cursor.seq) && cursor.seq > 0)) {
|
|
82066
|
+
reportInboxAckObservationError({
|
|
81538
82067
|
agentId: reg.agentId,
|
|
81539
|
-
reason: "
|
|
82068
|
+
reason: "invalid_ack_shape",
|
|
81540
82069
|
contentEncoding
|
|
81541
82070
|
});
|
|
81542
82071
|
} else {
|
|
81543
|
-
const
|
|
81544
|
-
if (
|
|
82072
|
+
const applied = parsed.applied;
|
|
82073
|
+
if (applied.length > 0) {
|
|
81545
82074
|
try {
|
|
81546
|
-
|
|
82075
|
+
onAck(reg.agentId, applied, inboxAckObservationToken);
|
|
81547
82076
|
} catch {
|
|
81548
|
-
|
|
82077
|
+
reportInboxAckObservationError({
|
|
81549
82078
|
agentId: reg.agentId,
|
|
81550
82079
|
reason: "observer_failed",
|
|
81551
82080
|
contentEncoding
|
|
@@ -81553,66 +82082,47 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
81553
82082
|
}
|
|
81554
82083
|
}
|
|
81555
82084
|
}
|
|
81556
|
-
} else if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.applied) || !parsed.applied.every((cursor) => Boolean(cursor) && typeof cursor === "object" && !Array.isArray(cursor) && typeof cursor.channel === "string" && cursor.channel.length > 0 && typeof cursor.seq === "number" && Number.isSafeInteger(cursor.seq) && cursor.seq > 0)) {
|
|
81557
|
-
reportInboxAckObservationError({
|
|
81558
|
-
agentId: reg.agentId,
|
|
81559
|
-
reason: "invalid_ack_shape",
|
|
81560
|
-
contentEncoding
|
|
81561
|
-
});
|
|
81562
|
-
} else {
|
|
81563
|
-
const applied = parsed.applied;
|
|
81564
|
-
if (applied.length > 0) {
|
|
81565
|
-
try {
|
|
81566
|
-
onAck(reg.agentId, applied, inboxAckObservationToken);
|
|
81567
|
-
} catch {
|
|
81568
|
-
reportInboxAckObservationError({
|
|
81569
|
-
agentId: reg.agentId,
|
|
81570
|
-
reason: "observer_failed",
|
|
81571
|
-
contentEncoding
|
|
81572
|
-
});
|
|
81573
|
-
}
|
|
81574
|
-
}
|
|
81575
82085
|
}
|
|
81576
82086
|
}
|
|
81577
|
-
|
|
81578
|
-
|
|
81579
|
-
|
|
81580
|
-
})
|
|
81581
|
-
|
|
81582
|
-
|
|
81583
|
-
|
|
81584
|
-
|
|
81585
|
-
|
|
81586
|
-
}
|
|
81587
|
-
|
|
81588
|
-
|
|
81589
|
-
|
|
81590
|
-
|
|
81591
|
-
|
|
81592
|
-
|
|
81593
|
-
|
|
81594
|
-
|
|
81595
|
-
|
|
81596
|
-
|
|
81597
|
-
|
|
81598
|
-
|
|
81599
|
-
|
|
81600
|
-
|
|
81601
|
-
|
|
81602
|
-
|
|
81603
|
-
|
|
81604
|
-
|
|
81605
|
-
|
|
81606
|
-
|
|
81607
|
-
|
|
81608
|
-
|
|
81609
|
-
|
|
81610
|
-
|
|
81611
|
-
|
|
81612
|
-
|
|
81613
|
-
|
|
81614
|
-
|
|
81615
|
-
|
|
82087
|
+
res.writeHead(res_.statusCode, res_.headers);
|
|
82088
|
+
res.end(body);
|
|
82089
|
+
});
|
|
82090
|
+
} else if (piiTriggeredFilters.length && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300 && normalizeContentEncoding(res_.headers["content-encoding"]) === "identity") {
|
|
82091
|
+
forwardPiiSendResponse(res_, res, piiTriggeredFilters);
|
|
82092
|
+
} else {
|
|
82093
|
+
res.writeHead(res_.statusCode ?? 502, res_.headers);
|
|
82094
|
+
res_.pipe(res);
|
|
82095
|
+
}
|
|
82096
|
+
});
|
|
82097
|
+
upstreamReq.on("error", (err) => {
|
|
82098
|
+
if (responded)
|
|
82099
|
+
return;
|
|
82100
|
+
responded = true;
|
|
82101
|
+
res.writeHead(502, { "content-type": "application/json" });
|
|
82102
|
+
res.end(JSON.stringify({ error: `upstream error: ${err.message}`, code: "upstream_error" }));
|
|
82103
|
+
});
|
|
82104
|
+
const waitingForModels = route.modelDiscovery && requestUrl.searchParams.get("wait") === "1";
|
|
82105
|
+
const upstreamTimeoutMs = options.upstreamTimeoutMs ?? (waitingForModels ? 55000 : DEFAULT_UPSTREAM_TIMEOUT_MS);
|
|
82106
|
+
upstreamReq.setTimeout(upstreamTimeoutMs, () => {
|
|
82107
|
+
upstreamReq.destroy();
|
|
82108
|
+
upstreamRes?.destroy();
|
|
82109
|
+
if (responded) {
|
|
82110
|
+
res.destroy();
|
|
82111
|
+
return;
|
|
82112
|
+
}
|
|
82113
|
+
responded = true;
|
|
82114
|
+
res.writeHead(504, { "content-type": "application/json" });
|
|
82115
|
+
res.end(JSON.stringify({ error: `upstream request timed out after ${upstreamTimeoutMs}ms`, code: "upstream_timeout" }));
|
|
82116
|
+
});
|
|
82117
|
+
res.on("close", () => {
|
|
82118
|
+
upstreamReq.destroy();
|
|
82119
|
+
upstreamRes?.destroy();
|
|
82120
|
+
});
|
|
82121
|
+
if (filteredBody)
|
|
82122
|
+
upstreamReq.end(filteredBody);
|
|
82123
|
+
else
|
|
82124
|
+
req.pipe(upstreamReq);
|
|
82125
|
+
})();
|
|
81616
82126
|
});
|
|
81617
82127
|
await new Promise((resolve6, reject) => {
|
|
81618
82128
|
server.once("error", reject);
|