@dudko.dev/agent-web-react 0.0.32 → 0.0.33

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/README.md CHANGED
@@ -209,7 +209,7 @@ function Custom() {
209
209
  | `learned`, `learnedNow`, `fetches` | the agent's notebook (`LessonView[]`, survives `reset`), what it wrote this run, and the `web_fetch` requests this run made (`FetchView[]`) |
210
210
  | `queued`, `notes`, `undelivered`, `replan` | steering: messages waiting, shown (and where), left over; the last replan decision (`byUser` when a message caused it; `failed` + `error` when the replanner call itself failed and the run went on with its plan) |
211
211
  | `steps[i].tier`, `.model`, `.tierReason`, `.escalations`, `.replanFailed` | with the core's `executorTiers`: the tier and model a step is on, why it started there, and its escalations (`StepEscalationView[]`); a tool call of an escalated attempt has `attempt`, a write that was not run twice `replayed`. `replanFailed`: the replanner failed after this step (a warning). All absent when tiers are off — see [docs/chat.md](docs/chat.md#model-tiers-escalation-and-a-replanner-that-failed) |
212
- | `error`, `stopped`, `events`, `seq` | the run's error text (a replanner failure is not one: see `replan.failed`), whether it was stopped, the raw event log and its counter |
212
+ | `error`, `errorCode`, `stopped`, `events`, `seq` | the run's error text (a replanner failure is not one: see `replan.failed`); the core's code for an error a host may say in its own words - `'no-plan'` (the planner returned nothing readable) or `'no-answer'` (the model wrote no answer); whether it was stopped, the raw event log and its counter |
213
213
  | `modelLoad` | WebLLM download progress, when loading |
214
214
 
215
215
  **Options:** `deps` (rebuild the agent when these change — e.g. on a model
@@ -1397,6 +1397,12 @@ interface AgentUiState {
1397
1397
  * `replan.failed` and `StepView.replanFailed`).
1398
1398
  */
1399
1399
  error?: string;
1400
+ /**
1401
+ * The core's code of a run error a host may want to say in its own words: `'no-plan'` (the
1402
+ * planner returned nothing readable) or `'no-answer'` (the model wrote no answer). Absent for
1403
+ * every other error.
1404
+ */
1405
+ errorCode?: 'no-plan' | 'no-answer';
1400
1406
  /** True when the last run was aborted via stop(). */
1401
1407
  stopped: boolean;
1402
1408
  /** A chat-style transcript built from every run, for chat UIs. */
@@ -1397,6 +1397,12 @@ interface AgentUiState {
1397
1397
  * `replan.failed` and `StepView.replanFailed`).
1398
1398
  */
1399
1399
  error?: string;
1400
+ /**
1401
+ * The core's code of a run error a host may want to say in its own words: `'no-plan'` (the
1402
+ * planner returned nothing readable) or `'no-answer'` (the model wrote no answer). Absent for
1403
+ * every other error.
1404
+ */
1405
+ errorCode?: 'no-plan' | 'no-answer';
1400
1406
  /** True when the last run was aborted via stop(). */
1401
1407
  stopped: boolean;
1402
1408
  /** A chat-style transcript built from every run, for chat UIs. */
package/dist/index.cjs CHANGED
@@ -329,6 +329,7 @@ var createInitialAgentState = () => ({
329
329
  events: [],
330
330
  seq: 0
331
331
  });
332
+ var BLOCKER_MARK = "[BLOCKER]";
332
333
  var resetRun = (state) => ({
333
334
  ...createInitialAgentState(),
334
335
  status: state.status,
@@ -870,7 +871,13 @@ var applyEvent = (state, event, ctx) => {
870
871
  case "step.text-delta":
871
872
  return {
872
873
  ...state,
873
- steps: patchStep(state.steps, event.step.id, (s) => ({ ...s, text: s.text + event.delta }))
874
+ // "[BLOCKER]" is the executor's signal to the core that a step cannot be completed (the
875
+ // core strips it from the step's summary): never a word for the user. Stripped from the
876
+ // text as it accumulates, so a marker split across two deltas goes too.
877
+ steps: patchStep(state.steps, event.step.id, (s) => ({
878
+ ...s,
879
+ text: (s.text + event.delta).split(BLOCKER_MARK).join("")
880
+ }))
874
881
  };
875
882
  case "step.tool-call": {
876
883
  const tagged = new Set(
@@ -1225,6 +1232,7 @@ var applyEvent = (state, event, ctx) => {
1225
1232
  return event.phase === "run" ? {
1226
1233
  ...withoutBusy(keepSubmitted(state)),
1227
1234
  error: event.error,
1235
+ errorCode: event.code,
1228
1236
  messages: finalizeAssistant(
1229
1237
  state.messages,
1230
1238
  state.finalText || `Error: ${event.error}`,
@@ -1306,7 +1314,8 @@ var agentStateReducer = (state, action) => {
1306
1314
  return {
1307
1315
  ...state,
1308
1316
  status: action.status,
1309
- error: action.status === "error" ? action.error : void 0
1317
+ error: action.status === "error" ? action.error : void 0,
1318
+ errorCode: void 0
1310
1319
  };
1311
1320
  case "remote": {
1312
1321
  const remote = action.remote;
@@ -7860,13 +7869,18 @@ var UsageBadge = ({
7860
7869
  const media = showCalls ? usage.mediaCalls ?? 0 : 0;
7861
7870
  const decisions = showCalls ? usage.decisionCalls ?? 0 : 0;
7862
7871
  if (usage.totalTokens === 0 && media === 0 && decisions === 0) return null;
7872
+ const mediaText = media ? L.usageMedia(media, {
7873
+ imagesGenerated: usage.imagesGenerated ?? 0,
7874
+ speechCharacters: usage.speechCharacters ?? 0,
7875
+ transcriptionSeconds: usage.transcriptionSeconds ?? 0
7876
+ }) : "";
7863
7877
  const reasoning = usage.reasoningTokens ?? 0;
7864
7878
  const cached = usage.cachedInputTokens ?? 0;
7865
7879
  const title = [
7866
7880
  `${usage.inputTokens} in + ${usage.outputTokens} out = ${usage.totalTokens} tokens`,
7867
7881
  reasoning ? `${reasoning} thinking` : "",
7868
7882
  cached ? `${cached} input tokens from the prompt cache` : "",
7869
- media ? L.usageMedia(media) : "",
7883
+ mediaText,
7870
7884
  decisions ? L.usageDecisions(decisions) : ""
7871
7885
  ].filter(Boolean).join(" \xB7 ");
7872
7886
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: ["awr-usage", className].filter(Boolean).join(" "), title, children: [
@@ -7876,7 +7890,7 @@ var UsageBadge = ({
7876
7890
  "\u2193",
7877
7891
  !compact && reasoning > 0 && ` \xB7 ${formatTokens(reasoning)} think`,
7878
7892
  !compact && cached > 0 && ` \xB7 ${formatTokens(cached)} cached`,
7879
- !compact && media > 0 && ` \xB7 ${L.usageMedia(media)}`,
7893
+ !compact && mediaText && ` \xB7 ${mediaText}`,
7880
7894
  !compact && decisions > 0 && ` \xB7 ${L.usageDecisions(decisions)}`
7881
7895
  ] });
7882
7896
  };