@deepagents/context 0.37.0 → 0.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -11,8 +11,10 @@ export * from './lib/fragments/domain.ts';
11
11
  export * from './lib/fragments/message/user.ts';
12
12
  export * from './lib/fragments/reasoning.ts';
13
13
  export * from './lib/fragments/reminders/classifier.ts';
14
+ export * from './lib/fragments/reminders/combinators.ts';
14
15
  export * from './lib/fragments/reminders/content-predicates.ts';
15
- export * from './lib/fragments/reminders/temporal-reminder.ts';
16
+ export * from './lib/fragments/reminders/temporal/index.ts';
17
+ export * from './lib/fragments/reminders/turn-predicates.ts';
16
18
  export * from './lib/fragments/socratic.ts';
17
19
  export * from './lib/fragments/user.ts';
18
20
  export * from './lib/guardrail.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,iDAAiD,CAAC;AAChE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sCAAsC,CAAC;AACrD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,iDAAiD,CAAC;AAChE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,sCAAsC,CAAC;AACrD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1118,118 +1118,9 @@ function extractPlainText(message2) {
1118
1118
  }
1119
1119
 
1120
1120
  // packages/context/src/lib/fragments/message/user.ts
1121
- function everyNTurns(n) {
1122
- return ({ turn }) => turn % n === 0;
1123
- }
1124
- function once() {
1125
- return ({ turn }) => turn === 1;
1126
- }
1127
- function firstN(n) {
1128
- return ({ turn }) => turn <= n;
1129
- }
1130
- function afterTurn(n) {
1131
- return ({ turn }) => turn > n;
1132
- }
1133
- function and(...predicates) {
1134
- return async (ctx) => {
1135
- for (const it of predicates) {
1136
- if (!await it(ctx)) return false;
1137
- }
1138
- return true;
1139
- };
1140
- }
1141
- function or(...predicates) {
1142
- return async (ctx) => {
1143
- for (const it of predicates) {
1144
- if (await it(ctx)) return true;
1145
- }
1146
- return false;
1147
- };
1148
- }
1149
- function not(predicate) {
1150
- return async (ctx) => !await predicate(ctx);
1151
- }
1152
- function contentIncludes(keywords) {
1153
- const lower = keywords.map((k) => k.toLowerCase());
1154
- return (ctx) => {
1155
- const text = ctx.content.toLowerCase();
1156
- return lower.some((kw) => text.includes(kw));
1157
- };
1158
- }
1159
- function contentPattern(pattern) {
1160
- return (ctx) => {
1161
- pattern.lastIndex = 0;
1162
- return pattern.test(ctx.content);
1163
- };
1164
- }
1165
- function toDateParts(date, tz) {
1166
- const parts = new Intl.DateTimeFormat("en-CA", {
1167
- timeZone: tz,
1168
- year: "numeric",
1169
- month: "2-digit",
1170
- day: "2-digit",
1171
- hour: "2-digit",
1172
- hourCycle: "h23"
1173
- }).formatToParts(date);
1174
- const get = (type) => parts.find((p) => p.type === type).value;
1175
- return {
1176
- year: get("year"),
1177
- month: get("month"),
1178
- day: get("day"),
1179
- hour: get("hour")
1180
- };
1181
- }
1182
- function temporalChanged(ctx, tz, getKey) {
1183
- if (ctx.lastMessageAt === void 0) return true;
1184
- const nowParts = toDateParts(/* @__PURE__ */ new Date(), tz);
1185
- const prevParts = toDateParts(new Date(ctx.lastMessageAt), tz);
1186
- return getKey(nowParts) !== getKey(prevParts);
1187
- }
1188
- function getSeason(month) {
1189
- if (month >= 2 && month <= 4) return "Spring";
1190
- if (month >= 5 && month <= 7) return "Summer";
1191
- if (month >= 8 && month <= 10) return "Fall";
1192
- return "Winter";
1193
- }
1194
- function isoWeekKey(parts) {
1195
- const d = new Date(
1196
- Date.UTC(
1197
- parseInt(parts.year),
1198
- parseInt(parts.month) - 1,
1199
- parseInt(parts.day)
1200
- )
1201
- );
1202
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
1203
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
1204
- const weekNo = Math.ceil(
1205
- ((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7
1206
- );
1207
- return `${d.getUTCFullYear()}-W${String(weekNo).padStart(2, "0")}`;
1208
- }
1209
- function dayChanged(tz = "UTC") {
1210
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}-${p.day}`);
1211
- }
1212
- function hourChanged(tz = "UTC") {
1213
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}-${p.day}-${p.hour}`);
1214
- }
1215
- function monthChanged(tz = "UTC") {
1216
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}`);
1217
- }
1218
- function yearChanged(tz = "UTC") {
1219
- return (ctx) => temporalChanged(ctx, tz, (p) => p.year);
1220
- }
1221
- function seasonChanged(tz = "UTC") {
1222
- return (ctx) => temporalChanged(ctx, tz, (p) => getSeason(parseInt(p.month) - 1));
1223
- }
1224
- function weekChanged(tz = "UTC") {
1225
- return (ctx) => temporalChanged(ctx, tz, isoWeekKey);
1226
- }
1227
1121
  function isConditionalReminder(fragment2) {
1228
1122
  return fragment2.name === "reminder" && !!fragment2.metadata?.reminder;
1229
1123
  }
1230
- function getConditionalReminder(fragment2) {
1231
- return fragment2.metadata.reminder;
1232
- }
1233
1124
  var SYSTEM_REMINDER_OPEN_TAG = "<system-reminder>";
1234
1125
  var SYSTEM_REMINDER_CLOSE_TAG = "</system-reminder>";
1235
1126
  function getReminderRanges(metadata) {
@@ -1417,10 +1308,12 @@ function mergeReminderMetadata(message2, addedReminders) {
1417
1308
  message2.metadata = metadata;
1418
1309
  }
1419
1310
  function reminder(textOrFragment, options) {
1420
- const text = isFragment(textOrFragment) ? new XmlRenderer().render([textOrFragment]) : textOrFragment;
1311
+ const fromFragment2 = isFragment(textOrFragment);
1312
+ const text = fromFragment2 ? new XmlRenderer().render([textOrFragment]) : textOrFragment;
1421
1313
  if (typeof text === "string") {
1422
1314
  assertReminderText(text);
1423
1315
  }
1316
+ const asPart = options?.asPart ?? fromFragment2;
1424
1317
  if (options && "when" in options && options.when) {
1425
1318
  return {
1426
1319
  name: "reminder",
@@ -1429,14 +1322,14 @@ function reminder(textOrFragment, options) {
1429
1322
  reminder: {
1430
1323
  text,
1431
1324
  when: options.when,
1432
- asPart: options.asPart ?? false
1325
+ asPart
1433
1326
  }
1434
1327
  }
1435
1328
  };
1436
1329
  }
1437
1330
  return {
1438
1331
  text,
1439
- asPart: options?.asPart ?? false
1332
+ asPart
1440
1333
  };
1441
1334
  }
1442
1335
  function user(content, ...reminders) {
@@ -3007,7 +2900,9 @@ var ContextEngine = class _ContextEngine {
3007
2900
  messageCount,
3008
2901
  lastAssistantMessage
3009
2902
  };
3010
- const configs = conditionalReminders.map(getConditionalReminder);
2903
+ const configs = conditionalReminders.map(
2904
+ (it) => it.metadata.reminder
2905
+ );
3011
2906
  const whenResults = await Promise.all(
3012
2907
  configs.map((it) => it.when(whenCtx))
3013
2908
  );
@@ -4477,6 +4372,27 @@ var BM25Classifier = class {
4477
4372
  }
4478
4373
  };
4479
4374
 
4375
+ // packages/context/src/lib/fragments/reminders/combinators.ts
4376
+ function and(...predicates) {
4377
+ return async (ctx) => {
4378
+ for (const it of predicates) {
4379
+ if (!await it(ctx)) return false;
4380
+ }
4381
+ return true;
4382
+ };
4383
+ }
4384
+ function or(...predicates) {
4385
+ return async (ctx) => {
4386
+ for (const it of predicates) {
4387
+ if (await it(ctx)) return true;
4388
+ }
4389
+ return false;
4390
+ };
4391
+ }
4392
+ function not(predicate) {
4393
+ return async (ctx) => !await predicate(ctx);
4394
+ }
4395
+
4480
4396
  // packages/context/src/lib/fragments/reminders/content-predicates.ts
4481
4397
  function contentMatches(topics, options) {
4482
4398
  const classifier = new BM25Classifier(
@@ -4487,8 +4403,118 @@ function contentMatches(topics, options) {
4487
4403
  function classifies(classifier, options) {
4488
4404
  return (ctx) => classifier.match(ctx.content, options).length > 0;
4489
4405
  }
4406
+ function contentIncludes(keywords) {
4407
+ const lower = keywords.map((k) => k.toLowerCase());
4408
+ return (ctx) => {
4409
+ const text = ctx.content.toLowerCase();
4410
+ return lower.some((kw) => text.includes(kw));
4411
+ };
4412
+ }
4413
+ function contentPattern(pattern) {
4414
+ return (ctx) => {
4415
+ pattern.lastIndex = 0;
4416
+ return pattern.test(ctx.content);
4417
+ };
4418
+ }
4490
4419
 
4491
- // packages/context/src/lib/fragments/reminders/temporal-reminder.ts
4420
+ // packages/context/src/lib/fragments/reminders/temporal/predicates.ts
4421
+ var LOCALE_METADATA_KEY = "locale";
4422
+ function getLocaleFromMessage(message2) {
4423
+ if (!message2) return null;
4424
+ const metadata = isRecord(message2.metadata) ? message2.metadata : null;
4425
+ if (!metadata) return null;
4426
+ const locale = metadata[LOCALE_METADATA_KEY];
4427
+ if (!isRecord(locale)) return null;
4428
+ if (typeof locale.language !== "string" || typeof locale.timeZone !== "string") {
4429
+ return null;
4430
+ }
4431
+ return { language: locale.language, timeZone: locale.timeZone };
4432
+ }
4433
+ function resolveTz(options, ctx) {
4434
+ if (options?.tz) return options.tz;
4435
+ const locale = getLocaleFromMessage(ctx.lastMessage);
4436
+ return locale?.timeZone ?? "UTC";
4437
+ }
4438
+ function toDateParts(date, tz) {
4439
+ const parts = new Intl.DateTimeFormat("en-CA", {
4440
+ timeZone: tz,
4441
+ year: "numeric",
4442
+ month: "2-digit",
4443
+ day: "2-digit",
4444
+ hour: "2-digit",
4445
+ hourCycle: "h23"
4446
+ }).formatToParts(date);
4447
+ const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
4448
+ return {
4449
+ year: get("year"),
4450
+ month: get("month"),
4451
+ day: get("day"),
4452
+ hour: get("hour")
4453
+ };
4454
+ }
4455
+ function temporalChanged(ctx, tz, getKey) {
4456
+ if (ctx.lastMessageAt === void 0) return true;
4457
+ const nowParts = toDateParts(/* @__PURE__ */ new Date(), tz);
4458
+ const prevParts = toDateParts(new Date(ctx.lastMessageAt), tz);
4459
+ return getKey(nowParts) !== getKey(prevParts);
4460
+ }
4461
+ function getSeason(month) {
4462
+ if (month >= 2 && month <= 4) return "Spring";
4463
+ if (month >= 5 && month <= 7) return "Summer";
4464
+ if (month >= 8 && month <= 10) return "Fall";
4465
+ return "Winter";
4466
+ }
4467
+ function isoWeekKey(parts) {
4468
+ const d = new Date(
4469
+ Date.UTC(
4470
+ parseInt(parts.year),
4471
+ parseInt(parts.month) - 1,
4472
+ parseInt(parts.day)
4473
+ )
4474
+ );
4475
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4476
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4477
+ const weekNo = Math.ceil(
4478
+ ((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7
4479
+ );
4480
+ return `${d.getUTCFullYear()}-W${String(weekNo).padStart(2, "0")}`;
4481
+ }
4482
+ function dayChanged(options) {
4483
+ return (ctx) => temporalChanged(
4484
+ ctx,
4485
+ resolveTz(options, ctx),
4486
+ (p) => `${p.year}-${p.month}-${p.day}`
4487
+ );
4488
+ }
4489
+ function hourChanged(options) {
4490
+ return (ctx) => temporalChanged(
4491
+ ctx,
4492
+ resolveTz(options, ctx),
4493
+ (p) => `${p.year}-${p.month}-${p.day}-${p.hour}`
4494
+ );
4495
+ }
4496
+ function monthChanged(options) {
4497
+ return (ctx) => temporalChanged(
4498
+ ctx,
4499
+ resolveTz(options, ctx),
4500
+ (p) => `${p.year}-${p.month}`
4501
+ );
4502
+ }
4503
+ function yearChanged(options) {
4504
+ return (ctx) => temporalChanged(ctx, resolveTz(options, ctx), (p) => p.year);
4505
+ }
4506
+ function seasonChanged(options) {
4507
+ return (ctx) => temporalChanged(
4508
+ ctx,
4509
+ resolveTz(options, ctx),
4510
+ (p) => getSeason(parseInt(p.month) - 1)
4511
+ );
4512
+ }
4513
+ function weekChanged(options) {
4514
+ return (ctx) => temporalChanged(ctx, resolveTz(options, ctx), isoWeekKey);
4515
+ }
4516
+
4517
+ // packages/context/src/lib/fragments/reminders/temporal/reminder.ts
4492
4518
  function formatDateKey(date, tz) {
4493
4519
  return date.toLocaleDateString("en-CA", { timeZone: tz });
4494
4520
  }
@@ -4538,9 +4564,9 @@ function formatDiff(changes) {
4538
4564
  `;
4539
4565
  }
4540
4566
  function dateReminder(options) {
4541
- const tz = options?.tz ?? "UTC";
4542
4567
  return reminder(
4543
4568
  (ctx) => {
4569
+ const tz = resolveTz(options, ctx);
4544
4570
  const now = /* @__PURE__ */ new Date();
4545
4571
  const currentDate = formatDateKey(now, tz);
4546
4572
  const currentDay = formatDayOfWeek(now, tz);
@@ -4555,13 +4581,13 @@ function dateReminder(options) {
4555
4581
  return `${diff}Date: ${currentDate}
4556
4582
  Day of Week: ${currentDay}`;
4557
4583
  },
4558
- { when: dayChanged(tz), asPart: true }
4584
+ { when: dayChanged(options), asPart: true }
4559
4585
  );
4560
4586
  }
4561
4587
  function timeReminder(options) {
4562
- const tz = options?.tz ?? "UTC";
4563
4588
  return reminder(
4564
4589
  (ctx) => {
4590
+ const tz = resolveTz(options, ctx);
4565
4591
  const now = /* @__PURE__ */ new Date();
4566
4592
  const currentTime = formatTime(now, tz);
4567
4593
  let diff = "";
@@ -4573,13 +4599,13 @@ function timeReminder(options) {
4573
4599
  }
4574
4600
  return `${diff}Time: ${currentTime}`;
4575
4601
  },
4576
- { when: hourChanged(tz), asPart: true }
4602
+ { when: hourChanged(options), asPart: true }
4577
4603
  );
4578
4604
  }
4579
4605
  function monthReminder(options) {
4580
- const tz = options?.tz ?? "UTC";
4581
4606
  return reminder(
4582
4607
  (ctx) => {
4608
+ const tz = resolveTz(options, ctx);
4583
4609
  const now = /* @__PURE__ */ new Date();
4584
4610
  const currentMonth = formatMonthName(now, tz);
4585
4611
  let diff = "";
@@ -4591,13 +4617,13 @@ function monthReminder(options) {
4591
4617
  }
4592
4618
  return `${diff}Month: ${currentMonth}`;
4593
4619
  },
4594
- { when: monthChanged(tz), asPart: true }
4620
+ { when: monthChanged(options), asPart: true }
4595
4621
  );
4596
4622
  }
4597
4623
  function yearReminder(options) {
4598
- const tz = options?.tz ?? "UTC";
4599
4624
  return reminder(
4600
4625
  (ctx) => {
4626
+ const tz = resolveTz(options, ctx);
4601
4627
  const now = /* @__PURE__ */ new Date();
4602
4628
  const currentYear = formatYear(now, tz);
4603
4629
  let diff = "";
@@ -4609,13 +4635,13 @@ function yearReminder(options) {
4609
4635
  }
4610
4636
  return `${diff}Year: ${currentYear}`;
4611
4637
  },
4612
- { when: yearChanged(tz), asPart: true }
4638
+ { when: yearChanged(options), asPart: true }
4613
4639
  );
4614
4640
  }
4615
4641
  function seasonReminder(options) {
4616
- const tz = options?.tz ?? "UTC";
4617
4642
  return reminder(
4618
4643
  (ctx) => {
4644
+ const tz = resolveTz(options, ctx);
4619
4645
  const now = /* @__PURE__ */ new Date();
4620
4646
  const currentSeason = getSeason(getMonthIndex(now, tz));
4621
4647
  let diff = "";
@@ -4627,21 +4653,9 @@ function seasonReminder(options) {
4627
4653
  }
4628
4654
  return `${diff}Season: ${currentSeason}`;
4629
4655
  },
4630
- { when: seasonChanged(tz), asPart: true }
4656
+ { when: seasonChanged(options), asPart: true }
4631
4657
  );
4632
4658
  }
4633
- var LOCALE_METADATA_KEY = "locale";
4634
- function getLocaleFromMessage(message2) {
4635
- if (!message2) return null;
4636
- const metadata = isRecord(message2.metadata) ? message2.metadata : null;
4637
- if (!metadata) return null;
4638
- const locale = metadata[LOCALE_METADATA_KEY];
4639
- if (!isRecord(locale)) return null;
4640
- if (typeof locale.language !== "string" || typeof locale.timeZone !== "string") {
4641
- return null;
4642
- }
4643
- return { language: locale.language, timeZone: locale.timeZone };
4644
- }
4645
4659
  function localeReminder(options) {
4646
4660
  const language = options?.language ?? "English (US)";
4647
4661
  const timeZone = options?.timeZone ?? "UTC";
@@ -4672,16 +4686,29 @@ Timezone: ${timeZone}`,
4672
4686
  );
4673
4687
  }
4674
4688
  function temporalReminder(options) {
4675
- const tz = options?.tz ?? "UTC";
4676
4689
  return [
4677
- dateReminder({ tz }),
4678
- timeReminder({ tz }),
4679
- monthReminder({ tz }),
4680
- yearReminder({ tz }),
4681
- seasonReminder({ tz })
4690
+ dateReminder(options),
4691
+ timeReminder(options),
4692
+ monthReminder(options),
4693
+ yearReminder(options),
4694
+ seasonReminder(options)
4682
4695
  ];
4683
4696
  }
4684
4697
 
4698
+ // packages/context/src/lib/fragments/reminders/turn-predicates.ts
4699
+ function everyNTurns(n) {
4700
+ return ({ turn }) => turn % n === 0;
4701
+ }
4702
+ function once() {
4703
+ return ({ turn }) => turn === 1;
4704
+ }
4705
+ function firstN(n) {
4706
+ return ({ turn }) => turn <= n;
4707
+ }
4708
+ function afterTurn(n) {
4709
+ return ({ turn }) => turn > n;
4710
+ }
4711
+
4685
4712
  // packages/context/src/lib/fragments/socratic.ts
4686
4713
  function socraticPrompting() {
4687
4714
  return [
@@ -8966,6 +8993,21 @@ var StreamManager = class {
8966
8993
  lastSeq: lastSeqRef.value
8967
8994
  });
8968
8995
  }
8996
+ if (currentStatus === "failed") {
8997
+ const stream = await store2.getStream(streamId);
8998
+ if (stream) {
8999
+ const errorText = stream.error || "Stream failed";
9000
+ this.#emitPolling({
9001
+ type: "watch:error-emitted",
9002
+ streamId,
9003
+ errorTextLength: errorText.length
9004
+ });
9005
+ controller.enqueue({
9006
+ type: "error",
9007
+ errorText
9008
+ });
9009
+ }
9010
+ }
8969
9011
  this.#emitPolling({
8970
9012
  type: "watch:closed",
8971
9013
  streamId,
@@ -9134,6 +9176,7 @@ export {
9134
9176
  DockerfileStrategy,
9135
9177
  DuplicateCommandError,
9136
9178
  InMemoryContextStore,
9179
+ LOCALE_METADATA_KEY,
9137
9180
  MarkdownRenderer,
9138
9181
  ModelsRegistry,
9139
9182
  MountPathError,
@@ -9208,8 +9251,8 @@ export {
9208
9251
  fragment,
9209
9252
  fromFragment,
9210
9253
  generateChatTitle,
9211
- getConditionalReminder,
9212
9254
  getFragmentData,
9255
+ getLocaleFromMessage,
9213
9256
  getModelsRegistry,
9214
9257
  getReminderRanges,
9215
9258
  getSeason,
@@ -9259,6 +9302,7 @@ export {
9259
9302
  resolveReminder,
9260
9303
  resolveReminderAsync,
9261
9304
  resolveReminderText,
9305
+ resolveTz,
9262
9306
  role,
9263
9307
  runGuardrailChain,
9264
9308
  runWithBashMeta,