@vellumai/assistant 0.8.8-dev.202606061835.dc283b1 → 0.8.8-dev.202606061935.99a472f

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.8.8-dev.202606061835.dc283b1",
3
+ "version": "0.8.8-dev.202606061935.99a472f",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -780,7 +780,7 @@ describe("session-agent-loop", () => {
780
780
  });
781
781
  });
782
782
 
783
- test("passes resolved canonical timezones into unified turn context", async () => {
783
+ test("threads the client timezone snapshot but not the config timezones", async () => {
784
784
  mockUiConfig = {
785
785
  userTimezone: "US/Eastern",
786
786
  detectedTimezone: "US/Central",
@@ -797,19 +797,20 @@ describe("session-agent-loop", () => {
797
797
 
798
798
  await runAgentLoopImpl(ctx, "hello", "msg-1", () => {});
799
799
 
800
+ // The loop resolves the effective timezone to format the turn timestamp.
800
801
  expect(formatTurnTimestampMock).toHaveBeenCalledWith({
801
802
  timeZone: "America/New_York",
802
803
  });
803
- // The loop resolves the unified turn-context inputs into the injection
804
- // options bag; the `unified-turn-context` injector later builds the block
805
- // from them. `configuredUserTimezone` is not threaded here —
806
- // `applyRuntimeInjections` sources it from config (`ui.userTimezone`).
804
+ // The client timezone is threaded as a turn-start snapshot, but the
805
+ // configured and detected timezones are not — `applyRuntimeInjections`
806
+ // self-resolves those from config (`ui.userTimezone`,
807
+ // `ui.detectedTimezone`).
807
808
  const injectionOptions = applyRuntimeInjectionsMock.mock.calls[0]?.[1];
808
809
  expect(injectionOptions).toMatchObject({
809
810
  clientTimezone: "America/Los_Angeles",
810
- detectedTimezone: "America/Chicago",
811
811
  });
812
812
  expect(injectionOptions).not.toHaveProperty("configuredUserTimezone");
813
+ expect(injectionOptions).not.toHaveProperty("detectedTimezone");
813
814
  });
814
815
  });
815
816
 
@@ -7,9 +7,10 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
7
7
  // injection chain assertions stay meaningful.
8
8
  const realLoaderForAssemblyTest = await import("../config/loader.js");
9
9
  const realGetConfigForAssemblyTest = realLoaderForAssemblyTest.getConfig;
10
- // Per-test override for `ui.userTimezone` so the self-resolution of the
11
- // configured user timezone inside `applyRuntimeInjections` can be exercised.
10
+ // Per-test overrides for `ui.userTimezone` / `ui.detectedTimezone` so the
11
+ // config self-resolution inside `applyRuntimeInjections` can be exercised.
12
12
  let assemblyConfiguredUserTimezone: string | null | undefined;
13
+ let assemblyDetectedTimezone: string | null | undefined;
13
14
  mock.module("../config/loader.js", () => ({
14
15
  ...realLoaderForAssemblyTest,
15
16
  getConfig: () => {
@@ -20,6 +21,8 @@ mock.module("../config/loader.js", () => ({
20
21
  ...real.ui,
21
22
  userTimezone:
22
23
  assemblyConfiguredUserTimezone ?? real.ui?.userTimezone ?? null,
24
+ detectedTimezone:
25
+ assemblyDetectedTimezone ?? real.ui?.detectedTimezone ?? null,
23
26
  },
24
27
  memory: { ...real.memory, v2: { ...real.memory.v2, enabled: false } },
25
28
  slack: { ...real.slack, botUserId: "U_BOT" },
@@ -1843,12 +1846,13 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
1843
1846
  });
1844
1847
 
1845
1848
  // ---------------------------------------------------------------------------
1846
- // applyRuntimeInjections self-resolves the configured user timezone
1849
+ // applyRuntimeInjections self-resolves the config timezones
1847
1850
  // ---------------------------------------------------------------------------
1848
1851
 
1849
- describe("applyRuntimeInjections configured user timezone self-resolution", () => {
1852
+ describe("applyRuntimeInjections timezone resolution", () => {
1850
1853
  afterEach(() => {
1851
1854
  assemblyConfiguredUserTimezone = undefined;
1855
+ assemblyDetectedTimezone = undefined;
1852
1856
  clearConversations();
1853
1857
  });
1854
1858
 
@@ -1863,23 +1867,48 @@ describe("applyRuntimeInjections configured user timezone self-resolution", () =
1863
1867
  .join("\n");
1864
1868
  }
1865
1869
 
1866
- test("sources configured_user_timezone from config, not the options bag", async () => {
1870
+ test("sources the configured and detected timezones from config, not the options bag", async () => {
1867
1871
  /**
1868
- * Verifies the re-homed configured user timezone is read from
1869
- * `config.ui.userTimezone` inside `applyRuntimeInjections` rather than
1870
- * threaded through the options bag.
1872
+ * Verifies the re-homed configured user timezone and detected-timezone
1873
+ * fallback are read from `config.ui` inside `applyRuntimeInjections`
1874
+ * rather than threaded through the options bag. The detected timezone is
1875
+ * the device-timezone fallback used when the client reports none.
1871
1876
  */
1872
1877
  // GIVEN the guardian has configured a user timezone in config
1873
1878
  assemblyConfiguredUserTimezone = "America/New_York";
1874
1879
 
1875
- // WHEN a turn is assembled whose client reports a different timezone
1876
- // (the options bag carries no `configuredUserTimezone`)
1880
+ // AND a different server-detected timezone is configured
1881
+ assemblyDetectedTimezone = "America/Los_Angeles";
1882
+
1883
+ // WHEN a turn is assembled whose options bag carries no client timezone
1884
+ // (so the detected timezone is the device-timezone fallback)
1885
+ const result = await applyRuntimeInjections(baseMessages, {
1886
+ timestamp: "2026-04-02 (Thursday) 08:00:00 -04:00 (America/New_York)",
1887
+ });
1888
+
1889
+ // THEN the injector surfaces the mismatch using the config-sourced values
1890
+ const injected = injectedText(result);
1891
+ expect(injected).toContain("configured_user_timezone: America/New_York");
1892
+ expect(injected).toContain("client_device_timezone: America/Los_Angeles");
1893
+ });
1894
+
1895
+ test("threads clientTimezone from the options bag as a turn-start snapshot", async () => {
1896
+ /**
1897
+ * Verifies the per-turn client timezone is taken from the options bag (the
1898
+ * turn-start snapshot) and takes precedence over the config-sourced
1899
+ * detected-timezone fallback.
1900
+ */
1901
+ // GIVEN the configured user timezone and a detected fallback in config
1902
+ assemblyConfiguredUserTimezone = "America/New_York";
1903
+ assemblyDetectedTimezone = "America/Denver";
1904
+
1905
+ // WHEN a turn is assembled whose options bag carries a client timezone
1877
1906
  const result = await applyRuntimeInjections(baseMessages, {
1878
1907
  timestamp: "2026-04-02 (Thursday) 08:00:00 -04:00 (America/New_York)",
1879
1908
  clientTimezone: "America/Los_Angeles",
1880
1909
  });
1881
1910
 
1882
- // THEN the injector surfaces the mismatch using the config-sourced value
1911
+ // THEN the injector surfaces the mismatch using the threaded client value
1883
1912
  const injected = injectedText(result);
1884
1913
  expect(injected).toContain("configured_user_timezone: America/New_York");
1885
1914
  expect(injected).toContain("client_device_timezone: America/Los_Angeles");
@@ -1888,7 +1917,7 @@ describe("applyRuntimeInjections configured user timezone self-resolution", () =
1888
1917
  test("omits the mismatch lines when config and client timezone agree", async () => {
1889
1918
  /**
1890
1919
  * Verifies no mismatch affordance is emitted when the config-sourced
1891
- * configured user timezone matches the client-reported timezone.
1920
+ * configured user timezone matches the threaded client timezone.
1892
1921
  */
1893
1922
  // GIVEN the configured user timezone matches the client timezone
1894
1923
  assemblyConfiguredUserTimezone = "America/New_York";
@@ -1085,16 +1085,15 @@ export async function runAgentLoopImpl(
1085
1085
  const injectionOpts = {
1086
1086
  slackChronologicalMessages,
1087
1087
  slackActiveThreadFocusBlock,
1088
- // Unified `<turn_context>` inputs (temporal, channel, interface, actor).
1089
- // The `unified-turn-context` injector builds the block from these via
1090
- // `buildUnifiedTurnContextBlock`. Actor identity is included only for
1091
- // non-guardian turns. The configured user timezone is not threaded here:
1092
- // `applyRuntimeInjections` sources it from config (`ui.userTimezone`).
1088
+ // Unified `<turn_context>` inputs (temporal, channel, interface, actor);
1089
+ // the `unified-turn-context` injector builds the block from these. Actor
1090
+ // identity is included only for non-guardian turns. `clientTimezone` is a
1091
+ // turn-start snapshot threaded here; the configured and detected
1092
+ // timezones are self-resolved from config in `applyRuntimeInjections`.
1093
1093
  timestamp,
1094
1094
  interfaceName,
1095
1095
  channelName,
1096
1096
  clientTimezone: timezoneContext.clientTimezone,
1097
- detectedTimezone: timezoneContext.detectedTimezone,
1098
1097
  timeSinceLastMessage,
1099
1098
  modelProfile: modelProfileStr,
1100
1099
  actorContext: isGuardian ? null : resolvedInboundActorContext,
@@ -1611,14 +1611,14 @@ function applyInjectionBlock(
1611
1611
  * The active workspace surface, the channel capabilities, the active document
1612
1612
  * list, the channel command context, the voice call-control prompt, the
1613
1613
  * transport hints, the background-conversation flag, the
1614
- * `<active_subagents>` status block, and the configured user timezone are not
1615
- * on this bag: `applyRuntimeInjections` resolves them from the live
1614
+ * `<active_subagents>` status block, and the two config-sourced timezones are
1615
+ * not on this bag: `applyRuntimeInjections` resolves them from the live
1616
1616
  * conversation itself (its surface state, `channelCapabilities`, the document
1617
1617
  * store keyed by `conversationId`, its `commandIntent`, its
1618
1618
  * `voiceCallControlPrompt`, its `transportHints`, its `conversationType`, and
1619
- * the subagent manager's children of `conversationId` respectively) or, for
1620
- * the configured user timezone, from config (`ui.userTimezone`), so the
1621
- * orchestrator does not compute or thread any of them per turn.
1619
+ * the subagent manager's children of `conversationId` respectively) or from
1620
+ * config (the configured user timezone and the detected-timezone fallback), so
1621
+ * the orchestrator does not compute or thread any of them per turn.
1622
1622
  *
1623
1623
  * {@link isNonInteractive} is the exception: it is derived from the agent
1624
1624
  * loop's `isInteractive` option (not re-derivable from live conversation
@@ -1628,11 +1628,14 @@ function applyInjectionBlock(
1628
1628
  * agent-loop closure state.
1629
1629
  *
1630
1630
  * The remaining unified `<turn_context>` inputs (`timestamp`, `interfaceName`,
1631
- * `channelName`, `actorContext`, `clientTimezone`, `detectedTimezone`,
1632
- * `timeSinceLastMessage`, and `modelProfile`) are flat top-level fields here.
1633
- * They flow through to the matching {@link TurnInjectionInputs} fields, and the
1634
- * `unified-turn-context` injector builds the block from them (combined with the
1635
- * self-resolved `configuredUserTimezone`) via `buildUnifiedTurnContextBlock`.
1631
+ * `channelName`, `actorContext`, `clientTimezone`, `timeSinceLastMessage`, and
1632
+ * `modelProfile`) are flat top-level fields here. `clientTimezone` stays on the
1633
+ * bag as a turn-start snapshot because the live `Conversation.clientTimezone`
1634
+ * is overwritten when a newer message for the same conversation arrives
1635
+ * mid-turn. They flow through to the matching {@link TurnInjectionInputs}
1636
+ * fields, and the `unified-turn-context` injector builds the block from them
1637
+ * (combined with the two self-resolved config timezones) via
1638
+ * `buildUnifiedTurnContextBlock`.
1636
1639
  */
1637
1640
  export interface RuntimeInjectionOptions {
1638
1641
  /**
@@ -1693,10 +1696,14 @@ export interface RuntimeInjectionOptions {
1693
1696
  * turns; `null`/absent suppresses the actor section of `<turn_context>`.
1694
1697
  */
1695
1698
  actorContext?: InboundActorContext | null;
1696
- /** Client-reported timezone, used to detect a client/config mismatch. */
1699
+ /**
1700
+ * Client-reported timezone, used to detect a client/config mismatch. Kept on
1701
+ * this bag as a turn-start snapshot rather than self-resolved: the live
1702
+ * `Conversation.clientTimezone` is overwritten when a newer message for the
1703
+ * same conversation arrives mid-turn, so reading it at assembly time could
1704
+ * leak a queued message's timezone into the in-flight turn.
1705
+ */
1697
1706
  clientTimezone?: string | null;
1698
- /** Server-detected timezone fallback when the client does not report one. */
1699
- detectedTimezone?: string | null;
1700
1707
  /**
1701
1708
  * Human-readable gap since the previous user message (e.g. "14h ago"), only
1702
1709
  * set when the gap exceeds the long-absence threshold.
@@ -1738,6 +1745,7 @@ function buildTurnInjectionInputs(
1738
1745
  isBackgroundConversation: boolean,
1739
1746
  subagentStatusBlock: string | null,
1740
1747
  configuredUserTimezone: string | null,
1748
+ detectedTimezone: string | null,
1741
1749
  ): TurnInjectionInputs {
1742
1750
  return {
1743
1751
  mode: options.mode,
@@ -1754,7 +1762,7 @@ function buildTurnInjectionInputs(
1754
1762
  actorContext: options.actorContext,
1755
1763
  configuredUserTimezone,
1756
1764
  clientTimezone: options.clientTimezone,
1757
- detectedTimezone: options.detectedTimezone,
1765
+ detectedTimezone,
1758
1766
  timeSinceLastMessage: options.timeSinceLastMessage,
1759
1767
  modelProfile: options.modelProfile,
1760
1768
  };
@@ -1853,12 +1861,20 @@ export async function applyRuntimeInjections(
1853
1861
  );
1854
1862
  const isNonInteractive = options.isNonInteractive ?? false;
1855
1863
 
1856
- // The guardian-configured timezone is a stable user setting, not a per-turn
1857
- // value, so it is sourced from config here rather than threaded through
1858
- // `options`. The `unified-turn-context` injector compares it against the
1859
- // client-reported timezone to surface a mismatch affordance.
1864
+ // The configured user timezone and the server-detected fallback are stable
1865
+ // settings, so they are read from config here rather than threaded through
1866
+ // `options`. The client-reported timezone stays on `options` instead: it is a
1867
+ // per-turn snapshot frozen at turn start, since the live
1868
+ // `Conversation.clientTimezone` is overwritten when a newer message for the
1869
+ // same conversation arrives mid-turn. The `unified-turn-context` injector
1870
+ // compares the configured and client timezones to surface a mismatch
1871
+ // affordance.
1872
+ const uiConfig = getConfig().ui;
1860
1873
  const configuredUserTimezone = canonicalizeTimeZone(
1861
- getConfig().ui?.userTimezone ?? null,
1874
+ uiConfig?.userTimezone ?? null,
1875
+ );
1876
+ const detectedTimezone = canonicalizeTimeZone(
1877
+ uiConfig?.detectedTimezone ?? null,
1862
1878
  );
1863
1879
 
1864
1880
  // The `<active_subagents>` status block is sourced from the live subagent
@@ -1882,6 +1898,7 @@ export async function applyRuntimeInjections(
1882
1898
  isBackgroundConversation,
1883
1899
  subagentStatusBlock,
1884
1900
  configuredUserTimezone,
1901
+ detectedTimezone,
1885
1902
  );
1886
1903
  const turnCtx: TurnContext = options.turnContext
1887
1904
  ? { ...options.turnContext, injectionInputs }