@alook/daemon 0.1.71 → 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.
Files changed (3) hide show
  1. package/dist/cli/index.js +685 -432
  2. package/dist/index.js +681 -429
  3. package/package.json +4 -4
package/dist/cli/index.js CHANGED
@@ -13522,13 +13522,13 @@ var require_sourcemap_codec_umd = __commonJS((exports, module) => {
13522
13522
  });
13523
13523
  });
13524
13524
 
13525
- // ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
13525
+ // ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.3/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.umd.js
13526
13526
  var require_resolve_uri_umd = __commonJS((exports, module) => {
13527
13527
  (function(global, factory) {
13528
13528
  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());
13529
13529
  })(exports, function() {
13530
13530
  const schemeRegex = /^[\w+.-]+:\/\//;
13531
- const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
13531
+ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
13532
13532
  const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
13533
13533
  function isAbsoluteUrl(input2) {
13534
13534
  return schemeRegex.test(input2);
@@ -43112,7 +43112,7 @@ var AgentModelReportSchema = exports_external.object({
43112
43112
  provider: identity2.optional(),
43113
43113
  source: exports_external.enum(["response", "session"]),
43114
43114
  responseId: identity2.optional(),
43115
- observedAt: exports_external.string().datetime({ offset: true })
43115
+ observedAt: exports_external.iso.datetime({ offset: true })
43116
43116
  });
43117
43117
 
43118
43118
  // ../shared/src/community-decision-card.ts
@@ -43232,7 +43232,8 @@ var DecisionCardEmbedSchema = exports_external.strictObject({
43232
43232
  summary: exports_external.string().trim().min(1).max(DECISION_CARD_SUMMARY_MAX_LENGTH).optional(),
43233
43233
  assignees: exports_external.array(DecisionCardAssigneeSchema).max(DECISION_CARD_MAX_MENTIONS),
43234
43234
  questions: exports_external.array(DecisionCardNormalizedQuestionSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS),
43235
- respondedUserIds: exports_external.array(exports_external.string().min(1)).optional()
43235
+ respondedUserIds: exports_external.array(exports_external.string().min(1)).optional(),
43236
+ viewerDismissed: exports_external.boolean().optional()
43236
43237
  });
43237
43238
  var DecisionCardAnswerItemSchema = exports_external.strictObject({
43238
43239
  questionId: idFieldSchema,
@@ -43319,8 +43320,8 @@ var QuotaLimitSchema = exports_external.object({
43319
43320
  model: QuotaModelIdentitySchema,
43320
43321
  window: QuotaWindowIdentitySchema
43321
43322
  }).strict(),
43322
- usedPercent: exports_external.number().finite().min(0).max(100),
43323
- resetsAt: exports_external.string().datetime({ offset: true }).optional()
43323
+ usedPercent: exports_external.number().min(0).max(100),
43324
+ resetsAt: exports_external.iso.datetime({ offset: true }).optional()
43324
43325
  }).strict();
43325
43326
  function quotaIdentity(limit) {
43326
43327
  const { product, model, window: window2, limitId } = limit.bucket;
@@ -43843,7 +43844,7 @@ var BotAuditEventKindSchema = exports_external.enum([
43843
43844
  var HostBotAuditEventFrameSchema = exports_external.object({
43844
43845
  type: exports_external.literal("bot_audit_event"),
43845
43846
  eventId: exports_external.string().min(1).max(128).optional(),
43846
- occurredAt: exports_external.string().datetime({ offset: true }).optional(),
43847
+ occurredAt: exports_external.iso.datetime({ offset: true }).optional(),
43847
43848
  agentId: exports_external.string().min(1),
43848
43849
  sessionId: exports_external.string().nullable().optional(),
43849
43850
  launchId: exports_external.string().nullable().optional(),
@@ -44415,7 +44416,7 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
44415
44416
  var EntitlementValueSchema = exports_external.lazy(() => exports_external.union([
44416
44417
  exports_external.null(),
44417
44418
  exports_external.boolean(),
44418
- exports_external.number().finite(),
44419
+ exports_external.number(),
44419
44420
  exports_external.string(),
44420
44421
  exports_external.array(EntitlementValueSchema),
44421
44422
  exports_external.record(exports_external.string(), EntitlementValueSchema)
@@ -44442,11 +44443,11 @@ var BillingOfferSchema = exports_external.object({
44442
44443
  var BillingSubscriptionSchema = exports_external.object({
44443
44444
  plan: BillingPlanSchema,
44444
44445
  status: exports_external.string().min(1),
44445
- currentPeriodEnd: exports_external.string().datetime().nullable(),
44446
- cancelAt: exports_external.string().datetime().nullable(),
44446
+ currentPeriodEnd: exports_external.iso.datetime().nullable(),
44447
+ cancelAt: exports_external.iso.datetime().nullable(),
44447
44448
  scheduledChange: exports_external.object({
44448
44449
  plan: BillingPlanSchema,
44449
- effectiveAt: exports_external.string().datetime()
44450
+ effectiveAt: exports_external.iso.datetime()
44450
44451
  }).nullable()
44451
44452
  });
44452
44453
  var PublicPricingSchema = exports_external.object({
@@ -44471,7 +44472,7 @@ var BillingPortalRequestSchema = exports_external.strictObject({
44471
44472
  priceId: exports_external.string().min(1).max(255).optional()
44472
44473
  });
44473
44474
  var BillingRedirectResponseSchema = exports_external.object({
44474
- url: exports_external.string().url()
44475
+ url: exports_external.url()
44475
44476
  });
44476
44477
  // ../shared/src/utils/day-key.ts
44477
44478
  function utcDayKey(now) {
@@ -44509,7 +44510,7 @@ function dayKeyInTimeZone(now, timeZone) {
44509
44510
  return `${year}-${month}-${day}`;
44510
44511
  }
44511
44512
 
44512
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/entity.js
44513
+ // ../../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
44513
44514
  var entityKind = Symbol.for("drizzle:entityKind");
44514
44515
  var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
44515
44516
  function is(value, type) {
@@ -44534,7 +44535,7 @@ function is(value, type) {
44534
44535
  return false;
44535
44536
  }
44536
44537
 
44537
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/column.js
44538
+ // ../../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
44538
44539
  class Column {
44539
44540
  constructor(table, config2) {
44540
44541
  this.table = table;
@@ -44584,7 +44585,7 @@ class Column {
44584
44585
  }
44585
44586
  }
44586
44587
 
44587
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/column-builder.js
44588
+ // ../../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
44588
44589
  class ColumnBuilder {
44589
44590
  static [entityKind] = "ColumnBuilder";
44590
44591
  config;
@@ -44640,20 +44641,20 @@ class ColumnBuilder {
44640
44641
  }
44641
44642
  }
44642
44643
 
44643
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/table.utils.js
44644
+ // ../../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
44644
44645
  var TableName = Symbol.for("drizzle:Name");
44645
44646
 
44646
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/tracing-utils.js
44647
+ // ../../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
44647
44648
  function iife(fn, ...args) {
44648
44649
  return fn(...args);
44649
44650
  }
44650
44651
 
44651
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/pg-core/unique-constraint.js
44652
+ // ../../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
44652
44653
  function uniqueKeyName(table, columns) {
44653
44654
  return `${table[TableName]}_${columns.join("_")}_unique`;
44654
44655
  }
44655
44656
 
44656
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/pg-core/columns/common.js
44657
+ // ../../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
44657
44658
  class PgColumn extends Column {
44658
44659
  constructor(table, config2) {
44659
44660
  if (!config2.uniqueName) {
@@ -44702,7 +44703,7 @@ class ExtraConfigColumn extends PgColumn {
44702
44703
  }
44703
44704
  }
44704
44705
 
44705
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/pg-core/columns/enum.js
44706
+ // ../../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
44706
44707
  class PgEnumObjectColumn extends PgColumn {
44707
44708
  static [entityKind] = "PgEnumObjectColumn";
44708
44709
  enum;
@@ -44732,7 +44733,7 @@ class PgEnumColumn extends PgColumn {
44732
44733
  }
44733
44734
  }
44734
44735
 
44735
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/subquery.js
44736
+ // ../../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
44736
44737
  class Subquery {
44737
44738
  static [entityKind] = "Subquery";
44738
44739
  constructor(sql, fields, alias, isWith = false, usedTables = []) {
@@ -44747,10 +44748,10 @@ class Subquery {
44747
44748
  }
44748
44749
  }
44749
44750
 
44750
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/version.js
44751
+ // ../../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
44751
44752
  var version2 = "0.45.4";
44752
44753
 
44753
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/tracing.js
44754
+ // ../../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
44754
44755
  var otel;
44755
44756
  var rawTracer;
44756
44757
  var tracer = {
@@ -44777,10 +44778,10 @@ var tracer = {
44777
44778
  }
44778
44779
  };
44779
44780
 
44780
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/view-common.js
44781
+ // ../../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
44781
44782
  var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
44782
44783
 
44783
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/table.js
44784
+ // ../../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
44784
44785
  var Schema = Symbol.for("drizzle:Schema");
44785
44786
  var Columns = Symbol.for("drizzle:Columns");
44786
44787
  var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
@@ -44818,7 +44819,7 @@ class Table {
44818
44819
  }
44819
44820
  }
44820
44821
 
44821
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sql/sql.js
44822
+ // ../../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
44822
44823
  function isSQLWrapper(value) {
44823
44824
  return value !== null && value !== undefined && typeof value.getSQL === "function";
44824
44825
  }
@@ -45181,7 +45182,7 @@ Subquery.prototype.getSQL = function() {
45181
45182
  return new SQL([this]);
45182
45183
  };
45183
45184
 
45184
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/alias.js
45185
+ // ../../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
45185
45186
  class ColumnAliasProxyHandler {
45186
45187
  constructor(table) {
45187
45188
  this.table = table;
@@ -45237,7 +45238,7 @@ class TableAliasProxyHandler {
45237
45238
  }
45238
45239
  }
45239
45240
 
45240
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/utils.js
45241
+ // ../../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
45241
45242
  function getColumnNameAndConfig(a, b) {
45242
45243
  return {
45243
45244
  name: typeof a === "string" && a.length > 0 ? a : "",
@@ -45246,7 +45247,7 @@ function getColumnNameAndConfig(a, b) {
45246
45247
  }
45247
45248
  var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
45248
45249
 
45249
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sql/expressions/conditions.js
45250
+ // ../../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
45250
45251
  function bindIfParam(value, column) {
45251
45252
  if (isDriverValueEncoder(column) && !isSQLWrapper(value) && !is(value, Param) && !is(value, Placeholder) && !is(value, Column) && !is(value, Table) && !is(value, View)) {
45252
45253
  return new Param(value, column);
@@ -45277,7 +45278,7 @@ function isNotNull(value) {
45277
45278
  return sql`${value} is not null`;
45278
45279
  }
45279
45280
 
45280
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sql/expressions/select.js
45281
+ // ../../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
45281
45282
  function desc(column) {
45282
45283
  return sql`${column} desc`;
45283
45284
  }
@@ -45316,12 +45317,12 @@ __export(exports_community_schema, {
45316
45317
  communityAttachment: () => communityAttachment
45317
45318
  });
45318
45319
 
45319
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/alias.js
45320
+ // ../../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
45320
45321
  function alias(table, alias2) {
45321
45322
  return new Proxy(table, new TableAliasProxyHandler(alias2, false));
45322
45323
  }
45323
45324
 
45324
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/checks.js
45325
+ // ../../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
45325
45326
  class CheckBuilder {
45326
45327
  constructor(name, value) {
45327
45328
  this.name = name;
@@ -45348,7 +45349,7 @@ function check2(name, value) {
45348
45349
  return new CheckBuilder(name, value);
45349
45350
  }
45350
45351
 
45351
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
45352
+ // ../../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
45352
45353
  class ForeignKeyBuilder {
45353
45354
  static [entityKind] = "SQLiteForeignKeyBuilder";
45354
45355
  reference;
@@ -45402,7 +45403,7 @@ class ForeignKey {
45402
45403
  }
45403
45404
  }
45404
45405
 
45405
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
45406
+ // ../../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
45406
45407
  function uniqueKeyName2(table, columns) {
45407
45408
  return `${table[TableName]}_${columns.join("_")}_unique`;
45408
45409
  }
@@ -45447,7 +45448,7 @@ class UniqueConstraint {
45447
45448
  }
45448
45449
  }
45449
45450
 
45450
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/common.js
45451
+ // ../../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
45451
45452
  class SQLiteColumnBuilder extends ColumnBuilder {
45452
45453
  static [entityKind] = "SQLiteColumnBuilder";
45453
45454
  foreignKeyConfigs = [];
@@ -45498,7 +45499,7 @@ class SQLiteColumn extends Column {
45498
45499
  static [entityKind] = "SQLiteColumn";
45499
45500
  }
45500
45501
 
45501
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/blob.js
45502
+ // ../../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
45502
45503
  class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
45503
45504
  static [entityKind] = "SQLiteBigIntBuilder";
45504
45505
  constructor(name) {
@@ -45586,7 +45587,7 @@ function blob(a, b) {
45586
45587
  return new SQLiteBlobBufferBuilder(name);
45587
45588
  }
45588
45589
 
45589
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/custom.js
45590
+ // ../../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
45590
45591
  class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
45591
45592
  static [entityKind] = "SQLiteCustomColumnBuilder";
45592
45593
  constructor(name, fieldConfig, customTypeParams) {
@@ -45627,7 +45628,7 @@ function customType(customTypeParams) {
45627
45628
  };
45628
45629
  }
45629
45630
 
45630
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/integer.js
45631
+ // ../../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
45631
45632
  class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
45632
45633
  static [entityKind] = "SQLiteBaseIntegerBuilder";
45633
45634
  constructor(name, dataType, columnType) {
@@ -45729,7 +45730,7 @@ function integer2(a, b) {
45729
45730
  return new SQLiteIntegerBuilder(name);
45730
45731
  }
45731
45732
 
45732
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
45733
+ // ../../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
45733
45734
  class SQLiteNumericBuilder extends SQLiteColumnBuilder {
45734
45735
  static [entityKind] = "SQLiteNumericBuilder";
45735
45736
  constructor(name) {
@@ -45799,7 +45800,7 @@ function numeric(a, b) {
45799
45800
  return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
45800
45801
  }
45801
45802
 
45802
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/real.js
45803
+ // ../../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
45803
45804
  class SQLiteRealBuilder extends SQLiteColumnBuilder {
45804
45805
  static [entityKind] = "SQLiteRealBuilder";
45805
45806
  constructor(name) {
@@ -45820,7 +45821,7 @@ function real(name) {
45820
45821
  return new SQLiteRealBuilder(name ?? "");
45821
45822
  }
45822
45823
 
45823
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/text.js
45824
+ // ../../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
45824
45825
  class SQLiteTextBuilder extends SQLiteColumnBuilder {
45825
45826
  static [entityKind] = "SQLiteTextBuilder";
45826
45827
  constructor(name, config2) {
@@ -45875,7 +45876,7 @@ function text(a, b = {}) {
45875
45876
  return new SQLiteTextBuilder(name, config2);
45876
45877
  }
45877
45878
 
45878
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/columns/all.js
45879
+ // ../../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
45879
45880
  function getSQLiteColumnBuilders() {
45880
45881
  return {
45881
45882
  blob,
@@ -45887,7 +45888,7 @@ function getSQLiteColumnBuilders() {
45887
45888
  };
45888
45889
  }
45889
45890
 
45890
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/table.js
45891
+ // ../../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
45891
45892
  var InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
45892
45893
 
45893
45894
  class SQLiteTable extends Table {
@@ -45921,7 +45922,7 @@ var sqliteTable = (name, columns, extraConfig) => {
45921
45922
  return sqliteTableBase(name, columns, extraConfig);
45922
45923
  };
45923
45924
 
45924
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/indexes.js
45925
+ // ../../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
45925
45926
  class IndexBuilderOn {
45926
45927
  constructor(name, unique2) {
45927
45928
  this.name = name;
@@ -45967,7 +45968,7 @@ function uniqueIndex(name) {
45967
45968
  return new IndexBuilderOn(name, true);
45968
45969
  }
45969
45970
 
45970
- // ../../node_modules/.pnpm/drizzle-orm@0.45.4_@cloudflare+workers-types@5.20261114.1_@opentelemetry+api@1.10.0_@ty_3390f7c80ab771c33a3e98a1c71b9106/node_modules/drizzle-orm/sqlite-core/primary-keys.js
45971
+ // ../../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
45971
45972
  function primaryKey(...config2) {
45972
45973
  if (config2[0].columns) {
45973
45974
  return new PrimaryKeyBuilder(config2[0].columns, config2[0].name);
@@ -46655,19 +46656,18 @@ class Logger {
46655
46656
  entry[k] = { message: v.message, stack: v.stack };
46656
46657
  }
46657
46658
  }
46658
- let line;
46659
- if (this.pretty) {
46659
+ const output2 = this.pretty ? (() => {
46660
46660
  const ts = entry.ts.replace("T", " ").replace("Z", "");
46661
46661
  const lvl = entry.level.toUpperCase().padEnd(5);
46662
46662
  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(" ");
46663
- line = `${ts} ${lvl} [${entry.service}] ${entry.msg}${pairs ? " " + pairs : ""}`;
46664
- } else {
46665
- line = JSON.stringify(entry);
46666
- }
46663
+ return `${ts} ${lvl} [${entry.service}] ${entry.msg}${pairs ? " " + pairs : ""}`;
46664
+ })() : entry;
46667
46665
  if (level === "error") {
46668
- console.error(line);
46666
+ console.error(output2);
46667
+ } else if (level === "warn") {
46668
+ console.warn(output2);
46669
46669
  } else {
46670
- console.log(line);
46670
+ console.log(output2);
46671
46671
  }
46672
46672
  }
46673
46673
  }
@@ -55790,7 +55790,7 @@ function toResult(value) {
55790
55790
  }
55791
55791
  return value === null || value === undefined ? empty : [value];
55792
55792
  }
55793
- // ../../node_modules/.pnpm/mdast-util-find-and-replace@3.0.4/node_modules/mdast-util-find-and-replace/lib/index.js
55793
+ // ../../node_modules/.pnpm/mdast-util-find-and-replace@3.0.5/node_modules/mdast-util-find-and-replace/lib/index.js
55794
55794
  function findAndReplace(tree, list2, options) {
55795
55795
  const settings = options || {};
55796
55796
  const ignored = convert(settings.ignore || []);
@@ -55826,9 +55826,7 @@ function findAndReplace(tree, list2, options) {
55826
55826
  if (typeof value === "string") {
55827
55827
  value = value.length > 0 ? { type: "text", value } : undefined;
55828
55828
  }
55829
- if (value === false) {
55830
- find.lastIndex = position2 + 1;
55831
- } else {
55829
+ if (value !== false) {
55832
55830
  if (start !== position2) {
55833
55831
  add({ type: "text", value: node3.value.slice(start, position2) });
55834
55832
  }
@@ -55841,6 +55839,10 @@ function findAndReplace(tree, list2, options) {
55841
55839
  start = position2 + match[0].length;
55842
55840
  change = true;
55843
55841
  }
55842
+ if (value === false || match[0].length === 0) {
55843
+ const code = node3.value.codePointAt(position2) || 0;
55844
+ find.lastIndex = position2 + (/[uv]/.test(find.flags) && code > 65535 ? 2 : 1);
55845
+ }
55844
55846
  if (!find.global) {
55845
55847
  break;
55846
55848
  }
@@ -55886,7 +55888,7 @@ function toFunction(replace) {
55886
55888
  return replace;
55887
55889
  };
55888
55890
  }
55889
- // ../../node_modules/.pnpm/mdast-util-gfm-autolink-literal@2.0.1/node_modules/mdast-util-gfm-autolink-literal/lib/index.js
55891
+ // ../../node_modules/.pnpm/mdast-util-gfm-autolink-literal@2.1.0/node_modules/mdast-util-gfm-autolink-literal/lib/index.js
55890
55892
  var inConstruct = "phrasing";
55891
55893
  var notInConstruct = ["autolink", "link", "image", "label"];
55892
55894
  function gfmAutolinkLiteralFromMarkdown() {
@@ -55934,7 +55936,7 @@ function gfmAutolinkLiteralToMarkdown() {
55934
55936
  };
55935
55937
  }
55936
55938
  function enterLiteralAutolink(token) {
55937
- this.enter({ type: "link", title: null, url: "", children: [] }, token);
55939
+ this.enter({ type: "link", title: null, url: "", children: [], position: undefined }, token);
55938
55940
  }
55939
55941
  function enterLiteralAutolinkValue(token) {
55940
55942
  this.config.enter.autolinkProtocol.call(this, token);
@@ -55956,62 +55958,107 @@ function exitLiteralAutolink(token) {
55956
55958
  }
55957
55959
  function transformGfmAutolinkLiterals(tree) {
55958
55960
  findAndReplace(tree, [
55959
- [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
55960
- [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
55961
+ [
55962
+ /(?<![\da-z])(https?:\/\/|www(?=\.))([\w-]*\.[\w\-.]*)([^\t\n\r ]*)/gi,
55963
+ findUrl
55964
+ ],
55965
+ [
55966
+ /(?<![\w+\-.@])xmpp:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)(\/(?:[\w\-/]|\.(?=[\dA-Za-z]))*)?/g,
55967
+ findXmpp
55968
+ ],
55969
+ [/(?<![\w+\-.@])mailto:([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g, findMailto],
55970
+ [
55971
+ /(?<![\w+\-.]|(?:^|[^\d@A-Za-z])(?:mailto|xmpp):)([\w+\-.]+)@([\w-]+(?:\.[\w-]+)+)/g,
55972
+ findEmail
55973
+ ]
55961
55974
  ], { ignore: ["link", "linkReference"] });
55962
55975
  }
55963
55976
  function findUrl(_, protocol, domain2, path2, match) {
55964
- let prefix = "";
55965
55977
  if (!previous2(match)) {
55966
55978
  return false;
55967
55979
  }
55980
+ let prefix = "";
55968
55981
  if (/^w/i.test(protocol)) {
55969
55982
  domain2 = protocol + domain2;
55970
55983
  protocol = "";
55971
55984
  prefix = "http://";
55972
55985
  }
55973
- if (!isCorrectDomain(domain2)) {
55986
+ if (unicodePunctuation(domain2.charCodeAt(0)) || !isCorrectDomain(domain2)) {
55974
55987
  return false;
55975
55988
  }
55976
55989
  const parts = splitUrl(domain2 + path2);
55977
- if (!parts[0])
55978
- return false;
55979
55990
  const result = {
55980
55991
  type: "link",
55981
55992
  title: null,
55982
55993
  url: prefix + protocol + parts[0],
55983
- children: [{ type: "text", value: protocol + parts[0] }]
55994
+ children: [{ type: "text", value: protocol + parts[0], position: undefined }],
55995
+ position: undefined
55984
55996
  };
55985
55997
  if (parts[1]) {
55986
- return [result, { type: "text", value: parts[1] }];
55998
+ return [result, { type: "text", value: parts[1], position: undefined }];
55987
55999
  }
55988
56000
  return result;
55989
56001
  }
55990
- function findEmail(_, atext, label, match) {
55991
- if (!previous2(match, true) || /[-\d_]$/.test(label)) {
56002
+ function findEmail(_, atext, label) {
56003
+ if (/[\d\-_]$/.test(label)) {
55992
56004
  return false;
55993
56005
  }
55994
56006
  return {
55995
56007
  type: "link",
55996
56008
  title: null,
55997
56009
  url: "mailto:" + atext + "@" + label,
55998
- children: [{ type: "text", value: atext + "@" + label }]
56010
+ children: [{ type: "text", value: atext + "@" + label, position: undefined }],
56011
+ position: undefined
56012
+ };
56013
+ }
56014
+ function findMailto(_, atext, label) {
56015
+ if (/[\d\-_]$/.test(label)) {
56016
+ return false;
56017
+ }
56018
+ const value = "mailto:" + atext + "@" + label;
56019
+ return {
56020
+ type: "link",
56021
+ title: null,
56022
+ url: value,
56023
+ children: [{ type: "text", value, position: undefined }],
56024
+ position: undefined
56025
+ };
56026
+ }
56027
+ function findXmpp(matchValue, atext, label, resource, match) {
56028
+ if (/[\d\-_]$/.test(label) || resource && (!/[A-Za-z]$/.test(resource) || match.input.charAt(match.index + matchValue.length) === "@")) {
56029
+ return false;
56030
+ }
56031
+ const value = "xmpp:" + atext + "@" + label + (resource || "");
56032
+ return {
56033
+ type: "link",
56034
+ title: null,
56035
+ url: value,
56036
+ children: [{ type: "text", value, position: undefined }],
56037
+ position: undefined
55999
56038
  };
56000
56039
  }
56001
56040
  function isCorrectDomain(domain2) {
56002
56041
  const parts = domain2.split(".");
56003
- if (parts.length < 2 || parts[parts.length - 1] && (/_/.test(parts[parts.length - 1]) || !/[a-zA-Z\d]/.test(parts[parts.length - 1])) || parts[parts.length - 2] && (/_/.test(parts[parts.length - 2]) || !/[a-zA-Z\d]/.test(parts[parts.length - 2]))) {
56042
+ 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]))) {
56004
56043
  return false;
56005
56044
  }
56006
56045
  return true;
56007
56046
  }
56008
56047
  function splitUrl(url2) {
56009
- const trailExec = /[!"&'),.:;<>?\]}]+$/.exec(url2);
56010
- if (!trailExec) {
56048
+ let index3 = url2.length;
56049
+ while (index3 > 0) {
56050
+ const code = url2.charCodeAt(index3 - 1);
56051
+ 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) {
56052
+ index3--;
56053
+ } else {
56054
+ break;
56055
+ }
56056
+ }
56057
+ if (index3 === url2.length) {
56011
56058
  return [url2, undefined];
56012
56059
  }
56013
- url2 = url2.slice(0, trailExec.index);
56014
- let trail = trailExec[0];
56060
+ let trail = url2.slice(index3);
56061
+ url2 = url2.slice(0, index3);
56015
56062
  let closingParenIndex = trail.indexOf(")");
56016
56063
  const openingParens = ccount(url2, "(");
56017
56064
  let closingParens = ccount(url2, ")");
@@ -56023,9 +56070,9 @@ function splitUrl(url2) {
56023
56070
  }
56024
56071
  return [url2, trail];
56025
56072
  }
56026
- function previous2(match, email3) {
56073
+ function previous2(match) {
56027
56074
  const code = match.input.charCodeAt(match.index - 1);
56028
- return (match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code)) && (!email3 || code !== 47);
56075
+ return match.index === 0 || unicodeWhitespace(code) || unicodePunctuation(code);
56029
56076
  }
56030
56077
  // ../../node_modules/.pnpm/mdast-util-gfm-footnote@2.1.0/node_modules/mdast-util-gfm-footnote/lib/index.js
56031
56078
  footnoteReference.peek = footnoteReferencePeek;
@@ -56558,25 +56605,37 @@ function emphasisPeek(_, _1, state) {
56558
56605
  return state.options.emphasis || "*";
56559
56606
  }
56560
56607
 
56561
- // ../../node_modules/.pnpm/unist-util-visit@5.1.0/node_modules/unist-util-visit/lib/index.js
56562
- function visit2(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
56608
+ // ../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
56609
+ function visit2(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
56610
+ let check3;
56611
+ let visitors;
56563
56612
  let reverse;
56564
- let test;
56565
- let visitor;
56566
- if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
56567
- test = undefined;
56568
- visitor = testOrVisitor;
56569
- reverse = visitorOrReverse;
56570
- } else {
56571
- test = testOrVisitor;
56572
- visitor = visitorOrReverse;
56613
+ if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
56614
+ check3 = testOrEnterOrVisitors;
56615
+ visitors = enterOrVisitorsOrReverse;
56573
56616
  reverse = maybeReverse;
56617
+ } else {
56618
+ visitors = testOrEnterOrVisitors;
56619
+ reverse = enterOrVisitorsOrReverse;
56574
56620
  }
56575
- visitParents(tree, test, overload, reverse);
56576
- function overload(node3, parents) {
56577
- const parent = parents[parents.length - 1];
56578
- const index3 = parent ? parent.children.indexOf(node3) : undefined;
56579
- return visitor(node3, index3, parent);
56621
+ if (typeof visitors === "function") {
56622
+ visitParents(tree, check3, wrap2(visitors), reverse);
56623
+ } else {
56624
+ visitParents(tree, check3, wrapVisitors(visitors), reverse);
56625
+ }
56626
+ }
56627
+ function wrapVisitors(visitors) {
56628
+ if (!visitors || typeof visitors !== "object")
56629
+ return visitors;
56630
+ return {
56631
+ enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
56632
+ exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
56633
+ };
56634
+ }
56635
+ function wrap2(visitor) {
56636
+ return overload;
56637
+ function overload(node3, parents, index3) {
56638
+ return visitor(node3, index3, parents[parents.length - 1]);
56580
56639
  }
56581
56640
  }
56582
56641
  // ../../node_modules/.pnpm/mdast-util-to-markdown@2.1.2/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
@@ -59653,43 +59712,10 @@ function peek(_, _1, state) {
59653
59712
  return state.options.emphasis || "*";
59654
59713
  }
59655
59714
 
59656
- // ../../node_modules/.pnpm/unist-util-visit@5.2.0/node_modules/unist-util-visit/lib/index.js
59657
- function visit3(tree, testOrEnterOrVisitors, enterOrVisitorsOrReverse, maybeReverse) {
59658
- let check4;
59659
- let visitors;
59660
- let reverse;
59661
- if (typeof enterOrVisitorsOrReverse === "function" || enterOrVisitorsOrReverse && typeof enterOrVisitorsOrReverse === "object") {
59662
- check4 = testOrEnterOrVisitors;
59663
- visitors = enterOrVisitorsOrReverse;
59664
- reverse = maybeReverse;
59665
- } else {
59666
- visitors = testOrEnterOrVisitors;
59667
- reverse = enterOrVisitorsOrReverse;
59668
- }
59669
- if (typeof visitors === "function") {
59670
- visitParents(tree, check4, wrap2(visitors), reverse);
59671
- } else {
59672
- visitParents(tree, check4, wrapVisitors(visitors), reverse);
59673
- }
59674
- }
59675
- function wrapVisitors(visitors) {
59676
- if (!visitors || typeof visitors !== "object")
59677
- return visitors;
59678
- return {
59679
- enter: typeof visitors.enter === "function" ? wrap2(visitors.enter) : visitors.enter,
59680
- exit: typeof visitors.exit === "function" ? wrap2(visitors.exit) : visitors.exit
59681
- };
59682
- }
59683
- function wrap2(visitor) {
59684
- return overload;
59685
- function overload(node3, parents, index3) {
59686
- return visitor(node3, index3, parents[parents.length - 1]);
59687
- }
59688
- }
59689
59715
  // ../../node_modules/.pnpm/mdast-util-to-markdown@2.2.3/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
59690
59716
  function formatHeadingAsSetext2(node3, state) {
59691
59717
  let literalWithBreak = false;
59692
- visit3(node3, function(node4) {
59718
+ visit2(node3, function(node4) {
59693
59719
  if ("value" in node4 && /\r?\n|\r/.test(node4.value) || node4.type === "break") {
59694
59720
  literalWithBreak = true;
59695
59721
  return EXIT;
@@ -63594,9 +63620,11 @@ function parseNativeExecution(data) {
63594
63620
 
63595
63621
  class NativeExecutionReader {
63596
63622
  readRows;
63623
+ continuations;
63597
63624
  path;
63598
- constructor(home, sessionId, readRows = queryExecutionRows) {
63625
+ constructor(home, sessionId, readRows = queryExecutionRows, continuations = false) {
63599
63626
  this.readRows = readRows;
63627
+ this.continuations = continuations;
63600
63628
  if (!/^[a-zA-Z0-9_-]{1,100}$/.test(sessionId))
63601
63629
  throw new Error("Invalid native execution session identity");
63602
63630
  this.path = join7(home, "antigravity-cli", "conversations", `${sessionId}.db`);
@@ -63612,20 +63640,28 @@ class NativeExecutionReader {
63612
63640
  return { index: row.idx, executionId: execution.executionId, lastStepIndex: execution.lastStepIndex };
63613
63641
  }
63614
63642
  async terminal(checkpoint) {
63615
- const rows = await this.readRows(this.path, checkpoint.index, checkpoint.lastStepIndex);
63616
- if (rows.length !== 1)
63643
+ const max = this.continuations ? 32 : 1;
63644
+ const rows = await this.readRows(this.path, checkpoint.index, checkpoint.lastStepIndex, undefined, max + 1);
63645
+ if (!rows.length || rows.length > max)
63617
63646
  throw new Error("Native execution terminal unavailable or ambiguous");
63618
- const row = this.validate(rows[0]);
63619
- const execution = parseNativeExecution(Buffer.from(row.data, "hex"));
63620
- if (row.has_children !== 0)
63621
- throw new Error("Native executor subtrajectory ownership cannot be verified");
63622
- if (row.idx !== checkpoint.index + 1 || execution.executionId === checkpoint.executionId)
63623
- throw new Error("Native execution terminal does not belong to the new root");
63624
- if (execution.hasError || execution.reason === 1)
63625
- return "failed";
63626
- if (execution.reason === 2)
63627
- return "interrupted";
63628
- return execution.reason === 4 ? "success" : "failed";
63647
+ let lastStep = checkpoint.lastStepIndex;
63648
+ const identities = new Set([checkpoint.executionId]);
63649
+ let outcome = "success";
63650
+ for (let index3 = 0;index3 < rows.length; index3++) {
63651
+ const row = this.validate(rows[index3]);
63652
+ const execution = parseNativeExecution(Buffer.from(row.data, "hex"));
63653
+ if (row.has_children !== 0)
63654
+ throw new Error("Native executor subtrajectory ownership cannot be verified");
63655
+ if (row.idx !== checkpoint.index + index3 + 1 || identities.has(execution.executionId) || this.continuations && execution.lastStepIndex <= lastStep)
63656
+ throw new Error("Native execution terminal does not belong to the new root");
63657
+ identities.add(execution.executionId);
63658
+ lastStep = execution.lastStepIndex;
63659
+ if (execution.hasError || execution.reason !== 2 && execution.reason !== 4)
63660
+ outcome = "failed";
63661
+ else if (execution.reason === 2 && outcome !== "failed")
63662
+ outcome = "interrupted";
63663
+ }
63664
+ return outcome;
63629
63665
  }
63630
63666
  validate(row) {
63631
63667
  if (!Number.isSafeInteger(row.idx) || row.idx < 0 || !/^(?:[a-f0-9]{2})+$/i.test(row.data) || row.data.length > 2 * 1024 * 1024)
@@ -63647,10 +63683,12 @@ async function openNativeExecutionDatabase(path8, loadBuiltin = async () => {
63647
63683
  }
63648
63684
  return new sqlite.DatabaseSync(path8, { readOnly: true });
63649
63685
  }
63650
- async function queryExecutionRows(path8, after, afterStep = -1, openDatabase = openNativeExecutionDatabase) {
63686
+ async function queryExecutionRows(path8, after, afterStep = -1, openDatabase = openNativeExecutionDatabase, maxRows = 2) {
63651
63687
  if (after !== undefined && (!Number.isSafeInteger(after) || after < -1) || !Number.isSafeInteger(afterStep) || afterStep < -1)
63652
63688
  throw new Error("Invalid native execution cursor");
63653
- 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 2`}`;
63689
+ if (!Number.isSafeInteger(maxRows) || maxRows < 1 || maxRows > 33)
63690
+ throw new Error("Invalid native execution read limit");
63691
+ 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}`}`;
63654
63692
  const db = await openDatabase(path8);
63655
63693
  try {
63656
63694
  return db.prepare(query).all();
@@ -63659,6 +63697,37 @@ async function queryExecutionRows(path8, after, afterStep = -1, openDatabase = o
63659
63697
  }
63660
63698
  }
63661
63699
 
63700
+ class NativeSessionActivityReader {
63701
+ sessionId;
63702
+ version;
63703
+ openDatabase;
63704
+ path;
63705
+ constructor(home, sessionId, version3, openDatabase = openNativeExecutionDatabase) {
63706
+ this.sessionId = sessionId;
63707
+ this.version = version3;
63708
+ this.openDatabase = openDatabase;
63709
+ if (!/^[a-zA-Z0-9_-]{1,100}$/.test(sessionId))
63710
+ throw new Error("Invalid native activity session identity");
63711
+ this.path = join7(home, "antigravity-cli", "conversation_summaries.db");
63712
+ }
63713
+ async activity() {
63714
+ if (this.version !== "1.5.16")
63715
+ return "unknown";
63716
+ const db = await this.openDatabase(this.path);
63717
+ try {
63718
+ const rows = db.prepare("SELECT status,not_fully_idle FROM conversation_summaries WHERE conversation_id = ? LIMIT 1").all(this.sessionId);
63719
+ const row = rows[0];
63720
+ if (!row || row.not_fully_idle !== 0 && row.not_fully_idle !== 1)
63721
+ return "unknown";
63722
+ if (row.status === "CASCADE_RUN_STATUS_RUNNING")
63723
+ return "running";
63724
+ return row.status === "CASCADE_RUN_STATUS_IDLE" ? row.not_fully_idle ? "running" : "idle" : "unknown";
63725
+ } finally {
63726
+ db.close();
63727
+ }
63728
+ }
63729
+ }
63730
+
63662
63731
  // agent-driver/dist/internal/model-observation.js
63663
63732
  function id3(value) {
63664
63733
  if (typeof value !== "string")
@@ -63876,6 +63945,18 @@ class AgyAcpLane {
63876
63945
  events = new EventEmitter;
63877
63946
  pending = new Map;
63878
63947
  toolCalls = new Map;
63948
+ completedTools = new Set;
63949
+ unownedContent = false;
63950
+ activityReader;
63951
+ activityRead;
63952
+ activityTimer;
63953
+ nativeActivity = "unknown";
63954
+ publishedActivity;
63955
+ activityRevision = 0;
63956
+ nativeVersion = "";
63957
+ contentOwner;
63958
+ executionIsolated = true;
63959
+ nativeClose = false;
63879
63960
  process = null;
63880
63961
  requestSequence = 0;
63881
63962
  started = false;
@@ -63951,10 +64032,13 @@ class AgyAcpLane {
63951
64032
  const sessionId = this.sessionId;
63952
64033
  if (!sessionId)
63953
64034
  throw new Error("Agy ACP handshake completed without a session id");
63954
- this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId);
64035
+ this.executionReader = this.options.executionReader ?? new NativeExecutionReader(this.stateHome, sessionId, undefined, this.nativeVersion === "1.5.16");
63955
64036
  this.processActivated = true;
63956
64037
  this.ready = true;
63957
64038
  this.events.emit("runtime_event", { kind: "session_init", sessionId, acquisition: { status: input2.sessionId ? "resumed" : "created", evidence: "native_api" } });
64039
+ this.activityReader = this.options.activityReader ?? new NativeSessionActivityReader(this.stateHome, sessionId, this.nativeVersion);
64040
+ await this.refreshActivity();
64041
+ this.scheduleActivity();
63958
64042
  const admission = await this.admitRoot(input2.text, input2.inputs);
63959
64043
  if (!admission.ok)
63960
64044
  throw new AgyAcpIncompatibleError(admission.error ?? "Native execution state unavailable");
@@ -63999,6 +64083,8 @@ class AgyAcpLane {
63999
64083
  stop(input2 = {}) {
64000
64084
  this.requestedStopReason ??= input2.reason ?? "requested_stop";
64001
64085
  this.ready = false;
64086
+ if (this.activityTimer)
64087
+ clearTimeout(this.activityTimer);
64002
64088
  this.currentPromptRequestId = null;
64003
64089
  this.terminalOwner = null;
64004
64090
  this.toolCalls.clear();
@@ -64016,20 +64102,29 @@ class AgyAcpLane {
64016
64102
  return this.stopPromise;
64017
64103
  }
64018
64104
  async stopPhysicalOnce(input2) {
64105
+ const deadline = Date.now() + (input2.forceAfterMs ?? SESSION_STOP_GRACE_MS);
64019
64106
  await this.spawnPromise?.catch(() => {
64020
64107
  return;
64021
64108
  });
64022
64109
  const proc = this.process;
64023
64110
  if (!proc)
64024
64111
  return;
64112
+ let closeAcknowledged = false;
64113
+ if (this.nativeClose && this.sessionId && !this.isClosed() && deadline > Date.now()) {
64114
+ try {
64115
+ await this.request("session/close", { sessionId: this.sessionId }, Math.max(1, deadline - Date.now())).promise;
64116
+ closeAcknowledged = true;
64117
+ } catch {}
64118
+ }
64025
64119
  if (proc.pid) {
64026
- await killProcessTree(proc.pid, { graceMs: input2.forceAfterMs ?? SESSION_STOP_GRACE_MS });
64120
+ await killProcessTree(proc.pid, { graceMs: closeAcknowledged ? 0 : Math.max(0, deadline - Date.now()) });
64027
64121
  } else if (!this.isClosed()) {
64028
64122
  proc.kill(input2.signal ?? "SIGTERM");
64029
64123
  }
64030
64124
  await this.executionRead?.catch(() => {
64031
64125
  return;
64032
64126
  });
64127
+ await this.activityRead;
64033
64128
  }
64034
64129
  async handshake(ctx) {
64035
64130
  const initialize = record3(await this.call("initialize", {
@@ -64044,6 +64139,7 @@ class AgyAcpLane {
64044
64139
  throw new AgyAcpIncompatibleError("Installed Agy ACP does not support protocol version 1");
64045
64140
  }
64046
64141
  const capabilities = record3(initialize.agentCapabilities);
64142
+ this.nativeClose = record3(record3(capabilities?.sessionCapabilities)?.close) !== null;
64047
64143
  if (capabilities?.loadSession !== true) {
64048
64144
  throw new AgyAcpIncompatibleError("Installed Agy ACP does not support persistent session loading");
64049
64145
  }
@@ -64051,6 +64147,7 @@ class AgyAcpLane {
64051
64147
  throw new AgyAcpIncompatibleError("Expected the native Antigravity CLI ACP server");
64052
64148
  }
64053
64149
  const version3 = record3(initialize.agentInfo)?.version;
64150
+ this.nativeVersion = typeof version3 === "string" ? version3 : "";
64054
64151
  this.usageProfile = version3 === "1.4.12" ? { inputIncludesCache: true, outputIncludesReasoning: false } : version3 === "1.5.9" ? { inputIncludesCache: false, outputIncludesReasoning: true } : undefined;
64055
64152
  if (!record3(record3(initialize.agentCapabilities)?.sessionCapabilities)?.resume) {
64056
64153
  throw new AgyAcpIncompatibleError("Antigravity CLI ACP does not support native session resume");
@@ -64257,6 +64354,7 @@ class AgyAcpLane {
64257
64354
  if (!this.ready || this.requestedStopReason || this.isClosed())
64258
64355
  return { ok: false, reason: "closed" };
64259
64356
  this.executionCheckpoint = checkpoint;
64357
+ this.executionIsolated = !this.unownedContent && !this.hasPendingTools();
64260
64358
  return this.admitPrompt(text7, "prompt", inputs);
64261
64359
  } catch {
64262
64360
  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." };
@@ -64283,7 +64381,7 @@ class AgyAcpLane {
64283
64381
  this.terminalOwner = prompt.receipt;
64284
64382
  this.currentPromptRequestId = requestId;
64285
64383
  if (delivery === "prompt") {
64286
- this.toolCalls.clear();
64384
+ this.contentOwner = !this.unownedContent && !this.hasPendingTools() ? prompt.receipt : undefined;
64287
64385
  this.promptOutcomes.clear();
64288
64386
  this.observedPrompts.clear();
64289
64387
  this.loopStartedAt = new Date().toISOString();
@@ -64350,13 +64448,22 @@ class AgyAcpLane {
64350
64448
  const read = this.executionReader.terminal(this.executionCheckpoint);
64351
64449
  this.executionRead = read;
64352
64450
  nativeOutcome = await read;
64451
+ if (!this.executionIsolated)
64452
+ nativeOutcome = "unknown";
64353
64453
  } catch {
64354
- verificationError = new Error("Antigravity CLI native execution terminal could not be verified");
64454
+ if (this.executionIsolated)
64455
+ verificationError = new Error("Antigravity CLI native execution terminal could not be verified");
64456
+ else
64457
+ nativeOutcome = "unknown";
64355
64458
  } finally {
64356
64459
  this.executionRead = undefined;
64357
64460
  }
64358
64461
  if (this.terminalOwner !== owner || this.requestedStopReason || this.processTerminal)
64359
64462
  return;
64463
+ if (this.hasPendingTools())
64464
+ this.unownedContent = true;
64465
+ this.observeOutsideWork();
64466
+ this.refreshActivity();
64360
64467
  this.finishing = false;
64361
64468
  const outcomes = [...this.promptOutcomes].sort(([a], [b]) => b - a);
64362
64469
  let latest = outcomes.find(([, outcome]) => outcome.error)?.[1] ?? outcomes[0]?.[1];
@@ -64389,7 +64496,7 @@ class AgyAcpLane {
64389
64496
  this.usage.reset();
64390
64497
  this.currentPromptRequestId = null;
64391
64498
  this.terminalOwner = null;
64392
- this.toolCalls.clear();
64499
+ this.contentOwner = undefined;
64393
64500
  this.promptOutcomes.clear();
64394
64501
  this.observedPrompts.clear();
64395
64502
  if (!latest) {
@@ -64401,7 +64508,7 @@ class AgyAcpLane {
64401
64508
  kind: "turn_end",
64402
64509
  sessionId: this.sessionId ?? undefined,
64403
64510
  turnOwner: terminalOwner,
64404
- outcome: latest?.stopReason === "cancelled" ? "interrupted" : latest?.stopReason === "end_turn" ? "success" : "failed",
64511
+ outcome: latest?.stopReason === "cancelled" ? "interrupted" : latest?.stopReason === "end_turn" ? nativeOutcome === "unknown" ? "unknown" : "success" : "failed",
64405
64512
  stopReason: latest?.stopReason,
64406
64513
  ...latest?.stopReason === "cancelled" ? { pendingContent: "discard" } : {}
64407
64514
  });
@@ -64633,24 +64740,38 @@ class AgyAcpLane {
64633
64740
  this.rememberConfig(configuration, true);
64634
64741
  return;
64635
64742
  }
64636
- if (!this.ready || this.currentPromptRequestId === null) {
64637
- this.diagnostic("warning", "Agy ACP emitted a session update without an active prompt");
64743
+ if (!this.ready || this.requestedStopReason || this.processTerminal)
64638
64744
  return;
64639
- }
64640
64745
  const update = record3(payload.update) ?? {};
64641
64746
  const updateType = update?.sessionUpdate;
64642
64747
  switch (updateType) {
64643
64748
  case "agent_message_chunk": {
64644
64749
  const content3 = record3(update.content);
64645
64750
  if (content3?.type === "text" && typeof content3.text === "string") {
64646
- this.events.emit("runtime_event", { kind: "assistant_message_delta", text: content3.text });
64751
+ if (!this.contentOwner || this.contentOwner !== this.terminalOwner) {
64752
+ this.unownedContent = true;
64753
+ this.observeOutsideWork();
64754
+ }
64755
+ this.events.emit("runtime_event", {
64756
+ kind: "assistant_message_delta",
64757
+ text: content3.text,
64758
+ ...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
64759
+ });
64647
64760
  }
64648
64761
  return;
64649
64762
  }
64650
64763
  case "agent_thought_chunk": {
64651
64764
  const content3 = record3(update.content);
64652
64765
  if (content3?.type === "text" && typeof content3.text === "string") {
64653
- this.events.emit("runtime_event", { kind: "assistant_reasoning_delta", text: content3.text });
64766
+ if (!this.contentOwner || this.contentOwner !== this.terminalOwner) {
64767
+ this.unownedContent = true;
64768
+ this.observeOutsideWork();
64769
+ }
64770
+ this.events.emit("runtime_event", {
64771
+ kind: "assistant_reasoning_delta",
64772
+ text: content3.text,
64773
+ ...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
64774
+ });
64654
64775
  }
64655
64776
  return;
64656
64777
  }
@@ -64674,56 +64795,67 @@ class AgyAcpLane {
64674
64795
  this.diagnostic("warning", "Agy ACP emitted a malformed tool_call update");
64675
64796
  return;
64676
64797
  }
64677
- if (!this.toolCalls.has(update.toolCallId)) {
64678
- const name = typeof update.name === "string" ? update.name : update.title;
64679
- this.toolCalls.set(update.toolCallId, name);
64798
+ if (this.completedTools.has(update.toolCallId))
64799
+ return;
64800
+ let tool = this.toolCalls.get(update.toolCallId);
64801
+ if (!tool) {
64802
+ tool = {
64803
+ name: typeof update.name === "string" ? update.name : update.title,
64804
+ owner: this.contentOwner
64805
+ };
64806
+ this.toolCalls.set(update.toolCallId, tool);
64680
64807
  this.events.emit("runtime_event", {
64681
64808
  kind: "tool_call",
64682
64809
  callId: update.toolCallId,
64683
- name,
64684
- input: update.rawInput
64685
- });
64686
- }
64687
- if ((update.status === "completed" || update.status === "failed") && this.toolCalls.get(update.toolCallId) !== null) {
64688
- const name = this.toolCalls.get(update.toolCallId) ?? update.title;
64689
- this.toolCalls.set(update.toolCallId, null);
64690
- this.events.emit("runtime_event", {
64691
- kind: "tool_output",
64692
- callId: update.toolCallId,
64693
- name,
64694
- outcome: update.status === "failed" ? "failed" : "success",
64695
- output: update.rawOutput
64810
+ name: tool.name,
64811
+ input: update.rawInput,
64812
+ ...tool.owner && tool.owner === this.terminalOwner ? {} : { attribution: { scope: "session" } }
64696
64813
  });
64697
64814
  }
64815
+ this.observeOutsideWork();
64816
+ if (update.status === "completed" || update.status === "failed")
64817
+ this.finishTool(update, tool);
64698
64818
  return;
64699
64819
  }
64700
64820
  case "tool_call_update": {
64701
- if (typeof update.toolCallId === "string" && (update.status === "completed" || update.status === "failed")) {
64702
- const name = this.toolCalls.get(update.toolCallId);
64703
- if (name === undefined || name === null)
64704
- return;
64705
- this.toolCalls.set(update.toolCallId, null);
64706
- this.events.emit("runtime_event", {
64707
- kind: "tool_output",
64708
- callId: update.toolCallId,
64709
- outcome: update.status === "failed" ? "failed" : "success",
64710
- output: update.rawOutput,
64711
- name
64712
- });
64713
- }
64821
+ if (typeof update.toolCallId !== "string")
64822
+ return;
64823
+ const tool = this.toolCalls.get(update.toolCallId);
64824
+ if (!tool)
64825
+ return;
64826
+ if (update.status === "completed" || update.status === "failed")
64827
+ this.finishTool(update, tool);
64714
64828
  return;
64715
64829
  }
64716
64830
  case "plan":
64717
64831
  this.events.emit("runtime_event", {
64718
64832
  kind: "internal_progress",
64719
64833
  source: "agy.acp",
64720
- itemType: "plan"
64834
+ itemType: "plan",
64835
+ ...!this.contentOwner || this.contentOwner !== this.terminalOwner ? { attribution: { scope: "session" } } : {}
64721
64836
  });
64722
64837
  return;
64723
64838
  default:
64724
64839
  this.diagnostic("warning", `Unsupported Agy ACP session update: ${safeLabel(updateType)}`);
64725
64840
  }
64726
64841
  }
64842
+ finishTool(update, tool) {
64843
+ this.toolCalls.delete(update.toolCallId);
64844
+ this.completedTools.add(update.toolCallId);
64845
+ if (this.completedTools.size > 4096)
64846
+ this.completedTools.delete(this.completedTools.values().next().value);
64847
+ if (!tool.owner || tool.owner !== this.terminalOwner)
64848
+ this.unownedContent = true;
64849
+ this.observeOutsideWork();
64850
+ this.events.emit("runtime_event", {
64851
+ kind: "tool_output",
64852
+ callId: update.toolCallId,
64853
+ name: tool.name,
64854
+ outcome: update.status === "failed" ? "failed" : "success",
64855
+ output: update.rawOutput ?? update.content,
64856
+ ...tool.owner && tool.owner === this.terminalOwner ? {} : { attribution: { scope: "session" } }
64857
+ });
64858
+ }
64727
64859
  diagnostic(severity, message) {
64728
64860
  this.events.emit("runtime_event", {
64729
64861
  kind: "runtime_diagnostic",
@@ -64732,6 +64864,58 @@ class AgyAcpLane {
64732
64864
  message
64733
64865
  });
64734
64866
  }
64867
+ hasPendingTools() {
64868
+ return this.toolCalls.size > 0;
64869
+ }
64870
+ publishActivity() {
64871
+ if (!this.ready || this.requestedStopReason || this.processTerminal)
64872
+ return;
64873
+ const status = this.hasPendingTools() ? "running" : this.nativeActivity;
64874
+ if (status === this.publishedActivity)
64875
+ return;
64876
+ this.publishedActivity = status;
64877
+ this.events.emit("runtime_event", { kind: "session_activity", observation: { status, source: "agy.native" } });
64878
+ }
64879
+ observeOutsideWork() {
64880
+ this.activityRevision += 1;
64881
+ this.nativeActivity = "unknown";
64882
+ this.publishActivity();
64883
+ }
64884
+ refreshActivity() {
64885
+ if (this.activityRead)
64886
+ return this.activityRead;
64887
+ if (!this.ready || !this.activityReader || this.requestedStopReason || this.processTerminal)
64888
+ return Promise.resolve();
64889
+ const revision = this.activityRevision;
64890
+ const reading = (async () => {
64891
+ let status = "unknown";
64892
+ try {
64893
+ status = await this.activityReader.activity();
64894
+ } catch {}
64895
+ if (!this.ready || this.requestedStopReason || this.processTerminal)
64896
+ return;
64897
+ if (revision === this.activityRevision)
64898
+ this.nativeActivity = status;
64899
+ if (status === "running" && this.currentPromptRequestId === null)
64900
+ this.unownedContent = true;
64901
+ this.publishActivity();
64902
+ })();
64903
+ this.activityRead = reading;
64904
+ reading.finally(() => {
64905
+ if (this.activityRead === reading)
64906
+ this.activityRead = undefined;
64907
+ });
64908
+ return reading;
64909
+ }
64910
+ scheduleActivity() {
64911
+ if (!this.ready || this.requestedStopReason || this.processTerminal)
64912
+ return;
64913
+ this.activityTimer = setTimeout(() => {
64914
+ this.activityTimer = undefined;
64915
+ this.refreshActivity().then(() => this.scheduleActivity());
64916
+ }, this.options.activityPollMs ?? 1000);
64917
+ this.activityTimer.unref?.();
64918
+ }
64735
64919
  protocolFailure(message) {
64736
64920
  const error62 = new Error(message);
64737
64921
  this.rejectAllPending(error62);
@@ -67023,7 +67207,7 @@ async function collectJsonlFileCandidates(root3, options = {}) {
67023
67207
  const candidates3 = [];
67024
67208
  const readDirectory = options.readDirectory ?? ((directory) => readdir(directory, { withFileTypes: true }));
67025
67209
  const statPath = options.statPath ?? stat;
67026
- const visit4 = async (directory, remainingDepth, includeFiles) => {
67210
+ const visit3 = async (directory, remainingDepth, includeFiles) => {
67027
67211
  let entries;
67028
67212
  try {
67029
67213
  entries = await readDirectory(directory);
@@ -67035,7 +67219,7 @@ async function collectJsonlFileCandidates(root3, options = {}) {
67035
67219
  await Promise.all(entries.map(async (entry) => {
67036
67220
  const entryPath = path9.join(directory, entry.name);
67037
67221
  if (entry.isDirectory() && remainingDepth > 0) {
67038
- await visit4(entryPath, remainingDepth - 1, true);
67222
+ await visit3(entryPath, remainingDepth - 1, true);
67039
67223
  } else if (includeFiles && entry.isFile() && entry.name.endsWith(".jsonl")) {
67040
67224
  try {
67041
67225
  const metadata = await statPath(entryPath);
@@ -67048,7 +67232,7 @@ async function collectJsonlFileCandidates(root3, options = {}) {
67048
67232
  }
67049
67233
  }));
67050
67234
  };
67051
- await visit4(root3, options.maxDepth ?? Number.POSITIVE_INFINITY, options.includeRootFiles ?? true);
67235
+ await visit3(root3, options.maxDepth ?? Number.POSITIVE_INFINITY, options.includeRootFiles ?? true);
67052
67236
  return candidates3;
67053
67237
  }
67054
67238
  function retainNewest(values2, key, value, topK) {
@@ -74734,6 +74918,10 @@ class LogicalAgentSession {
74734
74918
  events;
74735
74919
  closed;
74736
74920
  state = "new";
74921
+ activity;
74922
+ sessionMessage = emptySemanticAssembler();
74923
+ sessionReasoning = emptySemanticAssembler();
74924
+ sessionContentTimer;
74737
74925
  backendSessionId;
74738
74926
  acquisition;
74739
74927
  configuration;
@@ -74934,11 +75122,12 @@ class LogicalAgentSession {
74934
75122
  }
74935
75123
  snapshot() {
74936
75124
  return {
75125
+ ...this.activity ? { activity: this.activity } : {},
74937
75126
  ...this.acquisition ? { acquisition: this.acquisition } : {},
74938
75127
  ...this.configuration ? { configuration: this.configuration } : {},
74939
75128
  ...this.observedModel ? { observedModel: { ...this.observedModel } } : {},
74940
75129
  sessionInstanceId: this.sessionInstanceId,
74941
- state: this.state,
75130
+ state: this.state === "idle" && this.activity && this.activity.status === "running" ? "working" : this.state,
74942
75131
  backendSessionId: this.backendSessionId,
74943
75132
  activeTurn: this.activeTurn ? { turnId: this.activeTurn.turnId, commandIds: this.activeTurn.commandIds } : undefined,
74944
75133
  queuedCommands: this.queued.map(({ message }) => ({
@@ -75264,6 +75453,13 @@ class LogicalAgentSession {
75264
75453
  return;
75265
75454
  if (this.isClosedPerTurnLaneTail(physicalOwner, generation))
75266
75455
  return;
75456
+ if (event.kind === "session_activity") {
75457
+ if (event.observation.status === "idle")
75458
+ this.flushSessionContent();
75459
+ this.activity = event.observation;
75460
+ this.emit({ type: "session_activity", observation: event.observation });
75461
+ return;
75462
+ }
75267
75463
  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;
75268
75464
  if (observation)
75269
75465
  this.emit({
@@ -75274,7 +75470,19 @@ class LogicalAgentSession {
75274
75470
  });
75275
75471
  if (event.kind === "model_observed")
75276
75472
  return;
75277
- if (event.attribution?.scope === "child" || event.attribution?.scope === "unknown") {
75473
+ if (event.attribution?.scope === "session" && (event.kind === "assistant_message_delta" || event.kind === "assistant_reasoning_delta")) {
75474
+ appendSemanticFragment(event.kind === "assistant_message_delta" ? this.sessionMessage : this.sessionReasoning, event.text);
75475
+ if (event.text && !this.sessionContentTimer) {
75476
+ this.sessionContentTimer = setTimeout(() => {
75477
+ this.sessionContentTimer = undefined;
75478
+ if (this.state !== "closed" && this.state !== "stopping")
75479
+ this.flushSessionContent();
75480
+ }, 500);
75481
+ this.sessionContentTimer.unref?.();
75482
+ }
75483
+ return;
75484
+ }
75485
+ if (event.attribution?.scope === "child" || event.attribution?.scope === "unknown" || event.attribution?.scope === "session") {
75278
75486
  this.emit({
75279
75487
  type: "activity",
75280
75488
  attribution: event.attribution,
@@ -75282,6 +75490,7 @@ class LogicalAgentSession {
75282
75490
  ..."text" in event ? { text: boundedSemanticCompletion(event.text).text } : {},
75283
75491
  ..."callId" in event ? { callId: event.callId } : {},
75284
75492
  ..."name" in event ? { name: event.name } : {},
75493
+ ..."input" in event ? { input: jsonValue(event.input) } : {},
75285
75494
  ..."outcome" in event ? { outcome: event.outcome } : {},
75286
75495
  ..."output" in event ? { output: jsonValue(event.output) } : {}
75287
75496
  });
@@ -75492,10 +75701,23 @@ class LogicalAgentSession {
75492
75701
  this.emit({ type: "assistant_message_completed", turnId, ...message });
75493
75702
  }
75494
75703
  }
75704
+ this.flushSessionContent();
75495
75705
  this.completeTurn(event.sessionId, physicalOwner, generation, event.turnOwner);
75496
75706
  return;
75497
75707
  }
75498
75708
  }
75709
+ flushSessionContent() {
75710
+ if (this.sessionContentTimer)
75711
+ clearTimeout(this.sessionContentTimer);
75712
+ this.sessionContentTimer = undefined;
75713
+ for (const [kind, buffer] of [["assistant_reasoning_completed", this.sessionReasoning], ["assistant_message_completed", this.sessionMessage]]) {
75714
+ const completion = finishSemanticAssembler(buffer);
75715
+ if (completion.text)
75716
+ this.emit({ type: "activity", attribution: { scope: "session" }, kind, ...completion });
75717
+ }
75718
+ this.sessionMessage = emptySemanticAssembler();
75719
+ this.sessionReasoning = emptySemanticAssembler();
75720
+ }
75499
75721
  isClosedPerTurnLaneTail(physicalOwner, generation) {
75500
75722
  if (this.adapter.execution.lifetime !== "turn" || this.activeTurn)
75501
75723
  return false;
@@ -76023,6 +76245,7 @@ class LogicalAgentSession {
76023
76245
  const cleanup = hostCleanup.status === "failed" || hostCleanup.status === "timed_out" ? hostCleanup : this.laneCleanupFailure ?? hostCleanup;
76024
76246
  const result2 = buildResult(cleanup);
76025
76247
  this.terminalResult = result2;
76248
+ this.flushSessionContent();
76026
76249
  this.state = "closed";
76027
76250
  this.emit({ type: "session_closed", result: result2 });
76028
76251
  this.eventQueue.close();
@@ -80773,212 +80996,233 @@ async function startCredentialProxy(broker, options = {}) {
80773
80996
  return;
80774
80997
  }
80775
80998
  };
80776
- const server = http.createServer(async (req, res) => {
80777
- const requestUrl = new URL2(req.url ?? "/", "http://placeholder");
80778
- const pathname = requestUrl.pathname;
80779
- if (pathname === LOCAL_MEMORY_COMMIT_PATH) {
80780
- if (req.method !== "POST" || req.url !== LOCAL_MEMORY_COMMIT_PATH) {
80781
- writeJson(res, 405, { error: "method not allowed" });
80782
- req.resume();
80999
+ const server = http.createServer((req, res) => {
81000
+ (async () => {
81001
+ const requestUrl = new URL2(req.url ?? "/", "http://placeholder");
81002
+ const pathname = requestUrl.pathname;
81003
+ if (pathname === LOCAL_MEMORY_COMMIT_PATH) {
81004
+ if (req.method !== "POST" || req.url !== LOCAL_MEMORY_COMMIT_PATH) {
81005
+ writeJson(res, 405, { error: "method not allowed" });
81006
+ req.resume();
81007
+ return;
81008
+ }
81009
+ const verdict2 = broker.check(req.headers["authorization"], "send");
81010
+ if (!verdict2.ok) {
81011
+ writeJson(res, verdict2.status, { error: verdict2.error, code: verdict2.code });
81012
+ req.resume();
81013
+ return;
81014
+ }
81015
+ await handleLocalMemoryCommit(req, res, verdict2.reg, options.onMemoryCommit, options.onMemoryCommitResetError);
80783
81016
  return;
80784
81017
  }
80785
- const verdict2 = broker.check(req.headers["authorization"], "send");
80786
- if (!verdict2.ok) {
80787
- writeJson(res, verdict2.status, { error: verdict2.error, code: verdict2.code });
80788
- req.resume();
81018
+ if (pathname === LOCAL_PII_PATH && (req.method === "GET" || req.method === "POST")) {
81019
+ const localVerdict = broker.check(req.headers["authorization"], req.method === "GET" ? "read" : "send");
81020
+ if (!localVerdict.ok) {
81021
+ writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
81022
+ req.resume();
81023
+ return;
81024
+ }
81025
+ await handleLocalPii(req, res, localVerdict.reg.agentId, options.pii);
80789
81026
  return;
80790
81027
  }
80791
- await handleLocalMemoryCommit(req, res, verdict2.reg, options.onMemoryCommit, options.onMemoryCommitResetError);
80792
- return;
80793
- }
80794
- if (pathname === LOCAL_PII_PATH && (req.method === "GET" || req.method === "POST")) {
80795
- const localVerdict = broker.check(req.headers["authorization"], req.method === "GET" ? "read" : "send");
80796
- if (!localVerdict.ok) {
80797
- writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
80798
- req.resume();
81028
+ if (pathname.startsWith("/__alook/local/")) {
81029
+ if (req.url !== LOCAL_MESSAGE_REMINDER_PATH) {
81030
+ writeJson(res, 404, { error: "unknown local route", code: "not_found" });
81031
+ req.resume();
81032
+ return;
81033
+ }
81034
+ if (req.method !== "PUT") {
81035
+ writeJson(res, 405, { error: "method not allowed", code: "method_not_allowed" });
81036
+ req.resume();
81037
+ return;
81038
+ }
81039
+ const localVerdict = broker.check(req.headers["authorization"], "send");
81040
+ if (!localVerdict.ok) {
81041
+ writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
81042
+ req.resume();
81043
+ return;
81044
+ }
81045
+ handleLocalMessageReminder(req, res, localVerdict.reg.agentId, options.onMessageReminderArm);
80799
81046
  return;
80800
81047
  }
80801
- await handleLocalPii(req, res, localVerdict.reg.agentId, options.pii);
80802
- return;
80803
- }
80804
- if (pathname.startsWith("/__alook/local/")) {
80805
- if (req.url !== LOCAL_MESSAGE_REMINDER_PATH) {
80806
- writeJson(res, 404, { error: "unknown local route", code: "not_found" });
81048
+ const route = resolveProxyRoute(pathname, req.method ?? "GET", req.url ?? pathname);
81049
+ const requiredCap = resolveCap ? resolveCap(req.method ?? "GET", pathname) : route.capability;
81050
+ const verdict = broker.check(req.headers["authorization"], requiredCap);
81051
+ if (!verdict.ok) {
81052
+ res.writeHead(verdict.status, { "content-type": "application/json" });
81053
+ res.end(JSON.stringify({ error: verdict.error, code: verdict.code }));
80807
81054
  req.resume();
80808
81055
  return;
80809
81056
  }
80810
- if (req.method !== "PUT") {
80811
- writeJson(res, 405, { error: "method not allowed", code: "method_not_allowed" });
80812
- req.resume();
81057
+ 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))) {
81058
+ writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
80813
81059
  return;
80814
81060
  }
80815
- const localVerdict = broker.check(req.headers["authorization"], "send");
80816
- if (!localVerdict.ok) {
80817
- writeJson(res, localVerdict.status, { error: localVerdict.error, code: localVerdict.code });
81061
+ const canonicalCommunityDoor = pathname === "/api/community/platform/feedback" || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
81062
+ if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
81063
+ res.writeHead(404, { "content-type": "application/json" });
81064
+ res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
80818
81065
  req.resume();
80819
81066
  return;
80820
81067
  }
80821
- handleLocalMessageReminder(req, res, localVerdict.reg.agentId, options.onMessageReminderArm);
80822
- return;
80823
- }
80824
- const route = resolveProxyRoute(pathname, req.method ?? "GET", req.url ?? pathname);
80825
- const requiredCap = resolveCap ? resolveCap(req.method ?? "GET", pathname) : route.capability;
80826
- const verdict = broker.check(req.headers["authorization"], requiredCap);
80827
- if (!verdict.ok) {
80828
- res.writeHead(verdict.status, { "content-type": "application/json" });
80829
- res.end(JSON.stringify({ error: verdict.error, code: verdict.code }));
80830
- req.resume();
80831
- return;
80832
- }
80833
- 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))) {
80834
- writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
80835
- return;
80836
- }
80837
- const canonicalCommunityDoor = pathname === "/api/community/platform/feedback" || /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
80838
- if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
80839
- res.writeHead(404, { "content-type": "application/json" });
80840
- res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
80841
- req.resume();
80842
- return;
80843
- }
80844
- if (/^\/api\/community\/bots\/me\/nap(?:\/|$)/.test(pathname)) {
80845
- writeJson(res, 410, { error: "nap was removed; use local commit to record a memory review", code: "command_removed" });
80846
- req.resume();
80847
- return;
80848
- }
80849
- const reg = verdict.reg;
80850
- if (/^\/api\/community\/bots\/[^/]+\/pii\/?$/.test(pathname)) {
80851
- writeJson(res, 403, { error: "PII management requires a human owner session", code: "forbidden" });
80852
- req.resume();
80853
- return;
80854
- }
80855
- let filteredBody;
80856
- let piiTriggeredFilters = [];
80857
- if (options.pii && route.filterPiiSend) {
80858
- try {
80859
- const filtered = await filterPiiRequest(req, reg.agentId, options.pii);
80860
- filteredBody = filtered.body;
80861
- piiTriggeredFilters = filtered.triggeredFilters;
80862
- } catch (error62) {
80863
- writePiiError(res, error62);
81068
+ if (/^\/api\/community\/bots\/me\/nap(?:\/|$)/.test(pathname)) {
81069
+ writeJson(res, 410, { error: "nap was removed; use local commit to record a memory review", code: "command_removed" });
81070
+ req.resume();
80864
81071
  return;
80865
81072
  }
80866
- if (res.destroyed)
81073
+ const reg = verdict.reg;
81074
+ if (/^\/api\/community\/bots\/[^/]+\/pii\/?$/.test(pathname)) {
81075
+ writeJson(res, 403, { error: "PII management requires a human owner session", code: "forbidden" });
81076
+ req.resume();
80867
81077
  return;
80868
- }
80869
- const isInboxPull = route.inboxObservation === "pull";
80870
- const isInboxAck = route.inboxObservation === "ack";
80871
- const shouldObserveInboxPull = Boolean(isInboxPull && onPull);
80872
- const shouldObserveInboxAck = Boolean(isInboxAck && onAck);
80873
- let inboxPullObservationToken;
80874
- let inboxAckObservationToken;
80875
- if (shouldObserveInboxPull) {
80876
- try {
80877
- inboxPullObservationToken = options.onInboxPullStart?.(reg.agentId);
80878
- } catch {
80879
- reportInboxPullObservationError({
80880
- agentId: reg.agentId,
80881
- reason: "observer_failed",
80882
- contentEncoding: "identity"
80883
- });
80884
81078
  }
80885
- }
80886
- if (shouldObserveInboxAck) {
80887
- try {
80888
- inboxAckObservationToken = options.onInboxAckStart?.(reg.agentId);
80889
- } catch {
80890
- reportInboxAckObservationError({
80891
- agentId: reg.agentId,
80892
- reason: "observer_failed",
80893
- contentEncoding: "identity"
80894
- });
81079
+ let filteredBody;
81080
+ let piiTriggeredFilters = [];
81081
+ if (options.pii && route.filterPiiSend) {
81082
+ try {
81083
+ const filtered = await filterPiiRequest(req, reg.agentId, options.pii);
81084
+ filteredBody = filtered.body;
81085
+ piiTriggeredFilters = filtered.triggeredFilters;
81086
+ } catch (error62) {
81087
+ writePiiError(res, error62);
81088
+ return;
81089
+ }
81090
+ if (res.destroyed)
81091
+ return;
80895
81092
  }
80896
- }
80897
- if (onProxyRequest) {
80898
- try {
80899
- const method = req.method ?? "GET";
80900
- onProxyRequest(reg.agentId, method, pathname, route.propertyMetadata, route.auditOperation);
80901
- } catch {}
80902
- }
80903
- const outHeaders = { ...req.headers };
80904
- delete outHeaders["authorization"];
80905
- delete outHeaders["host"];
80906
- outHeaders["authorization"] = `Bearer ${reg.runnerKey}`;
80907
- outHeaders[broker.headerNames.agentId.toLowerCase()] = reg.agentId;
80908
- outHeaders[broker.headerNames.client.toLowerCase()] = broker.clientLabel;
80909
- outHeaders[broker.headerNames.capabilities.toLowerCase()] = [...reg.capabilities].join(",");
80910
- if (isInboxPull || isInboxAck)
80911
- outHeaders["accept-encoding"] = "identity";
80912
- if (filteredBody) {
80913
- delete outHeaders["transfer-encoding"];
80914
- outHeaders["content-length"] = filteredBody.byteLength;
80915
- }
80916
- let responded = false;
80917
- if (piiTriggeredFilters.length)
80918
- outHeaders["accept-encoding"] = "identity";
80919
- let upstreamRes;
80920
- const upstreamReq = upstreamClient.request({
80921
- protocol: upstream.protocol,
80922
- hostname: upstream.hostname,
80923
- port: upstream.port || (upstream.protocol === "https:" ? 443 : 80),
80924
- method: req.method,
80925
- path: joinPath(upstream.pathname, req.url ?? "/"),
80926
- headers: outHeaders
80927
- }, (res_) => {
80928
- responded = true;
80929
- upstreamRes = res_;
80930
- const destroyResIfIncomplete = () => {
80931
- if (!res_.complete)
80932
- res.destroy();
80933
- };
80934
- res_.on("error", destroyResIfIncomplete);
80935
- res_.on("close", destroyResIfIncomplete);
80936
- if ((shouldObserveInboxPull || shouldObserveInboxAck) && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300) {
80937
- const chunks = [];
80938
- res_.on("data", (chunk2) => chunks.push(chunk2));
80939
- res_.on("end", () => {
80940
- const body = Buffer.concat(chunks);
80941
- const contentEncoding = normalizeContentEncoding(res_.headers["content-encoding"]);
80942
- if (contentEncoding !== "identity") {
80943
- if (shouldObserveInboxPull) {
80944
- reportInboxPullObservationError({
80945
- agentId: reg.agentId,
80946
- reason: "unexpected_content_encoding",
80947
- contentEncoding
80948
- });
80949
- } else {
80950
- reportInboxAckObservationError({
80951
- agentId: reg.agentId,
80952
- reason: "unexpected_content_encoding",
80953
- contentEncoding
80954
- });
80955
- }
80956
- } else {
80957
- let parsed;
80958
- try {
80959
- parsed = JSON.parse(body.toString("utf8"));
80960
- } catch {
81093
+ const isInboxPull = route.inboxObservation === "pull";
81094
+ const isInboxAck = route.inboxObservation === "ack";
81095
+ const shouldObserveInboxPull = Boolean(isInboxPull && onPull);
81096
+ const shouldObserveInboxAck = Boolean(isInboxAck && onAck);
81097
+ let inboxPullObservationToken;
81098
+ let inboxAckObservationToken;
81099
+ if (shouldObserveInboxPull) {
81100
+ try {
81101
+ inboxPullObservationToken = options.onInboxPullStart?.(reg.agentId);
81102
+ } catch {
81103
+ reportInboxPullObservationError({
81104
+ agentId: reg.agentId,
81105
+ reason: "observer_failed",
81106
+ contentEncoding: "identity"
81107
+ });
81108
+ }
81109
+ }
81110
+ if (shouldObserveInboxAck) {
81111
+ try {
81112
+ inboxAckObservationToken = options.onInboxAckStart?.(reg.agentId);
81113
+ } catch {
81114
+ reportInboxAckObservationError({
81115
+ agentId: reg.agentId,
81116
+ reason: "observer_failed",
81117
+ contentEncoding: "identity"
81118
+ });
81119
+ }
81120
+ }
81121
+ if (onProxyRequest) {
81122
+ try {
81123
+ const method = req.method ?? "GET";
81124
+ onProxyRequest(reg.agentId, method, pathname, route.propertyMetadata, route.auditOperation);
81125
+ } catch {}
81126
+ }
81127
+ const outHeaders = { ...req.headers };
81128
+ delete outHeaders["authorization"];
81129
+ delete outHeaders["host"];
81130
+ outHeaders["authorization"] = `Bearer ${reg.runnerKey}`;
81131
+ outHeaders[broker.headerNames.agentId.toLowerCase()] = reg.agentId;
81132
+ outHeaders[broker.headerNames.client.toLowerCase()] = broker.clientLabel;
81133
+ outHeaders[broker.headerNames.capabilities.toLowerCase()] = [...reg.capabilities].join(",");
81134
+ if (isInboxPull || isInboxAck)
81135
+ outHeaders["accept-encoding"] = "identity";
81136
+ if (filteredBody) {
81137
+ delete outHeaders["transfer-encoding"];
81138
+ outHeaders["content-length"] = filteredBody.byteLength;
81139
+ }
81140
+ let responded = false;
81141
+ if (piiTriggeredFilters.length)
81142
+ outHeaders["accept-encoding"] = "identity";
81143
+ let upstreamRes;
81144
+ const upstreamReq = upstreamClient.request({
81145
+ protocol: upstream.protocol,
81146
+ hostname: upstream.hostname,
81147
+ port: upstream.port || (upstream.protocol === "https:" ? 443 : 80),
81148
+ method: req.method,
81149
+ path: joinPath(upstream.pathname, req.url ?? "/"),
81150
+ headers: outHeaders
81151
+ }, (res_) => {
81152
+ responded = true;
81153
+ upstreamRes = res_;
81154
+ const destroyResIfIncomplete = () => {
81155
+ if (!res_.complete)
81156
+ res.destroy();
81157
+ };
81158
+ res_.on("error", destroyResIfIncomplete);
81159
+ res_.on("close", destroyResIfIncomplete);
81160
+ if ((shouldObserveInboxPull || shouldObserveInboxAck) && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300) {
81161
+ const chunks = [];
81162
+ res_.on("data", (chunk2) => chunks.push(chunk2));
81163
+ res_.on("end", () => {
81164
+ const body = Buffer.concat(chunks);
81165
+ const contentEncoding = normalizeContentEncoding(res_.headers["content-encoding"]);
81166
+ if (contentEncoding !== "identity") {
80961
81167
  if (shouldObserveInboxPull) {
80962
- reportInboxPullObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
81168
+ reportInboxPullObservationError({
81169
+ agentId: reg.agentId,
81170
+ reason: "unexpected_content_encoding",
81171
+ contentEncoding
81172
+ });
80963
81173
  } else {
80964
- reportInboxAckObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
81174
+ reportInboxAckObservationError({
81175
+ agentId: reg.agentId,
81176
+ reason: "unexpected_content_encoding",
81177
+ contentEncoding
81178
+ });
80965
81179
  }
80966
- }
80967
- if (parsed !== undefined) {
80968
- if (shouldObserveInboxPull) {
80969
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.messages)) {
80970
- reportInboxPullObservationError({
81180
+ } else {
81181
+ let parsed;
81182
+ try {
81183
+ parsed = JSON.parse(body.toString("utf8"));
81184
+ } catch {
81185
+ if (shouldObserveInboxPull) {
81186
+ reportInboxPullObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
81187
+ } else {
81188
+ reportInboxAckObservationError({ agentId: reg.agentId, reason: "invalid_json", contentEncoding });
81189
+ }
81190
+ }
81191
+ if (parsed !== undefined) {
81192
+ if (shouldObserveInboxPull) {
81193
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !Array.isArray(parsed.messages)) {
81194
+ reportInboxPullObservationError({
81195
+ agentId: reg.agentId,
81196
+ reason: "invalid_inbox_shape",
81197
+ contentEncoding
81198
+ });
81199
+ } else {
81200
+ const messages = parsed.messages;
81201
+ if (messages.length > 0) {
81202
+ try {
81203
+ onPull(reg.agentId, messages, inboxPullObservationToken);
81204
+ } catch {
81205
+ reportInboxPullObservationError({
81206
+ agentId: reg.agentId,
81207
+ reason: "observer_failed",
81208
+ contentEncoding
81209
+ });
81210
+ }
81211
+ }
81212
+ }
81213
+ } 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)) {
81214
+ reportInboxAckObservationError({
80971
81215
  agentId: reg.agentId,
80972
- reason: "invalid_inbox_shape",
81216
+ reason: "invalid_ack_shape",
80973
81217
  contentEncoding
80974
81218
  });
80975
81219
  } else {
80976
- const messages = parsed.messages;
80977
- if (messages.length > 0) {
81220
+ const applied = parsed.applied;
81221
+ if (applied.length > 0) {
80978
81222
  try {
80979
- onPull(reg.agentId, messages, inboxPullObservationToken);
81223
+ onAck(reg.agentId, applied, inboxAckObservationToken);
80980
81224
  } catch {
80981
- reportInboxPullObservationError({
81225
+ reportInboxAckObservationError({
80982
81226
  agentId: reg.agentId,
80983
81227
  reason: "observer_failed",
80984
81228
  contentEncoding
@@ -80986,66 +81230,47 @@ async function startCredentialProxy(broker, options = {}) {
80986
81230
  }
80987
81231
  }
80988
81232
  }
80989
- } 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)) {
80990
- reportInboxAckObservationError({
80991
- agentId: reg.agentId,
80992
- reason: "invalid_ack_shape",
80993
- contentEncoding
80994
- });
80995
- } else {
80996
- const applied = parsed.applied;
80997
- if (applied.length > 0) {
80998
- try {
80999
- onAck(reg.agentId, applied, inboxAckObservationToken);
81000
- } catch {
81001
- reportInboxAckObservationError({
81002
- agentId: reg.agentId,
81003
- reason: "observer_failed",
81004
- contentEncoding
81005
- });
81006
- }
81007
- }
81008
81233
  }
81009
81234
  }
81010
- }
81011
- res.writeHead(res_.statusCode, res_.headers);
81012
- res.end(body);
81013
- });
81014
- } else if (piiTriggeredFilters.length && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300 && normalizeContentEncoding(res_.headers["content-encoding"]) === "identity") {
81015
- forwardPiiSendResponse(res_, res, piiTriggeredFilters);
81016
- } else {
81017
- res.writeHead(res_.statusCode ?? 502, res_.headers);
81018
- res_.pipe(res);
81019
- }
81020
- });
81021
- upstreamReq.on("error", (err) => {
81022
- if (responded)
81023
- return;
81024
- responded = true;
81025
- res.writeHead(502, { "content-type": "application/json" });
81026
- res.end(JSON.stringify({ error: `upstream error: ${err.message}`, code: "upstream_error" }));
81027
- });
81028
- const waitingForModels = route.modelDiscovery && requestUrl.searchParams.get("wait") === "1";
81029
- const upstreamTimeoutMs = options.upstreamTimeoutMs ?? (waitingForModels ? 55000 : DEFAULT_UPSTREAM_TIMEOUT_MS);
81030
- upstreamReq.setTimeout(upstreamTimeoutMs, () => {
81031
- upstreamReq.destroy();
81032
- upstreamRes?.destroy();
81033
- if (responded) {
81034
- res.destroy();
81035
- return;
81036
- }
81037
- responded = true;
81038
- res.writeHead(504, { "content-type": "application/json" });
81039
- res.end(JSON.stringify({ error: `upstream request timed out after ${upstreamTimeoutMs}ms`, code: "upstream_timeout" }));
81040
- });
81041
- res.on("close", () => {
81042
- upstreamReq.destroy();
81043
- upstreamRes?.destroy();
81044
- });
81045
- if (filteredBody)
81046
- upstreamReq.end(filteredBody);
81047
- else
81048
- req.pipe(upstreamReq);
81235
+ res.writeHead(res_.statusCode, res_.headers);
81236
+ res.end(body);
81237
+ });
81238
+ } else if (piiTriggeredFilters.length && res_.statusCode !== undefined && res_.statusCode >= 200 && res_.statusCode < 300 && normalizeContentEncoding(res_.headers["content-encoding"]) === "identity") {
81239
+ forwardPiiSendResponse(res_, res, piiTriggeredFilters);
81240
+ } else {
81241
+ res.writeHead(res_.statusCode ?? 502, res_.headers);
81242
+ res_.pipe(res);
81243
+ }
81244
+ });
81245
+ upstreamReq.on("error", (err) => {
81246
+ if (responded)
81247
+ return;
81248
+ responded = true;
81249
+ res.writeHead(502, { "content-type": "application/json" });
81250
+ res.end(JSON.stringify({ error: `upstream error: ${err.message}`, code: "upstream_error" }));
81251
+ });
81252
+ const waitingForModels = route.modelDiscovery && requestUrl.searchParams.get("wait") === "1";
81253
+ const upstreamTimeoutMs = options.upstreamTimeoutMs ?? (waitingForModels ? 55000 : DEFAULT_UPSTREAM_TIMEOUT_MS);
81254
+ upstreamReq.setTimeout(upstreamTimeoutMs, () => {
81255
+ upstreamReq.destroy();
81256
+ upstreamRes?.destroy();
81257
+ if (responded) {
81258
+ res.destroy();
81259
+ return;
81260
+ }
81261
+ responded = true;
81262
+ res.writeHead(504, { "content-type": "application/json" });
81263
+ res.end(JSON.stringify({ error: `upstream request timed out after ${upstreamTimeoutMs}ms`, code: "upstream_timeout" }));
81264
+ });
81265
+ res.on("close", () => {
81266
+ upstreamReq.destroy();
81267
+ upstreamRes?.destroy();
81268
+ });
81269
+ if (filteredBody)
81270
+ upstreamReq.end(filteredBody);
81271
+ else
81272
+ req.pipe(upstreamReq);
81273
+ })();
81049
81274
  });
81050
81275
  await new Promise((resolve7, reject) => {
81051
81276
  server.once("error", reject);
@@ -81072,7 +81297,10 @@ function joinPath(basePath, reqUrl) {
81072
81297
  }
81073
81298
  // src/manager/managerPolicy.ts
81074
81299
  function isActivelyWorking(agent) {
81075
- return agent.status === "running" && (leaseIsWorking(agent.execution.lease) || agent.pendingAdmissions.length > 0 || agent.inbox.length > 0);
81300
+ return agent.status === "running" && (agent.sessionActivity?.status === "running" || leaseIsWorking(agent.execution.lease) || agent.pendingAdmissions.length > 0 || agent.inbox.length > 0);
81301
+ }
81302
+ function sessionBlocksIdleCleanup(agent) {
81303
+ return agent.sessionActivity !== undefined && agent.sessionActivity.status !== "idle";
81076
81304
  }
81077
81305
  var DEFAULT_STALE_THRESHOLD_MS = 120000;
81078
81306
  var DEFAULT_TURN_SILENCE_POLICY = {
@@ -81098,6 +81326,19 @@ function createInitialManagerState(staleThresholdMs = DEFAULT_STALE_THRESHOLD_MS
81098
81326
  }
81099
81327
  function reduceManager(state, event) {
81100
81328
  switch (event.type) {
81329
+ case "session_activity": {
81330
+ const current = state.agents[event.agentId];
81331
+ if (!current || !matchesSession(current, event.sessionInstanceId) || current.status === "stopping")
81332
+ return { state, effects: [] };
81333
+ const agent = clone2(current);
81334
+ const changed = agent.sessionActivity?.status !== event.observation.status;
81335
+ agent.sessionActivity = event.observation;
81336
+ if (sessionBlocksIdleCleanup(agent))
81337
+ agent.idleSince = null;
81338
+ else if (changed && !leaseIsWorking(agent.execution.lease) && agent.pendingAdmissions.length === 0 && agent.inbox.length === 0)
81339
+ agent.idleSince = event.nowMs;
81340
+ return commit(state, agent, []);
81341
+ }
81101
81342
  case "register":
81102
81343
  return withAgent(state, event.agentId, (a) => a ?? freshAgent(event.agentId), []);
81103
81344
  case "wake":
@@ -81147,6 +81388,7 @@ function reduceManager(state, event) {
81147
81388
  {
81148
81389
  const a = agent;
81149
81390
  a.execution = { sessionInstanceId: event.sessionInstanceId, lease: { state: "none", lastTerminal: null } };
81391
+ a.sessionActivity = undefined;
81150
81392
  a.turnSilence = event.turnSilence ?? {
81151
81393
  ...DEFAULT_TURN_SILENCE_POLICY,
81152
81394
  nativeIdleTimeoutMs: state.staleThresholdMs,
@@ -81348,6 +81590,7 @@ function reduceManager(state, event) {
81348
81590
  const closing = agent.pendingAdmissions.filter((entry) => entry.sessionInstanceId === event.sessionInstanceId);
81349
81591
  agent.pendingAdmissions = agent.pendingAdmissions.filter((entry) => entry.sessionInstanceId !== event.sessionInstanceId);
81350
81592
  agent.execution = { sessionInstanceId: null, lease: { state: "detached" } };
81593
+ agent.sessionActivity = undefined;
81351
81594
  syncExecutionProjection(agent);
81352
81595
  return commit(state, agent, recoveryEffects(agent, closing));
81353
81596
  }
@@ -81476,7 +81719,7 @@ function onTurnCompleted(state, agentId, sessionInstanceId, nowMs, turnId, endRe
81476
81719
  ...messages.map((queued) => ({ type: "send", agentId, message: queued, mode: "idle" }))
81477
81720
  ]);
81478
81721
  }
81479
- agent.idleSince = agent.status === "running" && !agent.resetting ? nowMs : null;
81722
+ agent.idleSince = agent.status === "running" && !agent.resetting && !sessionBlocksIdleCleanup(agent) ? nowMs : null;
81480
81723
  return commit(state, agent, clearEffects);
81481
81724
  }
81482
81725
  function onTurnToolLifecycle(state, event, lifecycle) {
@@ -81626,13 +81869,13 @@ function onTick(state, nowMs) {
81626
81869
  effects.push({ type: "force_exit", agentId: id4, reason: "stopping_stuck" });
81627
81870
  continue;
81628
81871
  }
81629
- 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);
81872
+ 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);
81630
81873
  if (idleResetEligible && nowMs - a.idleSince >= state.idleResetTimeoutMs) {
81631
81874
  agents[id4] = { ...a, idleSince: nowMs };
81632
81875
  effects.push({ type: "maintain_idle_memory", agentId: id4, sessionId: a.sessionId });
81633
81876
  continue;
81634
81877
  }
81635
- 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);
81878
+ 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);
81636
81879
  if (idleEligible && a.idleSince !== null && nowMs - a.idleSince >= state.idleTimeoutMs) {
81637
81880
  agents[id4] = { ...a, status: "stopping", stoppingSince: nowMs };
81638
81881
  effects.push({ type: "stop", agentId: id4, reason: "idle_timeout" });
@@ -81666,6 +81909,8 @@ function freshAgent(agentId) {
81666
81909
  }
81667
81910
  function enterStable(agent, status) {
81668
81911
  agent.status = status;
81912
+ if (status === "idle")
81913
+ agent.sessionActivity = undefined;
81669
81914
  agent.resetting = false;
81670
81915
  agent.resettingSince = null;
81671
81916
  agent.stoppingSince = null;
@@ -81879,7 +82124,11 @@ function messagingSection() {
81879
82124
  "",
81880
82125
  "#### Ask for a decision",
81881
82126
  "",
81882
- `Alook users cannot see native question prompts. When you need someone to choose from options, use \`${CLI} message send --ask\` with JSON on stdin (max 8 KiB).`,
82127
+ `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.`,
82128
+ "",
82129
+ "When you ask a question and can offer options, use a decision card. " + "Use a normal Alook message for updates and questions without options.",
82130
+ "",
82131
+ "Pass JSON on stdin (max 8 KiB).",
81883
82132
  "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.",
81884
82133
  "",
81885
82134
  "```json",
@@ -83771,6 +84020,9 @@ ${this.opts.wakePromptFooter}` : text8;
83771
84020
  return;
83772
84021
  }
83773
84022
  const sessionSuperseded = owner.superseded;
84023
+ if (event.type === "session_activity" && !sessionSuperseded) {
84024
+ this.dispatch({ type: "session_activity", agentId, sessionInstanceId: event.sessionInstanceId, observation: event.observation, nowMs: this.now() }, owner);
84025
+ }
83774
84026
  const runtimeError = event.type === "session_failed" ? event.error : event.type === "turn_completed" && event.result.outcome === "failed" ? event.result.error : undefined;
83775
84027
  if (runtimeError !== undefined && !sessionSuperseded) {
83776
84028
  this.emitErrorAudit(agentId, "runtime", runtimeError.code, runtimeError.message);
@@ -83787,12 +84039,12 @@ ${this.opts.wakePromptFooter}` : text8;
83787
84039
  }
83788
84040
  }
83789
84041
  if (this.opts.onBotAuditEvent) {
83790
- if (event.type === "assistant_message_completed" && event.text.length > 0) {
84042
+ if ((event.type === "assistant_message_completed" || event.type === "activity" && event.kind === "assistant_message_completed") && event.text && event.text.length > 0) {
83791
84043
  const { text: text8, truncated, chars } = truncateAuditText(event.text);
83792
84044
  try {
83793
84045
  this.opts.onBotAuditEvent(agentId, {
83794
84046
  kind: "text",
83795
- payload: { text: text8, truncated: truncated || event.truncated, chars }
84047
+ payload: { text: text8, truncated: truncated || event.truncated === true, chars }
83796
84048
  }, {
83797
84049
  sessionId: this.liveSessions.get(agentId) ?? null,
83798
84050
  launchId: this.launchIds.get(agentId) ?? null
@@ -87668,6 +87920,7 @@ function projectDaemonLogRow(value, targetAgentId) {
87668
87920
  };
87669
87921
  }
87670
87922
  var CURRENT_MANAGER_EVENTS = {
87923
+ session_activity: "include",
87671
87924
  register: "include",
87672
87925
  wake: "include",
87673
87926
  spawned: "include",