@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/browser.js CHANGED
@@ -1772,118 +1772,9 @@ function extractPlainText(message2) {
1772
1772
  }
1773
1773
 
1774
1774
  // packages/context/src/lib/fragments/message/user.ts
1775
- function everyNTurns(n) {
1776
- return ({ turn }) => turn % n === 0;
1777
- }
1778
- function once() {
1779
- return ({ turn }) => turn === 1;
1780
- }
1781
- function firstN(n) {
1782
- return ({ turn }) => turn <= n;
1783
- }
1784
- function afterTurn(n) {
1785
- return ({ turn }) => turn > n;
1786
- }
1787
- function and(...predicates) {
1788
- return async (ctx) => {
1789
- for (const it of predicates) {
1790
- if (!await it(ctx)) return false;
1791
- }
1792
- return true;
1793
- };
1794
- }
1795
- function or(...predicates) {
1796
- return async (ctx) => {
1797
- for (const it of predicates) {
1798
- if (await it(ctx)) return true;
1799
- }
1800
- return false;
1801
- };
1802
- }
1803
- function not(predicate) {
1804
- return async (ctx) => !await predicate(ctx);
1805
- }
1806
- function contentIncludes(keywords) {
1807
- const lower = keywords.map((k) => k.toLowerCase());
1808
- return (ctx) => {
1809
- const text = ctx.content.toLowerCase();
1810
- return lower.some((kw) => text.includes(kw));
1811
- };
1812
- }
1813
- function contentPattern(pattern) {
1814
- return (ctx) => {
1815
- pattern.lastIndex = 0;
1816
- return pattern.test(ctx.content);
1817
- };
1818
- }
1819
- function toDateParts(date, tz) {
1820
- const parts = new Intl.DateTimeFormat("en-CA", {
1821
- timeZone: tz,
1822
- year: "numeric",
1823
- month: "2-digit",
1824
- day: "2-digit",
1825
- hour: "2-digit",
1826
- hourCycle: "h23"
1827
- }).formatToParts(date);
1828
- const get = (type) => parts.find((p) => p.type === type).value;
1829
- return {
1830
- year: get("year"),
1831
- month: get("month"),
1832
- day: get("day"),
1833
- hour: get("hour")
1834
- };
1835
- }
1836
- function temporalChanged(ctx, tz, getKey) {
1837
- if (ctx.lastMessageAt === void 0) return true;
1838
- const nowParts = toDateParts(/* @__PURE__ */ new Date(), tz);
1839
- const prevParts = toDateParts(new Date(ctx.lastMessageAt), tz);
1840
- return getKey(nowParts) !== getKey(prevParts);
1841
- }
1842
- function getSeason(month) {
1843
- if (month >= 2 && month <= 4) return "Spring";
1844
- if (month >= 5 && month <= 7) return "Summer";
1845
- if (month >= 8 && month <= 10) return "Fall";
1846
- return "Winter";
1847
- }
1848
- function isoWeekKey(parts) {
1849
- const d = new Date(
1850
- Date.UTC(
1851
- parseInt(parts.year),
1852
- parseInt(parts.month) - 1,
1853
- parseInt(parts.day)
1854
- )
1855
- );
1856
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
1857
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
1858
- const weekNo = Math.ceil(
1859
- ((d.getTime() - yearStart.getTime()) / 864e5 + 1) / 7
1860
- );
1861
- return `${d.getUTCFullYear()}-W${String(weekNo).padStart(2, "0")}`;
1862
- }
1863
- function dayChanged(tz = "UTC") {
1864
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}-${p.day}`);
1865
- }
1866
- function hourChanged(tz = "UTC") {
1867
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}-${p.day}-${p.hour}`);
1868
- }
1869
- function monthChanged(tz = "UTC") {
1870
- return (ctx) => temporalChanged(ctx, tz, (p) => `${p.year}-${p.month}`);
1871
- }
1872
- function yearChanged(tz = "UTC") {
1873
- return (ctx) => temporalChanged(ctx, tz, (p) => p.year);
1874
- }
1875
- function seasonChanged(tz = "UTC") {
1876
- return (ctx) => temporalChanged(ctx, tz, (p) => getSeason(parseInt(p.month) - 1));
1877
- }
1878
- function weekChanged(tz = "UTC") {
1879
- return (ctx) => temporalChanged(ctx, tz, isoWeekKey);
1880
- }
1881
1775
  function isConditionalReminder(fragment2) {
1882
1776
  return fragment2.name === "reminder" && !!fragment2.metadata?.reminder;
1883
1777
  }
1884
- function getConditionalReminder(fragment2) {
1885
- return fragment2.metadata.reminder;
1886
- }
1887
1778
  var SYSTEM_REMINDER_OPEN_TAG = "<system-reminder>";
1888
1779
  var SYSTEM_REMINDER_CLOSE_TAG = "</system-reminder>";
1889
1780
  function getReminderRanges(metadata) {
@@ -2071,10 +1962,12 @@ function mergeReminderMetadata(message2, addedReminders) {
2071
1962
  message2.metadata = metadata;
2072
1963
  }
2073
1964
  function reminder(textOrFragment, options) {
2074
- const text = isFragment(textOrFragment) ? new XmlRenderer().render([textOrFragment]) : textOrFragment;
1965
+ const fromFragment2 = isFragment(textOrFragment);
1966
+ const text = fromFragment2 ? new XmlRenderer().render([textOrFragment]) : textOrFragment;
2075
1967
  if (typeof text === "string") {
2076
1968
  assertReminderText(text);
2077
1969
  }
1970
+ const asPart = options?.asPart ?? fromFragment2;
2078
1971
  if (options && "when" in options && options.when) {
2079
1972
  return {
2080
1973
  name: "reminder",
@@ -2083,14 +1976,14 @@ function reminder(textOrFragment, options) {
2083
1976
  reminder: {
2084
1977
  text,
2085
1978
  when: options.when,
2086
- asPart: options.asPart ?? false
1979
+ asPart
2087
1980
  }
2088
1981
  }
2089
1982
  };
2090
1983
  }
2091
1984
  return {
2092
1985
  text,
2093
- asPart: options?.asPart ?? false
1986
+ asPart
2094
1987
  };
2095
1988
  }
2096
1989
  function user(content, ...reminders) {
@@ -2311,38 +2204,28 @@ export {
2311
2204
  TomlRenderer,
2312
2205
  ToonRenderer,
2313
2206
  XmlRenderer,
2314
- afterTurn,
2315
2207
  alias,
2316
2208
  analogy,
2317
- and,
2318
2209
  applyInlineReminder,
2319
2210
  applyPartReminder,
2320
2211
  applyReminderToMessage,
2321
2212
  assistant,
2322
2213
  assistantText,
2323
2214
  clarification,
2324
- contentIncludes,
2325
- contentPattern,
2326
2215
  correction,
2327
- dayChanged,
2328
2216
  defaultTokenizer,
2329
2217
  estimate,
2330
- everyNTurns,
2331
2218
  example,
2332
2219
  explain,
2333
2220
  fail,
2334
- firstN,
2335
2221
  fragment,
2336
2222
  fromFragment,
2337
- getConditionalReminder,
2338
2223
  getFragmentData,
2339
2224
  getModelsRegistry,
2340
2225
  getReminderRanges,
2341
- getSeason,
2342
2226
  glossary,
2343
2227
  guardrail,
2344
2228
  hint,
2345
- hourChanged,
2346
2229
  identity,
2347
2230
  isConditionalReminder,
2348
2231
  isFragment,
@@ -2352,10 +2235,6 @@ export {
2352
2235
  mergeMessageMetadata,
2353
2236
  mergeReminderMetadata,
2354
2237
  message,
2355
- monthChanged,
2356
- not,
2357
- once,
2358
- or,
2359
2238
  pass,
2360
2239
  persistedWriter,
2361
2240
  persona,
@@ -2370,7 +2249,6 @@ export {
2370
2249
  resolveReminderText,
2371
2250
  role,
2372
2251
  runGuardrailChain,
2373
- seasonChanged,
2374
2252
  soul,
2375
2253
  stop,
2376
2254
  stripReminders,
@@ -2380,8 +2258,6 @@ export {
2380
2258
  toFragment,
2381
2259
  user,
2382
2260
  visualizeGraph,
2383
- weekChanged,
2384
- workflow,
2385
- yearChanged
2261
+ workflow
2386
2262
  };
2387
2263
  //# sourceMappingURL=browser.js.map