@alook/daemon 0.1.73 → 0.1.74
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 +409 -19
- package/dist/index.js +409 -19
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -47680,8 +47680,59 @@ var communityScheduleRun = sqliteTable("community_schedule_run", {
|
|
|
47680
47680
|
index("idx_community_schedule_run_bot_id_lookup").on(t.botUserId)
|
|
47681
47681
|
]);
|
|
47682
47682
|
|
|
47683
|
+
// ../shared/src/db/community-bot-private-inbox-schema.ts
|
|
47684
|
+
var exports_community_bot_private_inbox_schema = {};
|
|
47685
|
+
__export(exports_community_bot_private_inbox_schema, {
|
|
47686
|
+
communityBotPrivateInbox: () => communityBotPrivateInbox
|
|
47687
|
+
});
|
|
47688
|
+
var communityBotPrivateInbox = sqliteTable("community_bot_private_inbox", {
|
|
47689
|
+
id: text("id").primaryKey(),
|
|
47690
|
+
ownerUserId: text("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
47691
|
+
botUserId: text("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
47692
|
+
sourceKind: text("source_kind").$type().notNull(),
|
|
47693
|
+
sourceId: text("source_id").notNull(),
|
|
47694
|
+
sourceRefId: text("source_ref_id"),
|
|
47695
|
+
dedupeKey: text("dedupe_key"),
|
|
47696
|
+
eventType: text("event_type").notNull(),
|
|
47697
|
+
summary: text("summary").notNull(),
|
|
47698
|
+
promptText: text("prompt_text").notNull(),
|
|
47699
|
+
status: text("status").$type().notNull(),
|
|
47700
|
+
lastError: text("last_error"),
|
|
47701
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
47702
|
+
dispatchedAtMs: integer2("dispatched_at_ms")
|
|
47703
|
+
}, (t) => [
|
|
47704
|
+
uniqueIndex("uq_community_bot_private_inbox_dedupe").on(t.sourceKind, t.sourceId, t.dedupeKey).where(sql`${t.dedupeKey} IS NOT NULL`),
|
|
47705
|
+
index("idx_community_bot_private_inbox_bot_pending").on(t.botUserId, t.status, t.createdAtMs),
|
|
47706
|
+
index("idx_community_bot_private_inbox_source_created").on(t.sourceKind, t.sourceId, t.createdAtMs),
|
|
47707
|
+
index("idx_community_bot_private_inbox_owner").on(t.ownerUserId)
|
|
47708
|
+
]);
|
|
47709
|
+
|
|
47710
|
+
// ../shared/src/db/community-bot-webhook-schema.ts
|
|
47711
|
+
var exports_community_bot_webhook_schema = {};
|
|
47712
|
+
__export(exports_community_bot_webhook_schema, {
|
|
47713
|
+
communityBotWebhook: () => communityBotWebhook
|
|
47714
|
+
});
|
|
47715
|
+
var communityBotWebhook = sqliteTable("community_bot_webhook", {
|
|
47716
|
+
id: text("id").primaryKey(),
|
|
47717
|
+
ownerUserId: text("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
47718
|
+
botUserId: text("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
47719
|
+
name: text("name").notNull(),
|
|
47720
|
+
provider: text("provider").$type().notNull(),
|
|
47721
|
+
tokenHash: text("token_hash").notNull().unique(),
|
|
47722
|
+
signingSecretEnc: text("signing_secret_enc"),
|
|
47723
|
+
eventFilterJson: text("event_filter_json"),
|
|
47724
|
+
instruction: text("instruction").notNull().default(""),
|
|
47725
|
+
enabled: integer2("enabled", { mode: "boolean" }).notNull().default(true),
|
|
47726
|
+
lastTriggeredAtMs: integer2("last_triggered_at_ms"),
|
|
47727
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
47728
|
+
updatedAtMs: integer2("updated_at_ms").notNull()
|
|
47729
|
+
}, (t) => [
|
|
47730
|
+
index("idx_community_bot_webhook_owner_bot").on(t.ownerUserId, t.botUserId, t.createdAtMs),
|
|
47731
|
+
index("idx_community_bot_webhook_bot").on(t.botUserId)
|
|
47732
|
+
]);
|
|
47733
|
+
|
|
47683
47734
|
// ../shared/src/db/index.ts
|
|
47684
|
-
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_community_schedule_schema };
|
|
47735
|
+
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_community_schedule_schema, ...exports_community_bot_private_inbox_schema, ...exports_community_bot_webhook_schema };
|
|
47685
47736
|
// ../shared/src/db/queries/native-oauth.ts
|
|
47686
47737
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
47687
47738
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
@@ -47830,6 +47881,107 @@ function isValidIanaTimeZone(timeZone) {
|
|
|
47830
47881
|
}
|
|
47831
47882
|
}
|
|
47832
47883
|
var formatterCache = new Map;
|
|
47884
|
+
// ../shared/src/bot-webhook.ts
|
|
47885
|
+
var BOT_WEBHOOK_PROVIDERS = [
|
|
47886
|
+
"github",
|
|
47887
|
+
"linear",
|
|
47888
|
+
"sentry",
|
|
47889
|
+
"stripe",
|
|
47890
|
+
"vercel",
|
|
47891
|
+
"gitlab",
|
|
47892
|
+
"slack",
|
|
47893
|
+
"openai",
|
|
47894
|
+
"resend",
|
|
47895
|
+
"clerk",
|
|
47896
|
+
"polar",
|
|
47897
|
+
"cloudflare",
|
|
47898
|
+
"grafana",
|
|
47899
|
+
"datadog",
|
|
47900
|
+
"n8n",
|
|
47901
|
+
"generic"
|
|
47902
|
+
];
|
|
47903
|
+
var BOT_WEBHOOK_DELIVERY_STATUSES = ["pending", "dispatched", "ignored", "failed"];
|
|
47904
|
+
var BOT_WEBHOOK_NAME_MAX_LENGTH = 80;
|
|
47905
|
+
var BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH = 500;
|
|
47906
|
+
var BOT_WEBHOOK_SECRET_MIN_LENGTH = 8;
|
|
47907
|
+
var BOT_WEBHOOK_SECRET_MAX_LENGTH = 256;
|
|
47908
|
+
var BOT_WEBHOOK_MAX_EVENT_FILTERS = 32;
|
|
47909
|
+
var BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH = 64;
|
|
47910
|
+
var BOT_WEBHOOK_RESYNC_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
47911
|
+
var BotWebhookProviderSchema = exports_external.enum(BOT_WEBHOOK_PROVIDERS);
|
|
47912
|
+
var BotWebhookDeliveryStatusSchema = exports_external.enum(BOT_WEBHOOK_DELIVERY_STATUSES);
|
|
47913
|
+
var EventFilterEntrySchema = exports_external.string().trim().min(1).max(BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH).regex(/^[a-z0-9_.-]+$/i, "Event name may only contain letters, digits, _, ., and -");
|
|
47914
|
+
var BotWebhookEventFilterSchema = exports_external.array(EventFilterEntrySchema).max(BOT_WEBHOOK_MAX_EVENT_FILTERS).transform((items) => [...new Set(items.map((item) => item.toLowerCase()))]);
|
|
47915
|
+
var SigningSecretInputSchema = exports_external.string().trim().min(BOT_WEBHOOK_SECRET_MIN_LENGTH, `Verification key must be at least ${BOT_WEBHOOK_SECRET_MIN_LENGTH} characters`).max(BOT_WEBHOOK_SECRET_MAX_LENGTH, `Verification key must be at most ${BOT_WEBHOOK_SECRET_MAX_LENGTH} characters`);
|
|
47916
|
+
var BotWebhookLastDeliverySchema = exports_external.strictObject({
|
|
47917
|
+
id: exports_external.string().min(1),
|
|
47918
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
47919
|
+
eventType: exports_external.string().min(1),
|
|
47920
|
+
summary: exports_external.string(),
|
|
47921
|
+
lastError: exports_external.string().nullable(),
|
|
47922
|
+
createdAt: exports_external.iso.datetime()
|
|
47923
|
+
});
|
|
47924
|
+
var BotWebhookDeliverySchema = exports_external.strictObject({
|
|
47925
|
+
id: exports_external.string().min(1),
|
|
47926
|
+
webhookId: exports_external.string().min(1),
|
|
47927
|
+
eventType: exports_external.string().min(1),
|
|
47928
|
+
summary: exports_external.string(),
|
|
47929
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
47930
|
+
lastError: exports_external.string().nullable(),
|
|
47931
|
+
externalDeliveryId: exports_external.string().nullable(),
|
|
47932
|
+
createdAt: exports_external.iso.datetime(),
|
|
47933
|
+
dispatchedAt: exports_external.iso.datetime().nullable()
|
|
47934
|
+
});
|
|
47935
|
+
var BotWebhookSummarySchema = exports_external.strictObject({
|
|
47936
|
+
id: exports_external.string().min(1),
|
|
47937
|
+
botId: exports_external.string().min(1),
|
|
47938
|
+
name: exports_external.string().min(1),
|
|
47939
|
+
provider: BotWebhookProviderSchema,
|
|
47940
|
+
hasSigningSecret: exports_external.boolean(),
|
|
47941
|
+
eventFilter: exports_external.array(exports_external.string()).nullable(),
|
|
47942
|
+
instruction: exports_external.string(),
|
|
47943
|
+
enabled: exports_external.boolean(),
|
|
47944
|
+
lastTriggeredAt: exports_external.iso.datetime().nullable(),
|
|
47945
|
+
createdAt: exports_external.iso.datetime(),
|
|
47946
|
+
updatedAt: exports_external.iso.datetime(),
|
|
47947
|
+
lastDelivery: BotWebhookLastDeliverySchema.nullable()
|
|
47948
|
+
});
|
|
47949
|
+
var BotWebhookCreateSchema = exports_external.strictObject({
|
|
47950
|
+
name: exports_external.string().trim().min(1, "Name is required").max(BOT_WEBHOOK_NAME_MAX_LENGTH),
|
|
47951
|
+
provider: BotWebhookProviderSchema,
|
|
47952
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
47953
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional().default(""),
|
|
47954
|
+
requireSecret: exports_external.boolean().optional(),
|
|
47955
|
+
signingSecret: SigningSecretInputSchema.optional()
|
|
47956
|
+
});
|
|
47957
|
+
var BotWebhookUpdateSchema = exports_external.strictObject({
|
|
47958
|
+
name: exports_external.string().trim().min(1).max(BOT_WEBHOOK_NAME_MAX_LENGTH).optional(),
|
|
47959
|
+
enabled: exports_external.boolean().optional(),
|
|
47960
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
47961
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional(),
|
|
47962
|
+
requireSecret: exports_external.boolean().optional(),
|
|
47963
|
+
signingSecret: SigningSecretInputSchema.optional(),
|
|
47964
|
+
rotateCredentials: exports_external.boolean().optional()
|
|
47965
|
+
}).refine((v) => v.name !== undefined || v.enabled !== undefined || v.eventFilter !== undefined || v.instruction !== undefined || v.requireSecret !== undefined || v.signingSecret !== undefined || v.rotateCredentials === true, { message: "At least one field must be provided" });
|
|
47966
|
+
var BotWebhookCreateResponseSchema = exports_external.strictObject({
|
|
47967
|
+
webhook: BotWebhookSummarySchema,
|
|
47968
|
+
webhookUrl: exports_external.url(),
|
|
47969
|
+
signingSecret: exports_external.string().nullable()
|
|
47970
|
+
});
|
|
47971
|
+
var BotWebhookUpdateResponseSchema = exports_external.strictObject({
|
|
47972
|
+
webhook: BotWebhookSummarySchema,
|
|
47973
|
+
webhookUrl: exports_external.url().optional(),
|
|
47974
|
+
signingSecret: exports_external.string().nullable().optional()
|
|
47975
|
+
});
|
|
47976
|
+
var BotWebhookListResponseSchema = exports_external.strictObject({
|
|
47977
|
+
webhooks: exports_external.array(BotWebhookSummarySchema)
|
|
47978
|
+
});
|
|
47979
|
+
var BotWebhookDeliveriesResponseSchema = exports_external.strictObject({
|
|
47980
|
+
deliveries: exports_external.array(BotWebhookDeliverySchema)
|
|
47981
|
+
});
|
|
47982
|
+
var BotWebhookTestResponseSchema = exports_external.strictObject({
|
|
47983
|
+
delivery: BotWebhookDeliverySchema
|
|
47984
|
+
});
|
|
47833
47985
|
// ../shared/src/lib/invite-link.ts
|
|
47834
47986
|
var INVITE_URL_RE = /(?:https?:\/\/[^\s/]+)?\/c\/invite\/([A-Za-z0-9_-]{6,64})/;
|
|
47835
47987
|
var BARE_TOKEN_RE = /^[A-Za-z0-9_-]{6,64}$/;
|
|
@@ -63788,6 +63940,55 @@ async function killProcessTree(pid, opts) {
|
|
|
63788
63940
|
import { createRequire as createRequire3 } from "node:module";
|
|
63789
63941
|
import { homedir as homedir3 } from "node:os";
|
|
63790
63942
|
import { join as join7, resolve } from "node:path";
|
|
63943
|
+
var MAX_CHILD_PROGRESS_ROWS = 64;
|
|
63944
|
+
function parseAgyVersion(version3) {
|
|
63945
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec(version3.trim());
|
|
63946
|
+
if (!match)
|
|
63947
|
+
return null;
|
|
63948
|
+
const major = Number(match[1]);
|
|
63949
|
+
const minor = Number(match[2]);
|
|
63950
|
+
const patch = Number(match[3]);
|
|
63951
|
+
if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) {
|
|
63952
|
+
return null;
|
|
63953
|
+
}
|
|
63954
|
+
return [major, minor, patch];
|
|
63955
|
+
}
|
|
63956
|
+
function compareSemver(a, b) {
|
|
63957
|
+
for (let index3 = 0;index3 < 3; index3 += 1) {
|
|
63958
|
+
if (a[index3] !== b[index3])
|
|
63959
|
+
return a[index3] - b[index3];
|
|
63960
|
+
}
|
|
63961
|
+
return 0;
|
|
63962
|
+
}
|
|
63963
|
+
function isAgyVersionAtLeast(version3, min, maxMajorExclusive) {
|
|
63964
|
+
const parsed = parseAgyVersion(version3);
|
|
63965
|
+
if (!parsed)
|
|
63966
|
+
return false;
|
|
63967
|
+
if (maxMajorExclusive !== undefined && parsed[0] >= maxMajorExclusive)
|
|
63968
|
+
return false;
|
|
63969
|
+
return compareSemver(parsed, min) >= 0;
|
|
63970
|
+
}
|
|
63971
|
+
function resolveAgyUsageProfile(version3) {
|
|
63972
|
+
const parsed = parseAgyVersion(version3);
|
|
63973
|
+
if (!parsed || parsed[0] >= 2)
|
|
63974
|
+
return;
|
|
63975
|
+
if (compareSemver(parsed, [1, 5, 9]) >= 0) {
|
|
63976
|
+
return { inputIncludesCache: false, outputIncludesReasoning: true };
|
|
63977
|
+
}
|
|
63978
|
+
if (compareSemver(parsed, [1, 4, 12]) >= 0) {
|
|
63979
|
+
return { inputIncludesCache: true, outputIncludesReasoning: false };
|
|
63980
|
+
}
|
|
63981
|
+
return;
|
|
63982
|
+
}
|
|
63983
|
+
function readConversationSummaryColumns(db) {
|
|
63984
|
+
const rows = db.prepare("PRAGMA table_info(conversation_summaries)").all();
|
|
63985
|
+
const columns = new Set;
|
|
63986
|
+
for (const row of rows) {
|
|
63987
|
+
if (typeof row?.name === "string")
|
|
63988
|
+
columns.add(row.name);
|
|
63989
|
+
}
|
|
63990
|
+
return columns;
|
|
63991
|
+
}
|
|
63791
63992
|
function agyStateHome(env, cwd) {
|
|
63792
63993
|
const home = env.HOME || env.USERPROFILE || homedir3();
|
|
63793
63994
|
return resolve(cwd, env.GEMINI_HOME?.trim().replace(/^~(?=[/\\]|$)/, home) || join7(home, ".gemini"));
|
|
@@ -63937,10 +64138,14 @@ class NativeSessionActivityReader {
|
|
|
63937
64138
|
this.path = join7(home, "antigravity-cli", "conversation_summaries.db");
|
|
63938
64139
|
}
|
|
63939
64140
|
async activity() {
|
|
63940
|
-
if (this.version
|
|
64141
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
63941
64142
|
return "unknown";
|
|
63942
64143
|
const db = await this.openDatabase(this.path);
|
|
63943
64144
|
try {
|
|
64145
|
+
const columns = readConversationSummaryColumns(db);
|
|
64146
|
+
if (!columns.has("conversation_id") || !columns.has("status") || !columns.has("not_fully_idle")) {
|
|
64147
|
+
return "unknown";
|
|
64148
|
+
}
|
|
63944
64149
|
const rows = db.prepare("SELECT status,not_fully_idle FROM conversation_summaries WHERE conversation_id = ? LIMIT 1").all(this.sessionId);
|
|
63945
64150
|
const row = rows[0];
|
|
63946
64151
|
if (!row || row.not_fully_idle !== 0 && row.not_fully_idle !== 1)
|
|
@@ -63952,6 +64157,40 @@ class NativeSessionActivityReader {
|
|
|
63952
64157
|
db.close();
|
|
63953
64158
|
}
|
|
63954
64159
|
}
|
|
64160
|
+
async childProgress() {
|
|
64161
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
64162
|
+
return null;
|
|
64163
|
+
let db;
|
|
64164
|
+
try {
|
|
64165
|
+
db = await this.openDatabase(this.path);
|
|
64166
|
+
} catch {
|
|
64167
|
+
return null;
|
|
64168
|
+
}
|
|
64169
|
+
try {
|
|
64170
|
+
const columns = readConversationSummaryColumns(db);
|
|
64171
|
+
if (!columns.has("conversation_id") || !columns.has("parent_conversation_id") || !columns.has("step_count") || !columns.has("last_modified_time")) {
|
|
64172
|
+
return null;
|
|
64173
|
+
}
|
|
64174
|
+
const rows = db.prepare(`SELECT conversation_id,step_count,last_modified_time FROM conversation_summaries WHERE parent_conversation_id = ? ORDER BY last_modified_time DESC LIMIT ${MAX_CHILD_PROGRESS_ROWS}`).all(this.sessionId);
|
|
64175
|
+
const children = [];
|
|
64176
|
+
for (const row of rows) {
|
|
64177
|
+
if (typeof row?.conversation_id !== "string" || !row.conversation_id)
|
|
64178
|
+
continue;
|
|
64179
|
+
const stepCount = typeof row.step_count === "number" && Number.isSafeInteger(row.step_count) && row.step_count >= 0 ? row.step_count : 0;
|
|
64180
|
+
const lastModifiedTime = typeof row.last_modified_time === "string" ? row.last_modified_time : typeof row.last_modified_time === "number" && Number.isFinite(row.last_modified_time) ? String(row.last_modified_time) : "";
|
|
64181
|
+
children.push({
|
|
64182
|
+
conversationId: row.conversation_id,
|
|
64183
|
+
stepCount,
|
|
64184
|
+
lastModifiedTime
|
|
64185
|
+
});
|
|
64186
|
+
}
|
|
64187
|
+
return children;
|
|
64188
|
+
} catch {
|
|
64189
|
+
return null;
|
|
64190
|
+
} finally {
|
|
64191
|
+
db.close();
|
|
64192
|
+
}
|
|
64193
|
+
}
|
|
63955
64194
|
}
|
|
63956
64195
|
|
|
63957
64196
|
// agent-driver/dist/internal/model-observation.js
|
|
@@ -64163,6 +64402,28 @@ function isMissingSessionError(error62) {
|
|
|
64163
64402
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
64164
64403
|
return /\bsession\b.*\b(not found|missing|unknown|invalid)\b/i.test(message) || /\b(not found|missing|unknown|invalid)\b.*\bsession\b/i.test(message);
|
|
64165
64404
|
}
|
|
64405
|
+
function timestampAdvanced(previous4, next) {
|
|
64406
|
+
if (!next || next === previous4)
|
|
64407
|
+
return false;
|
|
64408
|
+
if (!previous4)
|
|
64409
|
+
return true;
|
|
64410
|
+
const previousMs = Date.parse(previous4);
|
|
64411
|
+
const nextMs = Date.parse(next);
|
|
64412
|
+
if (Number.isFinite(previousMs) && Number.isFinite(nextMs)) {
|
|
64413
|
+
return nextMs > previousMs || nextMs === previousMs && next > previous4;
|
|
64414
|
+
}
|
|
64415
|
+
return next > previous4;
|
|
64416
|
+
}
|
|
64417
|
+
function toChildProgressMap(children) {
|
|
64418
|
+
const map6 = new Map;
|
|
64419
|
+
for (const child of children) {
|
|
64420
|
+
map6.set(child.conversationId, {
|
|
64421
|
+
stepCount: child.stepCount,
|
|
64422
|
+
lastModifiedTime: child.lastModifiedTime
|
|
64423
|
+
});
|
|
64424
|
+
}
|
|
64425
|
+
return map6;
|
|
64426
|
+
}
|
|
64166
64427
|
|
|
64167
64428
|
class AgyAcpLane {
|
|
64168
64429
|
factory;
|
|
@@ -64179,6 +64440,8 @@ class AgyAcpLane {
|
|
|
64179
64440
|
nativeActivity = "unknown";
|
|
64180
64441
|
publishedActivity;
|
|
64181
64442
|
activityRevision = 0;
|
|
64443
|
+
childProgressBaseline = null;
|
|
64444
|
+
resumedSession = false;
|
|
64182
64445
|
nativeVersion = "";
|
|
64183
64446
|
contentOwner;
|
|
64184
64447
|
executionIsolated = true;
|
|
@@ -64228,6 +64491,7 @@ class AgyAcpLane {
|
|
|
64228
64491
|
return { ok: false, reason: "runtime_error", error: "Agy ACP session already started" };
|
|
64229
64492
|
}
|
|
64230
64493
|
this.started = true;
|
|
64494
|
+
this.resumedSession = Boolean(input2.sessionId ?? this.ctx.config.sessionId);
|
|
64231
64495
|
const launchCtx = {
|
|
64232
64496
|
...this.ctx,
|
|
64233
64497
|
prompt: input2.text,
|
|
@@ -64258,7 +64522,7 @@ class AgyAcpLane {
|
|
|
64258
64522
|
const sessionId = this.sessionId;
|
|
64259
64523
|
if (!sessionId)
|
|
64260
64524
|
throw new Error("Agy ACP handshake completed without a session id");
|
|
64261
|
-
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, this.nativeVersion
|
|
64525
|
+
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, isAgyVersionAtLeast(this.nativeVersion, [1, 5, 16], 2));
|
|
64262
64526
|
this.processActivated = true;
|
|
64263
64527
|
this.ready = true;
|
|
64264
64528
|
this.events.emit("runtime_event", { kind: "session_init", sessionId, acquisition: { status: input2.sessionId ? "resumed" : "created", evidence: "native_api" } });
|
|
@@ -64310,6 +64574,7 @@ class AgyAcpLane {
|
|
|
64310
64574
|
this.requestedStopReason ??= input2.reason ?? "requested_stop";
|
|
64311
64575
|
this.ready = false;
|
|
64312
64576
|
this.clearActivityTimer();
|
|
64577
|
+
this.childProgressBaseline = null;
|
|
64313
64578
|
this.currentPromptRequestId = null;
|
|
64314
64579
|
this.terminalOwner = null;
|
|
64315
64580
|
this.toolCalls.clear();
|
|
@@ -64368,7 +64633,7 @@ class AgyAcpLane {
|
|
|
64368
64633
|
}
|
|
64369
64634
|
const version3 = record3(initialize.agentInfo)?.version;
|
|
64370
64635
|
this.nativeVersion = typeof version3 === "string" ? version3 : "";
|
|
64371
|
-
this.usageProfile = version3 === "
|
|
64636
|
+
this.usageProfile = typeof version3 === "string" ? resolveAgyUsageProfile(version3) : undefined;
|
|
64372
64637
|
if (!record3(record3(initialize.agentCapabilities)?.sessionCapabilities)?.resume) {
|
|
64373
64638
|
throw new AgyAcpIncompatibleError("Antigravity CLI ACP does not support native session resume");
|
|
64374
64639
|
}
|
|
@@ -64573,6 +64838,11 @@ class AgyAcpLane {
|
|
|
64573
64838
|
const checkpoint = await read;
|
|
64574
64839
|
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
64575
64840
|
return { ok: false, reason: "closed" };
|
|
64841
|
+
const childBaseline = await this.readChildProgress();
|
|
64842
|
+
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
64843
|
+
return { ok: false, reason: "closed" };
|
|
64844
|
+
if (childBaseline)
|
|
64845
|
+
this.childProgressBaseline = toChildProgressMap(childBaseline);
|
|
64576
64846
|
this.executionCheckpoint = checkpoint;
|
|
64577
64847
|
this.executionIsolated = !this.unownedContent && !this.hasPendingTools();
|
|
64578
64848
|
return this.admitPrompt(text7, "prompt", inputs);
|
|
@@ -65106,6 +65376,51 @@ class AgyAcpLane {
|
|
|
65106
65376
|
this.nativeActivity = "unknown";
|
|
65107
65377
|
this.publishActivity();
|
|
65108
65378
|
}
|
|
65379
|
+
async readChildProgress() {
|
|
65380
|
+
if (!this.activityReader?.childProgress)
|
|
65381
|
+
return null;
|
|
65382
|
+
try {
|
|
65383
|
+
return await this.activityReader.childProgress();
|
|
65384
|
+
} catch {
|
|
65385
|
+
return null;
|
|
65386
|
+
}
|
|
65387
|
+
}
|
|
65388
|
+
observeChildProgress(children) {
|
|
65389
|
+
if (!children || this.currentPromptRequestId === null || this.terminalOwner === null)
|
|
65390
|
+
return;
|
|
65391
|
+
if (this.childProgressBaseline === null) {
|
|
65392
|
+
this.childProgressBaseline = toChildProgressMap(children);
|
|
65393
|
+
if (!this.resumedSession && children.length > 0) {
|
|
65394
|
+
this.events.emit("runtime_event", {
|
|
65395
|
+
kind: "internal_progress",
|
|
65396
|
+
source: "agy.native",
|
|
65397
|
+
itemType: "subagent_progress"
|
|
65398
|
+
});
|
|
65399
|
+
}
|
|
65400
|
+
return;
|
|
65401
|
+
}
|
|
65402
|
+
let advanced = false;
|
|
65403
|
+
for (const child of children) {
|
|
65404
|
+
const previous4 = this.childProgressBaseline.get(child.conversationId);
|
|
65405
|
+
if (!previous4 || child.stepCount > previous4.stepCount || timestampAdvanced(previous4.lastModifiedTime, child.lastModifiedTime)) {
|
|
65406
|
+
advanced = true;
|
|
65407
|
+
}
|
|
65408
|
+
this.childProgressBaseline.set(child.conversationId, {
|
|
65409
|
+
stepCount: Math.max(previous4?.stepCount ?? 0, child.stepCount),
|
|
65410
|
+
lastModifiedTime: previous4 && !timestampAdvanced(previous4.lastModifiedTime, child.lastModifiedTime) ? previous4.lastModifiedTime : child.lastModifiedTime
|
|
65411
|
+
});
|
|
65412
|
+
}
|
|
65413
|
+
while (this.childProgressBaseline.size > 256) {
|
|
65414
|
+
this.childProgressBaseline.delete(this.childProgressBaseline.keys().next().value);
|
|
65415
|
+
}
|
|
65416
|
+
if (advanced) {
|
|
65417
|
+
this.events.emit("runtime_event", {
|
|
65418
|
+
kind: "internal_progress",
|
|
65419
|
+
source: "agy.native",
|
|
65420
|
+
itemType: "subagent_progress"
|
|
65421
|
+
});
|
|
65422
|
+
}
|
|
65423
|
+
}
|
|
65109
65424
|
refreshActivity() {
|
|
65110
65425
|
if (this.activityRead)
|
|
65111
65426
|
return this.activityRead;
|
|
@@ -65124,6 +65439,12 @@ class AgyAcpLane {
|
|
|
65124
65439
|
if (status === "running" && this.currentPromptRequestId === null)
|
|
65125
65440
|
this.unownedContent = true;
|
|
65126
65441
|
this.publishActivity();
|
|
65442
|
+
if (this.currentPromptRequestId !== null && this.terminalOwner !== null) {
|
|
65443
|
+
const children = await this.readChildProgress();
|
|
65444
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
65445
|
+
return;
|
|
65446
|
+
this.observeChildProgress(children);
|
|
65447
|
+
}
|
|
65127
65448
|
})();
|
|
65128
65449
|
this.activityRead = reading;
|
|
65129
65450
|
reading.finally(() => {
|
|
@@ -77143,6 +77464,10 @@ var communityProxyRoutes = {
|
|
|
77143
77464
|
avatar: "/api/community/users/me/avatar",
|
|
77144
77465
|
marks: "/api/community/users/me/marks"
|
|
77145
77466
|
};
|
|
77467
|
+
var SCHEDULE_EVENTS_PROXY_PATH_RE = /^\/api\/community\/schedule\/events(?:\/[^/]+)?$/;
|
|
77468
|
+
function isCanonicalCommunityProxyPath(pathname) {
|
|
77469
|
+
return pathname === "/api/community/platform/feedback" || SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname) || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
77470
|
+
}
|
|
77146
77471
|
function resolveProxyCapability(method, pathname) {
|
|
77147
77472
|
if (pathname === "/api/community/platform/feedback" && method === "POST")
|
|
77148
77473
|
return "send";
|
|
@@ -77152,7 +77477,7 @@ function resolveProxyCapability(method, pathname) {
|
|
|
77152
77477
|
return "read";
|
|
77153
77478
|
if (pathname === "/api/community/bots/creation-requests" && method === "POST")
|
|
77154
77479
|
return "send";
|
|
77155
|
-
if (
|
|
77480
|
+
if (SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname)) {
|
|
77156
77481
|
return method === "GET" ? "read" : "send";
|
|
77157
77482
|
}
|
|
77158
77483
|
if ((method === "GET" || method === "PATCH") && pathname === communityProxyRoutes.profile || method === "POST" && pathname === communityProxyRoutes.avatar)
|
|
@@ -77255,6 +77580,7 @@ function propertyAuditMetadata(method, pathname, requestUrl) {
|
|
|
77255
77580
|
}
|
|
77256
77581
|
function resolveProxyRoute(pathname, method, requestUrl = pathname) {
|
|
77257
77582
|
return {
|
|
77583
|
+
canonicalCommunityDoor: isCanonicalCommunityProxyPath(pathname),
|
|
77258
77584
|
capability: resolveProxyCapability(method ?? "", pathname),
|
|
77259
77585
|
auditOperation: resolveProxyAuditOperation(pathname, method),
|
|
77260
77586
|
propertyMetadata: propertyAuditMetadata(method ?? "", pathname, requestUrl),
|
|
@@ -77674,8 +78000,36 @@ async function readCursorQuota(options = {}, backend = "cursor") {
|
|
|
77674
78000
|
// agent-driver/dist/adapters/agy/quota.js
|
|
77675
78001
|
import { homedir as homedir15 } from "node:os";
|
|
77676
78002
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
78003
|
+
function classifyAgyQuotaError(message, sourceEpoch, structured) {
|
|
78004
|
+
const text8 = message.trim();
|
|
78005
|
+
if (!text8)
|
|
78006
|
+
return null;
|
|
78007
|
+
if (/(?:not authenticated|authentication (?:required|failed)|sign[ -]?in required|unauthenticated|unauthorized|invalid credentials|token expired|permission denied|\b401\b|\b403\b)/i.test(text8)) {
|
|
78008
|
+
return { status: "error", sourceEpoch, code: "unauthorized", retryable: false };
|
|
78009
|
+
}
|
|
78010
|
+
if (/(?:eligibility check failed|not eligible|not (?:currently )?available in your (?:location|region|country)|unsupported (?:location|region|country))/i.test(text8)) {
|
|
78011
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: false };
|
|
78012
|
+
}
|
|
78013
|
+
if (/(?:econnrefused|econnreset|etimedout|enotfound|ehostunreach|network error|fetch failed|dial tcp|socket hang up|connection refused|connection reset|proxyconnect|timed out|\bdns\b|\btls\b|\bssl\b)/i.test(text8)) {
|
|
78014
|
+
return { status: "error", sourceEpoch, code: "network", retryable: true };
|
|
78015
|
+
}
|
|
78016
|
+
if (/(?:rate[ -]?limit|too many requests|quota exceeded|\b429\b|\b50[0234]\b|internal server error|service unavailable|bad gateway|temporarily unavailable|resource exhausted|upstream)/i.test(text8)) {
|
|
78017
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
78018
|
+
}
|
|
78019
|
+
return structured ? { status: "error", sourceEpoch, code: "provider_error", retryable: true } : null;
|
|
78020
|
+
}
|
|
78021
|
+
function tryParseJson(text8) {
|
|
78022
|
+
try {
|
|
78023
|
+
return { ok: true, value: JSON.parse(text8) };
|
|
78024
|
+
} catch {
|
|
78025
|
+
return { ok: false };
|
|
78026
|
+
}
|
|
78027
|
+
}
|
|
77677
78028
|
function parseAgyQuota(value, sourceEpoch) {
|
|
77678
78029
|
const result2 = asRecord(value);
|
|
78030
|
+
if (result2?.status === "ERROR" && typeof result2.error === "string" && result2.error.trim()) {
|
|
78031
|
+
return classifyAgyQuotaError(result2.error, sourceEpoch, true) ?? { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
78032
|
+
}
|
|
77679
78033
|
const command = asRecord(result2?.command);
|
|
77680
78034
|
const data = asRecord(command?.data);
|
|
77681
78035
|
const groups = data?.groups;
|
|
@@ -77712,21 +78066,58 @@ async function readAgyQuota(options = {}) {
|
|
|
77712
78066
|
const source = quotaSource("agy", randomUUID11());
|
|
77713
78067
|
const read = async (args) => {
|
|
77714
78068
|
const child = (options.spawn ?? spawnAgentProcess)(spec.command, args, { cwd: options.cwd ?? process.cwd(), env: { ...env, CI: "1", AGY_CLI_DISABLE_AUTO_UPDATE: "true" }, shell: spec.shell, stdin: "ignore" });
|
|
77715
|
-
let
|
|
77716
|
-
|
|
77717
|
-
|
|
77718
|
-
|
|
77719
|
-
|
|
77720
|
-
|
|
77721
|
-
|
|
77722
|
-
|
|
77723
|
-
|
|
78069
|
+
let stdout = "";
|
|
78070
|
+
let stderr = "";
|
|
78071
|
+
return runBoundedDiscoveryProcess({
|
|
78072
|
+
process: child,
|
|
78073
|
+
label: "AGY quota",
|
|
78074
|
+
timeoutMs: options.timeoutMs ?? 30000,
|
|
78075
|
+
outputMaxBytes: options.outputMaxBytes ?? 1024 * 1024,
|
|
78076
|
+
stderr: "count",
|
|
78077
|
+
cleanupGraceMs: 100,
|
|
78078
|
+
cleanup: options.cleanup,
|
|
78079
|
+
exitEvent: "close",
|
|
78080
|
+
onStdout: (text8) => {
|
|
78081
|
+
stdout += text8;
|
|
78082
|
+
},
|
|
78083
|
+
onStderr: (text8) => {
|
|
78084
|
+
stderr += text8;
|
|
78085
|
+
},
|
|
78086
|
+
onExit: (code4, _signal, control) => {
|
|
78087
|
+
control.flushStdout();
|
|
78088
|
+
control.flushStderr();
|
|
78089
|
+
control.finish({ exitCode: code4, stdout, stderr });
|
|
78090
|
+
}
|
|
78091
|
+
});
|
|
77724
78092
|
};
|
|
77725
78093
|
try {
|
|
77726
|
-
|
|
78094
|
+
const models = await read(["models"]);
|
|
78095
|
+
if (models.exitCode !== 0) {
|
|
78096
|
+
const classified2 = classifyAgyQuotaError(models.stderr || models.stdout, source.epoch, false);
|
|
78097
|
+
return source.finish(classified2 ?? source.error("unavailable", true));
|
|
78098
|
+
}
|
|
78099
|
+
if (!parseAgyModelCatalog(models.stdout))
|
|
77727
78100
|
return source.finish(source.error("unauthorized"));
|
|
77728
|
-
|
|
77729
|
-
|
|
78101
|
+
const usage = await read(["-p", "/usage", "--output-format", "json"]);
|
|
78102
|
+
const parsed = tryParseJson(usage.stdout);
|
|
78103
|
+
if (parsed.ok) {
|
|
78104
|
+
const record9 = asRecord(parsed.value);
|
|
78105
|
+
if (usage.exitCode === 0) {
|
|
78106
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
78107
|
+
}
|
|
78108
|
+
if (record9?.status === "ERROR" && typeof record9.error === "string" && record9.error.trim()) {
|
|
78109
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
78110
|
+
}
|
|
78111
|
+
}
|
|
78112
|
+
if (usage.exitCode === 0) {
|
|
78113
|
+
return source.finish(source.error("invalid_response", true));
|
|
78114
|
+
}
|
|
78115
|
+
const classified = classifyAgyQuotaError(usage.stderr || usage.stdout, source.epoch, false);
|
|
78116
|
+
return source.finish(classified ?? source.error("unavailable", true));
|
|
78117
|
+
} catch (error62) {
|
|
78118
|
+
if (error62 instanceof DiscoveryProcessError && error62.code === "output_limit") {
|
|
78119
|
+
return source.finish(source.error("invalid_response", true));
|
|
78120
|
+
}
|
|
77730
78121
|
return source.finish(source.error("unavailable", true));
|
|
77731
78122
|
}
|
|
77732
78123
|
}
|
|
@@ -81316,8 +81707,7 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
81316
81707
|
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
81317
81708
|
return;
|
|
81318
81709
|
}
|
|
81319
|
-
|
|
81320
|
-
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
81710
|
+
if (pathname === "/api" || pathname.startsWith("/api/") && !route.canonicalCommunityDoor) {
|
|
81321
81711
|
res.writeHead(404, { "content-type": "application/json" });
|
|
81322
81712
|
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
81323
81713
|
req.resume();
|
package/dist/index.js
CHANGED
|
@@ -24158,6 +24158,55 @@ async function killProcessTree(pid, opts) {
|
|
|
24158
24158
|
import { createRequire as createRequire2 } from "node:module";
|
|
24159
24159
|
import { homedir as homedir2 } from "node:os";
|
|
24160
24160
|
import { join as join4, resolve } from "node:path";
|
|
24161
|
+
var MAX_CHILD_PROGRESS_ROWS = 64;
|
|
24162
|
+
function parseAgyVersion(version) {
|
|
24163
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec(version.trim());
|
|
24164
|
+
if (!match)
|
|
24165
|
+
return null;
|
|
24166
|
+
const major = Number(match[1]);
|
|
24167
|
+
const minor = Number(match[2]);
|
|
24168
|
+
const patch = Number(match[3]);
|
|
24169
|
+
if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) || !Number.isSafeInteger(patch)) {
|
|
24170
|
+
return null;
|
|
24171
|
+
}
|
|
24172
|
+
return [major, minor, patch];
|
|
24173
|
+
}
|
|
24174
|
+
function compareSemver(a, b) {
|
|
24175
|
+
for (let index = 0;index < 3; index += 1) {
|
|
24176
|
+
if (a[index] !== b[index])
|
|
24177
|
+
return a[index] - b[index];
|
|
24178
|
+
}
|
|
24179
|
+
return 0;
|
|
24180
|
+
}
|
|
24181
|
+
function isAgyVersionAtLeast(version, min, maxMajorExclusive) {
|
|
24182
|
+
const parsed = parseAgyVersion(version);
|
|
24183
|
+
if (!parsed)
|
|
24184
|
+
return false;
|
|
24185
|
+
if (maxMajorExclusive !== undefined && parsed[0] >= maxMajorExclusive)
|
|
24186
|
+
return false;
|
|
24187
|
+
return compareSemver(parsed, min) >= 0;
|
|
24188
|
+
}
|
|
24189
|
+
function resolveAgyUsageProfile(version) {
|
|
24190
|
+
const parsed = parseAgyVersion(version);
|
|
24191
|
+
if (!parsed || parsed[0] >= 2)
|
|
24192
|
+
return;
|
|
24193
|
+
if (compareSemver(parsed, [1, 5, 9]) >= 0) {
|
|
24194
|
+
return { inputIncludesCache: false, outputIncludesReasoning: true };
|
|
24195
|
+
}
|
|
24196
|
+
if (compareSemver(parsed, [1, 4, 12]) >= 0) {
|
|
24197
|
+
return { inputIncludesCache: true, outputIncludesReasoning: false };
|
|
24198
|
+
}
|
|
24199
|
+
return;
|
|
24200
|
+
}
|
|
24201
|
+
function readConversationSummaryColumns(db) {
|
|
24202
|
+
const rows = db.prepare("PRAGMA table_info(conversation_summaries)").all();
|
|
24203
|
+
const columns = new Set;
|
|
24204
|
+
for (const row of rows) {
|
|
24205
|
+
if (typeof row?.name === "string")
|
|
24206
|
+
columns.add(row.name);
|
|
24207
|
+
}
|
|
24208
|
+
return columns;
|
|
24209
|
+
}
|
|
24161
24210
|
function agyStateHome(env, cwd) {
|
|
24162
24211
|
const home = env.HOME || env.USERPROFILE || homedir2();
|
|
24163
24212
|
return resolve(cwd, env.GEMINI_HOME?.trim().replace(/^~(?=[/\\]|$)/, home) || join4(home, ".gemini"));
|
|
@@ -24307,10 +24356,14 @@ class NativeSessionActivityReader {
|
|
|
24307
24356
|
this.path = join4(home, "antigravity-cli", "conversation_summaries.db");
|
|
24308
24357
|
}
|
|
24309
24358
|
async activity() {
|
|
24310
|
-
if (this.version
|
|
24359
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
24311
24360
|
return "unknown";
|
|
24312
24361
|
const db = await this.openDatabase(this.path);
|
|
24313
24362
|
try {
|
|
24363
|
+
const columns = readConversationSummaryColumns(db);
|
|
24364
|
+
if (!columns.has("conversation_id") || !columns.has("status") || !columns.has("not_fully_idle")) {
|
|
24365
|
+
return "unknown";
|
|
24366
|
+
}
|
|
24314
24367
|
const rows = db.prepare("SELECT status,not_fully_idle FROM conversation_summaries WHERE conversation_id = ? LIMIT 1").all(this.sessionId);
|
|
24315
24368
|
const row = rows[0];
|
|
24316
24369
|
if (!row || row.not_fully_idle !== 0 && row.not_fully_idle !== 1)
|
|
@@ -24322,6 +24375,40 @@ class NativeSessionActivityReader {
|
|
|
24322
24375
|
db.close();
|
|
24323
24376
|
}
|
|
24324
24377
|
}
|
|
24378
|
+
async childProgress() {
|
|
24379
|
+
if (!isAgyVersionAtLeast(this.version, [1, 5, 16], 2))
|
|
24380
|
+
return null;
|
|
24381
|
+
let db;
|
|
24382
|
+
try {
|
|
24383
|
+
db = await this.openDatabase(this.path);
|
|
24384
|
+
} catch {
|
|
24385
|
+
return null;
|
|
24386
|
+
}
|
|
24387
|
+
try {
|
|
24388
|
+
const columns = readConversationSummaryColumns(db);
|
|
24389
|
+
if (!columns.has("conversation_id") || !columns.has("parent_conversation_id") || !columns.has("step_count") || !columns.has("last_modified_time")) {
|
|
24390
|
+
return null;
|
|
24391
|
+
}
|
|
24392
|
+
const rows = db.prepare(`SELECT conversation_id,step_count,last_modified_time FROM conversation_summaries WHERE parent_conversation_id = ? ORDER BY last_modified_time DESC LIMIT ${MAX_CHILD_PROGRESS_ROWS}`).all(this.sessionId);
|
|
24393
|
+
const children = [];
|
|
24394
|
+
for (const row of rows) {
|
|
24395
|
+
if (typeof row?.conversation_id !== "string" || !row.conversation_id)
|
|
24396
|
+
continue;
|
|
24397
|
+
const stepCount = typeof row.step_count === "number" && Number.isSafeInteger(row.step_count) && row.step_count >= 0 ? row.step_count : 0;
|
|
24398
|
+
const lastModifiedTime = typeof row.last_modified_time === "string" ? row.last_modified_time : typeof row.last_modified_time === "number" && Number.isFinite(row.last_modified_time) ? String(row.last_modified_time) : "";
|
|
24399
|
+
children.push({
|
|
24400
|
+
conversationId: row.conversation_id,
|
|
24401
|
+
stepCount,
|
|
24402
|
+
lastModifiedTime
|
|
24403
|
+
});
|
|
24404
|
+
}
|
|
24405
|
+
return children;
|
|
24406
|
+
} catch {
|
|
24407
|
+
return null;
|
|
24408
|
+
} finally {
|
|
24409
|
+
db.close();
|
|
24410
|
+
}
|
|
24411
|
+
}
|
|
24325
24412
|
}
|
|
24326
24413
|
|
|
24327
24414
|
// agent-driver/dist/internal/model-observation.js
|
|
@@ -24533,6 +24620,28 @@ function isMissingSessionError(error) {
|
|
|
24533
24620
|
const message = error instanceof Error ? error.message : String(error);
|
|
24534
24621
|
return /\bsession\b.*\b(not found|missing|unknown|invalid)\b/i.test(message) || /\b(not found|missing|unknown|invalid)\b.*\bsession\b/i.test(message);
|
|
24535
24622
|
}
|
|
24623
|
+
function timestampAdvanced(previous, next) {
|
|
24624
|
+
if (!next || next === previous)
|
|
24625
|
+
return false;
|
|
24626
|
+
if (!previous)
|
|
24627
|
+
return true;
|
|
24628
|
+
const previousMs = Date.parse(previous);
|
|
24629
|
+
const nextMs = Date.parse(next);
|
|
24630
|
+
if (Number.isFinite(previousMs) && Number.isFinite(nextMs)) {
|
|
24631
|
+
return nextMs > previousMs || nextMs === previousMs && next > previous;
|
|
24632
|
+
}
|
|
24633
|
+
return next > previous;
|
|
24634
|
+
}
|
|
24635
|
+
function toChildProgressMap(children) {
|
|
24636
|
+
const map = new Map;
|
|
24637
|
+
for (const child of children) {
|
|
24638
|
+
map.set(child.conversationId, {
|
|
24639
|
+
stepCount: child.stepCount,
|
|
24640
|
+
lastModifiedTime: child.lastModifiedTime
|
|
24641
|
+
});
|
|
24642
|
+
}
|
|
24643
|
+
return map;
|
|
24644
|
+
}
|
|
24536
24645
|
|
|
24537
24646
|
class AgyAcpLane {
|
|
24538
24647
|
factory;
|
|
@@ -24549,6 +24658,8 @@ class AgyAcpLane {
|
|
|
24549
24658
|
nativeActivity = "unknown";
|
|
24550
24659
|
publishedActivity;
|
|
24551
24660
|
activityRevision = 0;
|
|
24661
|
+
childProgressBaseline = null;
|
|
24662
|
+
resumedSession = false;
|
|
24552
24663
|
nativeVersion = "";
|
|
24553
24664
|
contentOwner;
|
|
24554
24665
|
executionIsolated = true;
|
|
@@ -24598,6 +24709,7 @@ class AgyAcpLane {
|
|
|
24598
24709
|
return { ok: false, reason: "runtime_error", error: "Agy ACP session already started" };
|
|
24599
24710
|
}
|
|
24600
24711
|
this.started = true;
|
|
24712
|
+
this.resumedSession = Boolean(input.sessionId ?? this.ctx.config.sessionId);
|
|
24601
24713
|
const launchCtx = {
|
|
24602
24714
|
...this.ctx,
|
|
24603
24715
|
prompt: input.text,
|
|
@@ -24628,7 +24740,7 @@ class AgyAcpLane {
|
|
|
24628
24740
|
const sessionId = this.sessionId;
|
|
24629
24741
|
if (!sessionId)
|
|
24630
24742
|
throw new Error("Agy ACP handshake completed without a session id");
|
|
24631
|
-
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, this.nativeVersion
|
|
24743
|
+
this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, isAgyVersionAtLeast(this.nativeVersion, [1, 5, 16], 2));
|
|
24632
24744
|
this.processActivated = true;
|
|
24633
24745
|
this.ready = true;
|
|
24634
24746
|
this.events.emit("runtime_event", { kind: "session_init", sessionId, acquisition: { status: input.sessionId ? "resumed" : "created", evidence: "native_api" } });
|
|
@@ -24680,6 +24792,7 @@ class AgyAcpLane {
|
|
|
24680
24792
|
this.requestedStopReason ??= input.reason ?? "requested_stop";
|
|
24681
24793
|
this.ready = false;
|
|
24682
24794
|
this.clearActivityTimer();
|
|
24795
|
+
this.childProgressBaseline = null;
|
|
24683
24796
|
this.currentPromptRequestId = null;
|
|
24684
24797
|
this.terminalOwner = null;
|
|
24685
24798
|
this.toolCalls.clear();
|
|
@@ -24738,7 +24851,7 @@ class AgyAcpLane {
|
|
|
24738
24851
|
}
|
|
24739
24852
|
const version = record2(initialize.agentInfo)?.version;
|
|
24740
24853
|
this.nativeVersion = typeof version === "string" ? version : "";
|
|
24741
|
-
this.usageProfile = version === "
|
|
24854
|
+
this.usageProfile = typeof version === "string" ? resolveAgyUsageProfile(version) : undefined;
|
|
24742
24855
|
if (!record2(record2(initialize.agentCapabilities)?.sessionCapabilities)?.resume) {
|
|
24743
24856
|
throw new AgyAcpIncompatibleError("Antigravity CLI ACP does not support native session resume");
|
|
24744
24857
|
}
|
|
@@ -24943,6 +25056,11 @@ class AgyAcpLane {
|
|
|
24943
25056
|
const checkpoint = await read;
|
|
24944
25057
|
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
24945
25058
|
return { ok: false, reason: "closed" };
|
|
25059
|
+
const childBaseline = await this.readChildProgress();
|
|
25060
|
+
if (!this.ready || this.requestedStopReason || this.isClosed())
|
|
25061
|
+
return { ok: false, reason: "closed" };
|
|
25062
|
+
if (childBaseline)
|
|
25063
|
+
this.childProgressBaseline = toChildProgressMap(childBaseline);
|
|
24946
25064
|
this.executionCheckpoint = checkpoint;
|
|
24947
25065
|
this.executionIsolated = !this.unownedContent && !this.hasPendingTools();
|
|
24948
25066
|
return this.admitPrompt(text, "prompt", inputs);
|
|
@@ -25476,6 +25594,51 @@ class AgyAcpLane {
|
|
|
25476
25594
|
this.nativeActivity = "unknown";
|
|
25477
25595
|
this.publishActivity();
|
|
25478
25596
|
}
|
|
25597
|
+
async readChildProgress() {
|
|
25598
|
+
if (!this.activityReader?.childProgress)
|
|
25599
|
+
return null;
|
|
25600
|
+
try {
|
|
25601
|
+
return await this.activityReader.childProgress();
|
|
25602
|
+
} catch {
|
|
25603
|
+
return null;
|
|
25604
|
+
}
|
|
25605
|
+
}
|
|
25606
|
+
observeChildProgress(children) {
|
|
25607
|
+
if (!children || this.currentPromptRequestId === null || this.terminalOwner === null)
|
|
25608
|
+
return;
|
|
25609
|
+
if (this.childProgressBaseline === null) {
|
|
25610
|
+
this.childProgressBaseline = toChildProgressMap(children);
|
|
25611
|
+
if (!this.resumedSession && children.length > 0) {
|
|
25612
|
+
this.events.emit("runtime_event", {
|
|
25613
|
+
kind: "internal_progress",
|
|
25614
|
+
source: "agy.native",
|
|
25615
|
+
itemType: "subagent_progress"
|
|
25616
|
+
});
|
|
25617
|
+
}
|
|
25618
|
+
return;
|
|
25619
|
+
}
|
|
25620
|
+
let advanced = false;
|
|
25621
|
+
for (const child of children) {
|
|
25622
|
+
const previous = this.childProgressBaseline.get(child.conversationId);
|
|
25623
|
+
if (!previous || child.stepCount > previous.stepCount || timestampAdvanced(previous.lastModifiedTime, child.lastModifiedTime)) {
|
|
25624
|
+
advanced = true;
|
|
25625
|
+
}
|
|
25626
|
+
this.childProgressBaseline.set(child.conversationId, {
|
|
25627
|
+
stepCount: Math.max(previous?.stepCount ?? 0, child.stepCount),
|
|
25628
|
+
lastModifiedTime: previous && !timestampAdvanced(previous.lastModifiedTime, child.lastModifiedTime) ? previous.lastModifiedTime : child.lastModifiedTime
|
|
25629
|
+
});
|
|
25630
|
+
}
|
|
25631
|
+
while (this.childProgressBaseline.size > 256) {
|
|
25632
|
+
this.childProgressBaseline.delete(this.childProgressBaseline.keys().next().value);
|
|
25633
|
+
}
|
|
25634
|
+
if (advanced) {
|
|
25635
|
+
this.events.emit("runtime_event", {
|
|
25636
|
+
kind: "internal_progress",
|
|
25637
|
+
source: "agy.native",
|
|
25638
|
+
itemType: "subagent_progress"
|
|
25639
|
+
});
|
|
25640
|
+
}
|
|
25641
|
+
}
|
|
25479
25642
|
refreshActivity() {
|
|
25480
25643
|
if (this.activityRead)
|
|
25481
25644
|
return this.activityRead;
|
|
@@ -25494,6 +25657,12 @@ class AgyAcpLane {
|
|
|
25494
25657
|
if (status === "running" && this.currentPromptRequestId === null)
|
|
25495
25658
|
this.unownedContent = true;
|
|
25496
25659
|
this.publishActivity();
|
|
25660
|
+
if (this.currentPromptRequestId !== null && this.terminalOwner !== null) {
|
|
25661
|
+
const children = await this.readChildProgress();
|
|
25662
|
+
if (!this.ready || this.requestedStopReason || this.processTerminal)
|
|
25663
|
+
return;
|
|
25664
|
+
this.observeChildProgress(children);
|
|
25665
|
+
}
|
|
25497
25666
|
})();
|
|
25498
25667
|
this.activityRead = reading;
|
|
25499
25668
|
reading.finally(() => {
|
|
@@ -37719,8 +37888,36 @@ async function readCursorQuota(options = {}, backend = "cursor") {
|
|
|
37719
37888
|
// agent-driver/dist/adapters/agy/quota.js
|
|
37720
37889
|
import { homedir as homedir14 } from "node:os";
|
|
37721
37890
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
37891
|
+
function classifyAgyQuotaError(message, sourceEpoch, structured) {
|
|
37892
|
+
const text2 = message.trim();
|
|
37893
|
+
if (!text2)
|
|
37894
|
+
return null;
|
|
37895
|
+
if (/(?:not authenticated|authentication (?:required|failed)|sign[ -]?in required|unauthenticated|unauthorized|invalid credentials|token expired|permission denied|\b401\b|\b403\b)/i.test(text2)) {
|
|
37896
|
+
return { status: "error", sourceEpoch, code: "unauthorized", retryable: false };
|
|
37897
|
+
}
|
|
37898
|
+
if (/(?:eligibility check failed|not eligible|not (?:currently )?available in your (?:location|region|country)|unsupported (?:location|region|country))/i.test(text2)) {
|
|
37899
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: false };
|
|
37900
|
+
}
|
|
37901
|
+
if (/(?:econnrefused|econnreset|etimedout|enotfound|ehostunreach|network error|fetch failed|dial tcp|socket hang up|connection refused|connection reset|proxyconnect|timed out|\bdns\b|\btls\b|\bssl\b)/i.test(text2)) {
|
|
37902
|
+
return { status: "error", sourceEpoch, code: "network", retryable: true };
|
|
37903
|
+
}
|
|
37904
|
+
if (/(?:rate[ -]?limit|too many requests|quota exceeded|\b429\b|\b50[0234]\b|internal server error|service unavailable|bad gateway|temporarily unavailable|resource exhausted|upstream)/i.test(text2)) {
|
|
37905
|
+
return { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
37906
|
+
}
|
|
37907
|
+
return structured ? { status: "error", sourceEpoch, code: "provider_error", retryable: true } : null;
|
|
37908
|
+
}
|
|
37909
|
+
function tryParseJson(text2) {
|
|
37910
|
+
try {
|
|
37911
|
+
return { ok: true, value: JSON.parse(text2) };
|
|
37912
|
+
} catch {
|
|
37913
|
+
return { ok: false };
|
|
37914
|
+
}
|
|
37915
|
+
}
|
|
37722
37916
|
function parseAgyQuota(value, sourceEpoch) {
|
|
37723
37917
|
const result = asRecord(value);
|
|
37918
|
+
if (result?.status === "ERROR" && typeof result.error === "string" && result.error.trim()) {
|
|
37919
|
+
return classifyAgyQuotaError(result.error, sourceEpoch, true) ?? { status: "error", sourceEpoch, code: "provider_error", retryable: true };
|
|
37920
|
+
}
|
|
37724
37921
|
const command = asRecord(result?.command);
|
|
37725
37922
|
const data = asRecord(command?.data);
|
|
37726
37923
|
const groups = data?.groups;
|
|
@@ -37757,21 +37954,58 @@ async function readAgyQuota(options = {}) {
|
|
|
37757
37954
|
const source = quotaSource("agy", randomUUID9());
|
|
37758
37955
|
const read = async (args) => {
|
|
37759
37956
|
const child = (options.spawn ?? spawnAgentProcess)(spec.command, args, { cwd: options.cwd ?? process.cwd(), env: { ...env, CI: "1", AGY_CLI_DISABLE_AUTO_UPDATE: "true" }, shell: spec.shell, stdin: "ignore" });
|
|
37760
|
-
let
|
|
37761
|
-
|
|
37762
|
-
|
|
37763
|
-
|
|
37764
|
-
|
|
37765
|
-
|
|
37766
|
-
|
|
37767
|
-
|
|
37768
|
-
|
|
37957
|
+
let stdout = "";
|
|
37958
|
+
let stderr = "";
|
|
37959
|
+
return runBoundedDiscoveryProcess({
|
|
37960
|
+
process: child,
|
|
37961
|
+
label: "AGY quota",
|
|
37962
|
+
timeoutMs: options.timeoutMs ?? 30000,
|
|
37963
|
+
outputMaxBytes: options.outputMaxBytes ?? 1024 * 1024,
|
|
37964
|
+
stderr: "count",
|
|
37965
|
+
cleanupGraceMs: 100,
|
|
37966
|
+
cleanup: options.cleanup,
|
|
37967
|
+
exitEvent: "close",
|
|
37968
|
+
onStdout: (text2) => {
|
|
37969
|
+
stdout += text2;
|
|
37970
|
+
},
|
|
37971
|
+
onStderr: (text2) => {
|
|
37972
|
+
stderr += text2;
|
|
37973
|
+
},
|
|
37974
|
+
onExit: (code, _signal, control) => {
|
|
37975
|
+
control.flushStdout();
|
|
37976
|
+
control.flushStderr();
|
|
37977
|
+
control.finish({ exitCode: code, stdout, stderr });
|
|
37978
|
+
}
|
|
37979
|
+
});
|
|
37769
37980
|
};
|
|
37770
37981
|
try {
|
|
37771
|
-
|
|
37982
|
+
const models = await read(["models"]);
|
|
37983
|
+
if (models.exitCode !== 0) {
|
|
37984
|
+
const classified2 = classifyAgyQuotaError(models.stderr || models.stdout, source.epoch, false);
|
|
37985
|
+
return source.finish(classified2 ?? source.error("unavailable", true));
|
|
37986
|
+
}
|
|
37987
|
+
if (!parseAgyModelCatalog(models.stdout))
|
|
37772
37988
|
return source.finish(source.error("unauthorized"));
|
|
37773
|
-
|
|
37774
|
-
|
|
37989
|
+
const usage = await read(["-p", "/usage", "--output-format", "json"]);
|
|
37990
|
+
const parsed = tryParseJson(usage.stdout);
|
|
37991
|
+
if (parsed.ok) {
|
|
37992
|
+
const record8 = asRecord(parsed.value);
|
|
37993
|
+
if (usage.exitCode === 0) {
|
|
37994
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
37995
|
+
}
|
|
37996
|
+
if (record8?.status === "ERROR" && typeof record8.error === "string" && record8.error.trim()) {
|
|
37997
|
+
return source.finish(parseAgyQuota(parsed.value, source.epoch));
|
|
37998
|
+
}
|
|
37999
|
+
}
|
|
38000
|
+
if (usage.exitCode === 0) {
|
|
38001
|
+
return source.finish(source.error("invalid_response", true));
|
|
38002
|
+
}
|
|
38003
|
+
const classified = classifyAgyQuotaError(usage.stderr || usage.stdout, source.epoch, false);
|
|
38004
|
+
return source.finish(classified ?? source.error("unavailable", true));
|
|
38005
|
+
} catch (error) {
|
|
38006
|
+
if (error instanceof DiscoveryProcessError && error.code === "output_limit") {
|
|
38007
|
+
return source.finish(source.error("invalid_response", true));
|
|
38008
|
+
}
|
|
37775
38009
|
return source.finish(source.error("unavailable", true));
|
|
37776
38010
|
}
|
|
37777
38011
|
}
|
|
@@ -63885,8 +64119,59 @@ var communityScheduleRun = sqliteTable("community_schedule_run", {
|
|
|
63885
64119
|
index("idx_community_schedule_run_bot_id_lookup").on(t.botUserId)
|
|
63886
64120
|
]);
|
|
63887
64121
|
|
|
64122
|
+
// ../shared/src/db/community-bot-private-inbox-schema.ts
|
|
64123
|
+
var exports_community_bot_private_inbox_schema = {};
|
|
64124
|
+
__export(exports_community_bot_private_inbox_schema, {
|
|
64125
|
+
communityBotPrivateInbox: () => communityBotPrivateInbox
|
|
64126
|
+
});
|
|
64127
|
+
var communityBotPrivateInbox = sqliteTable("community_bot_private_inbox", {
|
|
64128
|
+
id: text2("id").primaryKey(),
|
|
64129
|
+
ownerUserId: text2("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64130
|
+
botUserId: text2("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64131
|
+
sourceKind: text2("source_kind").$type().notNull(),
|
|
64132
|
+
sourceId: text2("source_id").notNull(),
|
|
64133
|
+
sourceRefId: text2("source_ref_id"),
|
|
64134
|
+
dedupeKey: text2("dedupe_key"),
|
|
64135
|
+
eventType: text2("event_type").notNull(),
|
|
64136
|
+
summary: text2("summary").notNull(),
|
|
64137
|
+
promptText: text2("prompt_text").notNull(),
|
|
64138
|
+
status: text2("status").$type().notNull(),
|
|
64139
|
+
lastError: text2("last_error"),
|
|
64140
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
64141
|
+
dispatchedAtMs: integer2("dispatched_at_ms")
|
|
64142
|
+
}, (t) => [
|
|
64143
|
+
uniqueIndex("uq_community_bot_private_inbox_dedupe").on(t.sourceKind, t.sourceId, t.dedupeKey).where(sql`${t.dedupeKey} IS NOT NULL`),
|
|
64144
|
+
index("idx_community_bot_private_inbox_bot_pending").on(t.botUserId, t.status, t.createdAtMs),
|
|
64145
|
+
index("idx_community_bot_private_inbox_source_created").on(t.sourceKind, t.sourceId, t.createdAtMs),
|
|
64146
|
+
index("idx_community_bot_private_inbox_owner").on(t.ownerUserId)
|
|
64147
|
+
]);
|
|
64148
|
+
|
|
64149
|
+
// ../shared/src/db/community-bot-webhook-schema.ts
|
|
64150
|
+
var exports_community_bot_webhook_schema = {};
|
|
64151
|
+
__export(exports_community_bot_webhook_schema, {
|
|
64152
|
+
communityBotWebhook: () => communityBotWebhook
|
|
64153
|
+
});
|
|
64154
|
+
var communityBotWebhook = sqliteTable("community_bot_webhook", {
|
|
64155
|
+
id: text2("id").primaryKey(),
|
|
64156
|
+
ownerUserId: text2("owner_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64157
|
+
botUserId: text2("bot_user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
64158
|
+
name: text2("name").notNull(),
|
|
64159
|
+
provider: text2("provider").$type().notNull(),
|
|
64160
|
+
tokenHash: text2("token_hash").notNull().unique(),
|
|
64161
|
+
signingSecretEnc: text2("signing_secret_enc"),
|
|
64162
|
+
eventFilterJson: text2("event_filter_json"),
|
|
64163
|
+
instruction: text2("instruction").notNull().default(""),
|
|
64164
|
+
enabled: integer2("enabled", { mode: "boolean" }).notNull().default(true),
|
|
64165
|
+
lastTriggeredAtMs: integer2("last_triggered_at_ms"),
|
|
64166
|
+
createdAtMs: integer2("created_at_ms").notNull(),
|
|
64167
|
+
updatedAtMs: integer2("updated_at_ms").notNull()
|
|
64168
|
+
}, (t) => [
|
|
64169
|
+
index("idx_community_bot_webhook_owner_bot").on(t.ownerUserId, t.botUserId, t.createdAtMs),
|
|
64170
|
+
index("idx_community_bot_webhook_bot").on(t.botUserId)
|
|
64171
|
+
]);
|
|
64172
|
+
|
|
63888
64173
|
// ../shared/src/db/index.ts
|
|
63889
|
-
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_community_schedule_schema };
|
|
64174
|
+
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema, ...exports_automation_schema, ...exports_feedback_schema, ...exports_community_schedule_schema, ...exports_community_bot_private_inbox_schema, ...exports_community_bot_webhook_schema };
|
|
63890
64175
|
// ../shared/src/db/queries/native-oauth.ts
|
|
63891
64176
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
63892
64177
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
@@ -64025,6 +64310,107 @@ var ScheduleUpdateRequestSchema = exports_external.strictObject({
|
|
|
64025
64310
|
ack: exports_external.literal(true).optional()
|
|
64026
64311
|
});
|
|
64027
64312
|
var formatterCache = new Map;
|
|
64313
|
+
// ../shared/src/bot-webhook.ts
|
|
64314
|
+
var BOT_WEBHOOK_PROVIDERS = [
|
|
64315
|
+
"github",
|
|
64316
|
+
"linear",
|
|
64317
|
+
"sentry",
|
|
64318
|
+
"stripe",
|
|
64319
|
+
"vercel",
|
|
64320
|
+
"gitlab",
|
|
64321
|
+
"slack",
|
|
64322
|
+
"openai",
|
|
64323
|
+
"resend",
|
|
64324
|
+
"clerk",
|
|
64325
|
+
"polar",
|
|
64326
|
+
"cloudflare",
|
|
64327
|
+
"grafana",
|
|
64328
|
+
"datadog",
|
|
64329
|
+
"n8n",
|
|
64330
|
+
"generic"
|
|
64331
|
+
];
|
|
64332
|
+
var BOT_WEBHOOK_DELIVERY_STATUSES = ["pending", "dispatched", "ignored", "failed"];
|
|
64333
|
+
var BOT_WEBHOOK_NAME_MAX_LENGTH = 80;
|
|
64334
|
+
var BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH = 500;
|
|
64335
|
+
var BOT_WEBHOOK_SECRET_MIN_LENGTH = 8;
|
|
64336
|
+
var BOT_WEBHOOK_SECRET_MAX_LENGTH = 256;
|
|
64337
|
+
var BOT_WEBHOOK_MAX_EVENT_FILTERS = 32;
|
|
64338
|
+
var BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH = 64;
|
|
64339
|
+
var BOT_WEBHOOK_RESYNC_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
64340
|
+
var BotWebhookProviderSchema = exports_external.enum(BOT_WEBHOOK_PROVIDERS);
|
|
64341
|
+
var BotWebhookDeliveryStatusSchema = exports_external.enum(BOT_WEBHOOK_DELIVERY_STATUSES);
|
|
64342
|
+
var EventFilterEntrySchema = exports_external.string().trim().min(1).max(BOT_WEBHOOK_EVENT_NAME_MAX_LENGTH).regex(/^[a-z0-9_.-]+$/i, "Event name may only contain letters, digits, _, ., and -");
|
|
64343
|
+
var BotWebhookEventFilterSchema = exports_external.array(EventFilterEntrySchema).max(BOT_WEBHOOK_MAX_EVENT_FILTERS).transform((items) => [...new Set(items.map((item) => item.toLowerCase()))]);
|
|
64344
|
+
var SigningSecretInputSchema = exports_external.string().trim().min(BOT_WEBHOOK_SECRET_MIN_LENGTH, `Verification key must be at least ${BOT_WEBHOOK_SECRET_MIN_LENGTH} characters`).max(BOT_WEBHOOK_SECRET_MAX_LENGTH, `Verification key must be at most ${BOT_WEBHOOK_SECRET_MAX_LENGTH} characters`);
|
|
64345
|
+
var BotWebhookLastDeliverySchema = exports_external.strictObject({
|
|
64346
|
+
id: exports_external.string().min(1),
|
|
64347
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
64348
|
+
eventType: exports_external.string().min(1),
|
|
64349
|
+
summary: exports_external.string(),
|
|
64350
|
+
lastError: exports_external.string().nullable(),
|
|
64351
|
+
createdAt: exports_external.iso.datetime()
|
|
64352
|
+
});
|
|
64353
|
+
var BotWebhookDeliverySchema = exports_external.strictObject({
|
|
64354
|
+
id: exports_external.string().min(1),
|
|
64355
|
+
webhookId: exports_external.string().min(1),
|
|
64356
|
+
eventType: exports_external.string().min(1),
|
|
64357
|
+
summary: exports_external.string(),
|
|
64358
|
+
status: BotWebhookDeliveryStatusSchema,
|
|
64359
|
+
lastError: exports_external.string().nullable(),
|
|
64360
|
+
externalDeliveryId: exports_external.string().nullable(),
|
|
64361
|
+
createdAt: exports_external.iso.datetime(),
|
|
64362
|
+
dispatchedAt: exports_external.iso.datetime().nullable()
|
|
64363
|
+
});
|
|
64364
|
+
var BotWebhookSummarySchema = exports_external.strictObject({
|
|
64365
|
+
id: exports_external.string().min(1),
|
|
64366
|
+
botId: exports_external.string().min(1),
|
|
64367
|
+
name: exports_external.string().min(1),
|
|
64368
|
+
provider: BotWebhookProviderSchema,
|
|
64369
|
+
hasSigningSecret: exports_external.boolean(),
|
|
64370
|
+
eventFilter: exports_external.array(exports_external.string()).nullable(),
|
|
64371
|
+
instruction: exports_external.string(),
|
|
64372
|
+
enabled: exports_external.boolean(),
|
|
64373
|
+
lastTriggeredAt: exports_external.iso.datetime().nullable(),
|
|
64374
|
+
createdAt: exports_external.iso.datetime(),
|
|
64375
|
+
updatedAt: exports_external.iso.datetime(),
|
|
64376
|
+
lastDelivery: BotWebhookLastDeliverySchema.nullable()
|
|
64377
|
+
});
|
|
64378
|
+
var BotWebhookCreateSchema = exports_external.strictObject({
|
|
64379
|
+
name: exports_external.string().trim().min(1, "Name is required").max(BOT_WEBHOOK_NAME_MAX_LENGTH),
|
|
64380
|
+
provider: BotWebhookProviderSchema,
|
|
64381
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
64382
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional().default(""),
|
|
64383
|
+
requireSecret: exports_external.boolean().optional(),
|
|
64384
|
+
signingSecret: SigningSecretInputSchema.optional()
|
|
64385
|
+
});
|
|
64386
|
+
var BotWebhookUpdateSchema = exports_external.strictObject({
|
|
64387
|
+
name: exports_external.string().trim().min(1).max(BOT_WEBHOOK_NAME_MAX_LENGTH).optional(),
|
|
64388
|
+
enabled: exports_external.boolean().optional(),
|
|
64389
|
+
eventFilter: BotWebhookEventFilterSchema.nullable().optional(),
|
|
64390
|
+
instruction: exports_external.string().trim().max(BOT_WEBHOOK_INSTRUCTION_MAX_LENGTH).optional(),
|
|
64391
|
+
requireSecret: exports_external.boolean().optional(),
|
|
64392
|
+
signingSecret: SigningSecretInputSchema.optional(),
|
|
64393
|
+
rotateCredentials: exports_external.boolean().optional()
|
|
64394
|
+
}).refine((v) => v.name !== undefined || v.enabled !== undefined || v.eventFilter !== undefined || v.instruction !== undefined || v.requireSecret !== undefined || v.signingSecret !== undefined || v.rotateCredentials === true, { message: "At least one field must be provided" });
|
|
64395
|
+
var BotWebhookCreateResponseSchema = exports_external.strictObject({
|
|
64396
|
+
webhook: BotWebhookSummarySchema,
|
|
64397
|
+
webhookUrl: exports_external.url(),
|
|
64398
|
+
signingSecret: exports_external.string().nullable()
|
|
64399
|
+
});
|
|
64400
|
+
var BotWebhookUpdateResponseSchema = exports_external.strictObject({
|
|
64401
|
+
webhook: BotWebhookSummarySchema,
|
|
64402
|
+
webhookUrl: exports_external.url().optional(),
|
|
64403
|
+
signingSecret: exports_external.string().nullable().optional()
|
|
64404
|
+
});
|
|
64405
|
+
var BotWebhookListResponseSchema = exports_external.strictObject({
|
|
64406
|
+
webhooks: exports_external.array(BotWebhookSummarySchema)
|
|
64407
|
+
});
|
|
64408
|
+
var BotWebhookDeliveriesResponseSchema = exports_external.strictObject({
|
|
64409
|
+
deliveries: exports_external.array(BotWebhookDeliverySchema)
|
|
64410
|
+
});
|
|
64411
|
+
var BotWebhookTestResponseSchema = exports_external.strictObject({
|
|
64412
|
+
delivery: BotWebhookDeliverySchema
|
|
64413
|
+
});
|
|
64028
64414
|
// ../shared/src/lib/channel-ref-syntax.ts
|
|
64029
64415
|
var REF_TERM = `.,;:!?)\\]}"'\\u2014\\u2019\\u201D\\u2026\\u3001\\u3002\\u3009\\u300B\\u300D\\u300F\\u3011\\u3015\\u3017\\u3019\\u301B\\uFF01\\uFF02\\uFF07\\uFF09\\uFF0C\\uFF0E\\uFF1A\\uFF1B\\uFF1F\\uFF3D\\uFF5D`;
|
|
64030
64416
|
var REF_SEG = `[^\\s/#${REF_TERM}]+`;
|
|
@@ -81360,6 +81746,10 @@ var communityProxyRoutes = {
|
|
|
81360
81746
|
avatar: "/api/community/users/me/avatar",
|
|
81361
81747
|
marks: "/api/community/users/me/marks"
|
|
81362
81748
|
};
|
|
81749
|
+
var SCHEDULE_EVENTS_PROXY_PATH_RE = /^\/api\/community\/schedule\/events(?:\/[^/]+)?$/;
|
|
81750
|
+
function isCanonicalCommunityProxyPath(pathname) {
|
|
81751
|
+
return pathname === "/api/community/platform/feedback" || SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname) || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
81752
|
+
}
|
|
81363
81753
|
function resolveProxyCapability(method, pathname) {
|
|
81364
81754
|
if (pathname === "/api/community/platform/feedback" && method === "POST")
|
|
81365
81755
|
return "send";
|
|
@@ -81369,7 +81759,7 @@ function resolveProxyCapability(method, pathname) {
|
|
|
81369
81759
|
return "read";
|
|
81370
81760
|
if (pathname === "/api/community/bots/creation-requests" && method === "POST")
|
|
81371
81761
|
return "send";
|
|
81372
|
-
if (
|
|
81762
|
+
if (SCHEDULE_EVENTS_PROXY_PATH_RE.test(pathname)) {
|
|
81373
81763
|
return method === "GET" ? "read" : "send";
|
|
81374
81764
|
}
|
|
81375
81765
|
if ((method === "GET" || method === "PATCH") && pathname === communityProxyRoutes.profile || method === "POST" && pathname === communityProxyRoutes.avatar)
|
|
@@ -81472,6 +81862,7 @@ function propertyAuditMetadata(method, pathname, requestUrl) {
|
|
|
81472
81862
|
}
|
|
81473
81863
|
function resolveProxyRoute(pathname, method, requestUrl = pathname) {
|
|
81474
81864
|
return {
|
|
81865
|
+
canonicalCommunityDoor: isCanonicalCommunityProxyPath(pathname),
|
|
81475
81866
|
capability: resolveProxyCapability(method ?? "", pathname),
|
|
81476
81867
|
auditOperation: resolveProxyAuditOperation(pathname, method),
|
|
81477
81868
|
propertyMetadata: propertyAuditMetadata(method ?? "", pathname, requestUrl),
|
|
@@ -82172,8 +82563,7 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
82172
82563
|
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
82173
82564
|
return;
|
|
82174
82565
|
}
|
|
82175
|
-
|
|
82176
|
-
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
82566
|
+
if (pathname === "/api" || pathname.startsWith("/api/") && !route.canonicalCommunityDoor) {
|
|
82177
82567
|
res.writeHead(404, { "content-type": "application/json" });
|
|
82178
82568
|
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
82179
82569
|
req.resume();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alook/daemon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"description": "Alook agent daemon — host-side runtime backend, process manager, credential proxy, and control plane.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/alookai/alook#readme",
|