@intentface/latch-core 0.13.2 → 0.14.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,2BAA2B,EAAgB,aAAa,EAAW,MAAM,IAAI,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,SAAS,EAET,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAoB,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAKL,KAAK,WAAW,EAIjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,UAAU,EAEV,SAAS,EACT,SAAS,EACT,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EASL,KAAK,SAAS,EAMf,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;GAUG;AACH;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;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gB,4BAA4B,CAC1C,QAAQ,EAAE,UAAU,EAAE,EACtB,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9B,UAAU,EAAE,CAmCd;AAwFD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA6BzD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,EAC3C,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC,CAu4FZ"}
package/dist/runtime.js CHANGED
@@ -58,6 +58,20 @@ function progressObserver(lead, onProgress, continuing) {
58
58
  })();
59
59
  };
60
60
  }
61
+ /**
62
+ * What an unattended turn records on its run (`RunRecord.settings`): only what
63
+ * differs from an attended chat turn's defaults, so a plain turn stores none.
64
+ */
65
+ function runSettingsOf(o) {
66
+ const settings = {
67
+ ...(o.autoApprove ? { autoApprove: true } : {}),
68
+ ...(o.blockGated ? { blockGated: o.blockGated } : {}),
69
+ ...(o.memory === false ? { memory: false } : {}),
70
+ ...(o.promptCaching === false ? { promptCaching: false } : {}),
71
+ ...(o.model ? { modelOverride: typeof o.model === "string" ? o.model : `${o.model.provider}:${o.model.modelId}` } : {}),
72
+ };
73
+ return Object.keys(settings).length ? settings : undefined;
74
+ }
61
75
  /** Ids for assistant response messages — `msg_<random>`, matching storage ids. */
62
76
  const generateMessageId = createIdGenerator({ prefix: "msg", separator: "_" });
63
77
  /** Sub-thread chat ids start with `sub_` so the host can keep them out of the
@@ -1395,16 +1409,23 @@ export function createRuntime(config) {
1395
1409
  // at most the write in flight and the one queued behind it. A failed write
1396
1410
  // logs and releases the chain — the next checkpoint still runs.
1397
1411
  let checkpoints = Promise.resolve();
1412
+ // Message writes of a leased turn carry the lease, so the adapter refuses
1413
+ // them atomically once the run was reaped and re-claimed elsewhere.
1414
+ const fence = lease ? { runId: run.id, ...lease } : undefined;
1398
1415
  const checkpoint = (message) => {
1399
1416
  if (!dur.enabled || abort.signal.aborted)
1400
1417
  return;
1401
1418
  checkpoints = checkpoints
1402
- .then(() => {
1419
+ .then(async () => {
1403
1420
  // Re-checked at write time: the lease may have gone while this
1404
1421
  // checkpoint waited behind the previous one.
1405
1422
  if (abort.signal.aborted)
1406
1423
  return;
1407
- return storage.appendMessages(resolvedChatId, [message]);
1424
+ const landed = await storage.appendMessages(resolvedChatId, [message], fence);
1425
+ // Refused by the fence: another worker owns the run now. Stop like
1426
+ // a lost heartbeat does, before this turn spends another step.
1427
+ if (landed === false)
1428
+ abort.abort(new Error("lease lost"));
1408
1429
  })
1409
1430
  .catch((e) => console.warn(`[durability] step checkpoint failed for run ${run.id}:`, e));
1410
1431
  };
@@ -1667,17 +1688,12 @@ export function createRuntime(config) {
1667
1688
  // (with any completed tool results) so a crash mid-turn doesn't repeat
1668
1689
  // them on resume. Durable turns only — keeps T1 write counts unchanged.
1669
1690
  //
1670
- // Guarded on the turn's abort signal: `appendMessages` has no lease
1671
- // fence (only `updateRun` does), so once this worker has lost the lease
1672
- // a reclaimed copy of the run may be replaying into this same chat —
1673
- // an un-guarded checkpoint from the zombie would interleave with it,
1674
- // and every later resume replays the polluted history.
1675
- //
1676
- // Best-effort, not a fence: the lease can be lost between this check and
1677
- // the write committing. Closing that window needs a lease/fencing-token
1678
- // check inside the storage write itself — an adapter interface change,
1679
- // tracked as a follow-up. With the heartbeat now aborting within one TTL
1680
- // of losing contact, the exposure is bounded to ~leaseTtlMs.
1691
+ // Fenced: once this worker has lost the lease, a reclaimed copy of the
1692
+ // run may be replaying into this same chat — a checkpoint from the
1693
+ // zombie would interleave with it, and every later resume replays the
1694
+ // polluted history. The write carries the lease (`fence`) and the
1695
+ // adapter checks it atomically with the insert; the abort-signal check
1696
+ // only saves a doomed write.
1681
1697
  onStepEnd: dur.enabled || hooks.has("step_end")
1682
1698
  ? ({ responseMessage }) => {
1683
1699
  if (hooks.has("step_end")) {
@@ -1798,7 +1814,9 @@ export function createRuntime(config) {
1798
1814
  endedAt: paused ? undefined : Date.now(),
1799
1815
  }, lease);
1800
1816
  if (applied) {
1801
- await storage.appendMessages(resolvedChatId, messages);
1817
+ // Fenced too: the run row and the message are separate writes, and
1818
+ // the lease can be lost between them.
1819
+ await storage.appendMessages(resolvedChatId, messages, fence);
1802
1820
  await storage.recordUsage(principal, {
1803
1821
  runId: run.id,
1804
1822
  model: modelId,
@@ -1850,7 +1868,7 @@ export function createRuntime(config) {
1850
1868
  return out;
1851
1869
  }
1852
1870
  async function reapTick(opts) {
1853
- const reaped = await storage.reapExpiredRuns(opts?.now ?? Date.now(), {
1871
+ const reaped = await storage.reapExpiredRuns(opts?.now, {
1854
1872
  error: opts?.error,
1855
1873
  });
1856
1874
  return { reaped };
@@ -1912,6 +1930,11 @@ export function createRuntime(config) {
1912
1930
  * resolution or run creation failed): the window counts turns that RAN, or a
1913
1931
  * user retrying into a busy chat would exhaust their own turn cap.
1914
1932
  */
1933
+ /** A run's stored error, when it ended `errored` — the fallback when its stream said nothing. */
1934
+ async function terminalError(runId) {
1935
+ const row = await storage.getRun(runId).catch(() => null);
1936
+ return row?.status === "errored" && row.error ? row.error : undefined;
1937
+ }
1915
1938
  async function releaseReservation(admitted) {
1916
1939
  if (!admitted?.counted || !config.limits)
1917
1940
  return;
@@ -1947,13 +1970,16 @@ export function createRuntime(config) {
1947
1970
  * persists nothing (the crash window between the two writes is the trade-off
1948
1971
  * an adapter without `openTurn` accepts).
1949
1972
  */
1950
- async function openTurn(principal, chatId, agentName, messages, agentVersion) {
1973
+ async function openTurn(principal, chatId, agentName, messages, agentVersion,
1974
+ /** Recorded on the run so recovery resumes it the same way (`RunRecord.settings`). */
1975
+ settings) {
1951
1976
  if (storage.openTurn) {
1952
1977
  const run = await storage.openTurn(principal, {
1953
1978
  chatId,
1954
1979
  agent: agentName,
1955
1980
  messages,
1956
1981
  agentVersion: agentVersion ?? null,
1982
+ ...(settings ? { settings } : {}),
1957
1983
  ...(dur.enabled ? { lease: { owner: dur.instanceId, ttlMs: dur.leaseTtlMs } } : {}),
1958
1984
  });
1959
1985
  return {
@@ -1961,12 +1987,12 @@ export function createRuntime(config) {
1961
1987
  lease: dur.enabled ? { owner: dur.instanceId, fencingToken: run.fencingToken ?? 1 } : undefined,
1962
1988
  };
1963
1989
  }
1964
- const opened = await openRun(principal, chatId, agentName, agentVersion);
1990
+ const opened = await openRun(principal, chatId, agentName, agentVersion, settings);
1965
1991
  if (messages.length > 0)
1966
1992
  await storage.appendMessages(chatId, messages);
1967
1993
  return opened;
1968
1994
  }
1969
- async function openRun(principal, chatId, agentName, agentVersion) {
1995
+ async function openRun(principal, chatId, agentName, agentVersion, settings) {
1970
1996
  if (dur.enabled) {
1971
1997
  const run = await storage.claimRun({
1972
1998
  principal,
@@ -1975,6 +2001,7 @@ export function createRuntime(config) {
1975
2001
  owner: dur.instanceId,
1976
2002
  ttlMs: dur.leaseTtlMs,
1977
2003
  agentVersion: agentVersion ?? null,
2004
+ ...(settings ? { settings } : {}),
1978
2005
  });
1979
2006
  return { run, lease: { owner: dur.instanceId, fencingToken: run.fencingToken ?? 1 } };
1980
2007
  }
@@ -1984,6 +2011,7 @@ export function createRuntime(config) {
1984
2011
  agent: agentName,
1985
2012
  kind: "turn",
1986
2013
  agentVersion: agentVersion ?? null,
2014
+ ...(settings ? { settings } : {}),
1987
2015
  }),
1988
2016
  lease: undefined,
1989
2017
  };
@@ -2049,14 +2077,11 @@ export function createRuntime(config) {
2049
2077
  owner: dur.instanceId,
2050
2078
  fencingToken: run.fencingToken ?? 1,
2051
2079
  };
2052
- if (principal === null) {
2053
- // Refused (see `ReconstructPrincipal`): the identity may no longer act, so
2054
- // nothing below — not even reading its history — runs as it. End the run
2055
- // instead of returning early with the lease held: an `active` row would be
2056
- // reaped and re-refused every tick until `maxAttempts`, and a throw here
2057
- // would abort the rest of `sweep`'s loop. No `onRunFinished`: its meta
2058
- // carries the principal, and there is none to report.
2059
- const error = "principal rejected: reconstructPrincipal refused the run's identity";
2080
+ // End a run recovery won't resume. Settled rather than returned early with
2081
+ // the lease held: an `active` row would be reaped and re-refused every tick
2082
+ // until `maxAttempts`, and a throw would abort the rest of `sweep`'s loop.
2083
+ // No `onRunFinished`: nothing ran.
2084
+ const refuse = async (error) => {
2060
2085
  await storage.updateRun(run.id, {
2061
2086
  status: "errored",
2062
2087
  error,
@@ -2075,6 +2100,11 @@ export function createRuntime(config) {
2075
2100
  status: settled?.status ?? "errored",
2076
2101
  attempt: settled?.attempt ?? run.attempt ?? null,
2077
2102
  };
2103
+ };
2104
+ if (principal === null) {
2105
+ // Refused (see `ReconstructPrincipal`): the identity may no longer act, so
2106
+ // nothing below — not even reading its history — runs as it.
2107
+ return refuse("principal rejected: reconstructPrincipal refused the run's identity");
2078
2108
  }
2079
2109
  const uiMessages = await storage.loadMessages(principal, run.chatId);
2080
2110
  // What does this run actually need? A crash between the last step's
@@ -2171,11 +2201,39 @@ export function createRuntime(config) {
2171
2201
  // reconcilable even if its (dynamic, DB-stored) agent was since deleted.
2172
2202
  // Before this ordering that throw also aborted `sweep`'s loop, so one such
2173
2203
  // run held up recovery for every other run until its attempts ran out.
2204
+ // Resume the turn the way it was asked to run (`RunRecord.settings`): an
2205
+ // unattended run stays unattended — and keeps its `blockGated`, or its
2206
+ // gated tools would run for real — memory off stays off. A run on a
2207
+ // per-turn model override can't be resumed on that model (the object
2208
+ // isn't stored), and finishing it on the agent's own would quietly change
2209
+ // what answered: refuse it instead.
2210
+ const settings = run.settings ?? {};
2211
+ if (settings.modelOverride) {
2212
+ return refuse(`can't resume on the per-turn model it started with (${settings.modelOverride})`);
2213
+ }
2174
2214
  // A recovered subagent run must resolve exactly as its spawner shaped it —
2175
2215
  // crash recovery and `sweep` both land here.
2176
2216
  const chat = await storage.getChat(principal, run.chatId);
2177
- const { cfg, modelId, runtimeCtx } = await resolveAgentConfig(run.agent, principal, undefined, undefined, {
2217
+ // And on the agent VERSION it started on (`RunRecord.agentVersion`): a
2218
+ // publish between the crash and the recovery must not change what finishes
2219
+ // the turn — a new model, new instructions. Pinned as `name@7`, the same
2220
+ // read-only pin a measured version uses. Code-declared agents have no
2221
+ // stored version, and an agent already pinned (`name@7`, `name@c_…`) keeps
2222
+ // the pin it ran under.
2223
+ const pinnedAgent = run.agentVersion != null && !config.agents[run.agent] && !run.agent.includes("@")
2224
+ ? `${run.agent}@${run.agentVersion}`
2225
+ : run.agent;
2226
+ const resolveCtx = {
2178
2227
  parentAgent: chat?.parentAgent,
2228
+ ...(settings.autoApprove !== undefined ? { autoApprove: settings.autoApprove } : {}),
2229
+ };
2230
+ // A store that records versions but can't resolve a pin falls back to the
2231
+ // agent as it is now — what recovery always did — rather than failing it.
2232
+ const { cfg, modelId, runtimeCtx } = await resolveAgentConfig(pinnedAgent, principal, undefined, undefined, resolveCtx).catch((e) => {
2233
+ if (pinnedAgent === run.agent)
2234
+ throw e;
2235
+ console.warn(`[resume] run ${run.id}: ${pinnedAgent} did not resolve; resuming on ${run.agent} as it is now`);
2236
+ return resolveAgentConfig(run.agent, principal, undefined, undefined, resolveCtx);
2179
2237
  });
2180
2238
  // A resume was admitted when the turn first ran — never refuse it (the
2181
2239
  // half-done work would strand), but its tokens still settle against the
@@ -2200,6 +2258,10 @@ export function createRuntime(config) {
2200
2258
  uiMessages: trimTrailingAssistantPrefill(uiMessages, { unanchored: true }),
2201
2259
  runtimeCtx,
2202
2260
  admitted,
2261
+ ...(settings.autoApprove !== undefined ? { autoApprove: settings.autoApprove } : {}),
2262
+ ...(settings.blockGated !== undefined ? { blockGated: settings.blockGated } : {}),
2263
+ ...(settings.memory !== undefined ? { memory: settings.memory } : {}),
2264
+ ...(settings.promptCaching !== undefined ? { promptCaching: settings.promptCaching } : {}),
2203
2265
  // Crash recovery, driven server-side: nobody is watching this stream.
2204
2266
  trigger: "resume",
2205
2267
  });
@@ -2722,36 +2784,67 @@ export function createRuntime(config) {
2722
2784
  parentAgent: chat.parentAgent ?? o.parentAgent,
2723
2785
  autoApprove: o.autoApprove,
2724
2786
  });
2725
- const opened = await openTurn(o.principal, chatId, o.agent, [o.message], resolved.cfg.configVersion);
2787
+ const opened = await openTurn(o.principal, chatId, o.agent, [o.message], resolved.cfg.configVersion, runSettingsOf(o));
2726
2788
  return { ...resolved, ...opened };
2727
2789
  });
2728
2790
  const onProgress = o.onProgress;
2729
- const res = await buildTurn({
2730
- resolvedChatId: chatId,
2731
- principal: o.principal,
2732
- modelId,
2733
- cfg,
2734
- run,
2735
- lease,
2736
- uiMessages: [...prior, o.message],
2737
- runtimeCtx,
2738
- admitted,
2739
- autoApprove: o.autoApprove,
2740
- blockGated: o.blockGated,
2741
- memory: o.memory,
2742
- model: o.model,
2743
- promptCaching: o.promptCaching,
2744
- depth: o.depth ?? 0,
2745
- parentRunId: o.parentRunId,
2746
- rootChatId: o.rootChatId,
2747
- trigger: o.trigger,
2748
- // Forward progressive UI-message snapshots to the caller (spawn_agent
2749
- // streams them into the parent turn).
2750
- observeStream: onProgress ? progressObserver([o.message], onProgress) : undefined,
2751
- });
2791
+ let res;
2792
+ try {
2793
+ res = await buildTurn({
2794
+ resolvedChatId: chatId,
2795
+ principal: o.principal,
2796
+ modelId,
2797
+ cfg,
2798
+ run,
2799
+ lease,
2800
+ uiMessages: [...prior, o.message],
2801
+ runtimeCtx,
2802
+ admitted,
2803
+ autoApprove: o.autoApprove,
2804
+ blockGated: o.blockGated,
2805
+ memory: o.memory,
2806
+ model: o.model,
2807
+ promptCaching: o.promptCaching,
2808
+ depth: o.depth ?? 0,
2809
+ parentRunId: o.parentRunId,
2810
+ rootChatId: o.rootChatId,
2811
+ trigger: o.trigger,
2812
+ // Forward progressive UI-message snapshots to the caller (spawn_agent
2813
+ // streams them into the parent turn).
2814
+ observeStream: onProgress ? progressObserver([o.message], onProgress) : undefined,
2815
+ });
2816
+ }
2817
+ catch (e) {
2818
+ // Setup failed after the run opened — a tool source that would not
2819
+ // open, say. Settle the run (left `active`, it would hold the chat until
2820
+ // its lease or the stale timeout lapsed), give back the reservation, and
2821
+ // say why the way a failed turn does: as `error`, not a throw. Admission
2822
+ // refusals never get here — they throw before any run exists.
2823
+ const error = clientErrorMessage(e);
2824
+ // If settling fails too, say so: the run then stays active (holding the
2825
+ // chat until its lease lapses), and a caller told only the setup error
2826
+ // would retry into a busy chat without knowing why.
2827
+ const unsettled = await storage
2828
+ .updateRun(run.id, { status: "errored", error, endedAt: Date.now(), leaseOwner: null, leaseExpiresAt: null }, lease)
2829
+ .then(
2830
+ // `false`: the lease guard refused the write — another worker holds the run now.
2831
+ (applied) => (applied === false ? "its lease is held elsewhere" : undefined), (settleError) => clientErrorMessage(settleError));
2832
+ await releaseReservation(admitted);
2833
+ if (unsettled)
2834
+ console.error(`[runAgent] run ${run.id} failed during setup and could not be settled: ${unsettled}`);
2835
+ return {
2836
+ chatId,
2837
+ answer: "",
2838
+ parked: false,
2839
+ error: unsettled ? `${error} (and the run could not be marked failed: ${unsettled})` : error,
2840
+ };
2841
+ }
2752
2842
  // The turn's own failure travels as an `error` chunk — the stream, not a
2753
2843
  // throw. Keep its text: without it a failed turn reads as a silent one.
2754
- const error = lastStreamError(await res.text());
2844
+ // A failure that ends the run without an error chunk (a final-step
2845
+ // `step_end` handler, caught in onFinish) is only on the run row: read it
2846
+ // back so a failed turn never looks like a silent one.
2847
+ const error = lastStreamError(await res.text()) ?? (await terminalError(run.id));
2755
2848
  const after = await storage.loadMessages(o.principal, chatId);
2756
2849
  // The verdict is about THIS turn, so read the FINAL message only (the same
2757
2850
  // rule hasPendingApproval applies): an undecided gate in an older message