@dudko.dev/agent-web-react 0.0.20 → 0.0.22

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
@@ -15,9 +15,14 @@ app with a single hook and (optionally) a set of pre-styled components:
15
15
  chip and speech to text; saved chats in IndexedDB and a workspace (virtual
16
16
  file system) panel. Everything is a prop: show/hide, labels (i18n), render
17
17
  props, slots, swappable components, theme — see [docs/chat.md](docs/chat.md).
18
+ - 🗣️ **Steering and learning** — type to the agent while it works (`send`,
19
+ `stopSubagent`; queued / delivered notes under the step that got them), and watch
20
+ it keep a notebook: lessons it wrote down as skills (`learned`, `<LearnedSkills>`,
21
+ `forgetSkill`) and the pages it fetched — see
22
+ [docs/chat.md](docs/chat.md#talking-to-the-agent-while-it-works).
18
23
  - 🧩 **Building blocks** — `<AgentComposer>`, `<MessageList>`, `<StepList>`,
19
- `<ToolApprovalPrompt>`, `<ChatHistoryList>`, `<FilesPanel>`, `<ContextMeter>`,
20
- `<ModelLoadBar>`, `<UsageBadge>`, `<ApiKeyForm>`; hooks `useChatHistory`,
24
+ `<ToolApprovalPrompt>`, `<ApprovalModeSwitch>`, `<ChatHistoryList>`, `<FilesPanel>`,
25
+ `<LearnedSkills>`, `<ContextMeter>`, `<PlanView>`, `<ModelLoadBar>`, `<UsageBadge>`, `<ApiKeyForm>`; hooks `useChatHistory`,
21
26
  `useVirtualFiles`, `useSpeechToText`; MCP hooks `useMcp` / `useMcpServers` live in
22
27
  [`@dudko.dev/agent-web-react/mcp`](#mcp-hooks-live-in-their-own-subpath).
23
28
  - 🔑 **`useCredentials`** — store BYOK API keys **encrypted at rest**
@@ -37,7 +42,10 @@ app with a single hook and (optionally) a set of pre-styled components:
37
42
  > one edits a sticky-notes board, one drives any number of MCP servers (plus a
38
43
  > 185-tool mock catalogue to show tool search), and one plays chess against you
39
44
  > — your move triggers it, analyst subagents run in Web Workers. Cloud BYOK or
40
- > local WebGPU, all in your browser. Source in [`demo/`](demo/).
45
+ > local WebGPU, all in your browser. Settings turn on tool consent, thinking, token
46
+ > and step limits, compaction, skills - the agent's own **notebook** (it writes down
47
+ > what it figured out, in the workspace, across reloads) and **web access** limited
48
+ > to hosts you list. Type to the agent while it works. Source in [`demo/`](demo/).
41
49
 
42
50
  ## Install
43
51
 
@@ -170,6 +178,9 @@ function Custom() {
170
178
  | --- | --- |
171
179
  | `run(goal, { images, files, attachments, label })` | Start a run (with attachments); resolves with the `RunResult` |
172
180
  | `stop()` | Abort the in-flight run |
181
+ | `agent` | the core `Agent` itself (or `undefined` until built): `agent.usage` / `agent.sessionUsage()` (tokens spent, counted live), `agent.listLearnedSkills()`, `agent.capabilities` |
182
+ | `forgetSkill(name)` | delete one of the agent's own lessons from its notebook |
183
+ | `sendUndelivered()` / `discardUndelivered()` | send, or drop, what a stopped run never showed the agent |
173
184
  | `send(text)`, `stopSubagent(id)` | Say something to the running agent (shown to the model at its next boundary; the replanner re-checks the plan) / stop one subagent. `queued`, `notes` and `undelivered` show where a message is — see [docs/chat.md](docs/chat.md#talking-to-the-agent-while-it-works) |
174
185
  | `reset()` | Clear the whole conversation (and the agent's memory of it) |
175
186
  | `reload()` | Rebuild the agent (e.g. after storing a new key) |
@@ -184,6 +195,9 @@ function Custom() {
184
195
  | `compact()` | summarise the stored transcript now |
185
196
  | `sessionId` / `loadChat(chat)` | the memory session; switch conversations |
186
197
  | `subagents`, `skills`, `discoveredTools`, `compactions`, `budget` | the rest of the run, folded |
198
+ | `learned`, `learnedNow`, `fetches` | the agent's notebook (`LessonView[]`, survives `reset`), what it wrote this run, and the `web_fetch` requests this run made (`FetchView[]`) |
199
+ | `queued`, `notes`, `undelivered`, `replan` | steering: messages waiting, shown (and where), left over; the last replan decision (`byUser` when a message caused it) |
200
+ | `error`, `stopped`, `events`, `seq` | the run's error text, whether it was stopped, the raw event log and its counter |
187
201
  | `modelLoad` | WebLLM download progress, when loading |
188
202
 
189
203
  **Options:** `deps` (rebuild the agent when these change — e.g. on a model
@@ -421,6 +435,7 @@ use them standalone. The full guide: [docs/chat.md](docs/chat.md).
421
435
  | `<ApprovalModeSwitch>` | Segmented consent-mode switch. |
422
436
  | `<ChatHistoryList>` | Saved chats (from `useChatHistory`). |
423
437
  | `<FilesPanel>` | A `VirtualFileSystem`, live: preview, download, delete, upload. |
438
+ | `<LearnedSkills>` | The agent's notebook (`learning`): its lessons, where each came from, forget. |
424
439
  | `<ContextMeter>` | Tokens by kind, budget bar, last compaction, Compact. |
425
440
  | `<PlanView>` | A plan's reasoning + step list. |
426
441
  | `<ModelLoadBar>` | WebLLM download/init progress. |
@@ -440,6 +455,14 @@ let state = createInitialAgentState()
440
455
  state = agentStateReducer(state, { type: 'event', event }) // fold each AgentEvent
441
456
  ```
442
457
 
458
+ The state is made of plain, exported view types you can render with your own components:
459
+ `StepView` (a step and its `ToolCallView`s), `ApprovalView`, `SubagentView`, `UserNoteView` /
460
+ `QueuedMessageView` (steering), `LessonView` / `FetchView` (the notebook and the pages fetched),
461
+ `BudgetView`, `CompactionView`, `AttachmentView`, `ChatMessage` (a transcript entry that keeps its
462
+ own steps, usage and duration). Outside `<AgentChat>`, `useAgentContext()` returns the controller of
463
+ the enclosing `<AgentProvider>` (it throws outside one; `useOptionalAgentContext()` returns
464
+ `undefined` instead), and `useLabels()` the labels in effect.
465
+
443
466
  ## How it fits together
444
467
 
445
468
  ```
@@ -473,7 +496,10 @@ from one place.
473
496
  kind in the transcript, a chat saved and restored after a reload, an image
474
497
  attached (shown, sent as a file part, saved in the workspace), a file
475
498
  dropped anywhere on the page, consent in "Ask" mode, slash commands, the
476
- chess move that triggers the agent, and Russian labels. The MCP and authorization servers it
499
+ chess move that triggers the agent, and Russian labels; the agent's
500
+ notebook (a lesson written, kept in the workspace across a reload, seen by the
501
+ planner, forgotten on request) and web access (off by default; an allowed page
502
+ is read, a metadata address is refused). The MCP and authorization servers it
477
503
  talks to are started on loopback by [`e2e/servers.ts`](e2e/servers.ts), CORS
478
504
  headers included — so the test also pins the deployment requirement that the
479
505
  challenge header be exposed.
package/dist/index.cjs CHANGED
@@ -35,7 +35,9 @@ __export(src_exports, {
35
35
  FilesPanel: () => FilesPanel,
36
36
  ImagesNotSupportedError: () => import_agent_web4.ImagesNotSupportedError,
37
37
  IndexedDBStore: () => import_agent_web4.IndexedDBStore,
38
+ LearnedSkills: () => LearnedSkills,
38
39
  MemoryCredentialStore: () => import_agent_web4.MemoryCredentialStore,
40
+ MemorySkillStore: () => import_agent_web4.MemorySkillStore,
39
41
  MemoryStore: () => import_agent_web4.MemoryStore,
40
42
  MessageList: () => MessageList,
41
43
  ModelLoadBar: () => ModelLoadBar,
@@ -47,6 +49,7 @@ __export(src_exports, {
47
49
  UsageBadge: () => UsageBadge,
48
50
  UserNoteRow: () => UserNoteRow,
49
51
  VaultCredentialStore: () => import_agent_web4.VaultCredentialStore,
52
+ VfsSkillStore: () => import_agent_web4.VfsSkillStore,
50
53
  VirtualFileSystem: () => import_agent_web4.VirtualFileSystem,
51
54
  agentStateReducer: () => agentStateReducer,
52
55
  attachmentKindOf: () => attachmentKindOf,
@@ -66,6 +69,7 @@ __export(src_exports, {
66
69
  filterCommands: () => filterCommands,
67
70
  formatElapsed: () => formatElapsed,
68
71
  isWebGPUAvailable: () => import_agent_web4.isWebGPUAvailable,
72
+ lessonsOf: () => lessonsOf,
69
73
  loadSkillFromUrl: () => import_agent_web4.loadSkillFromUrl,
70
74
  markReadOnly: () => import_agent_web4.markReadOnly,
71
75
  mergeLabels: () => mergeLabels,
@@ -125,6 +129,13 @@ var addUsage = (a, b) => ({
125
129
  cachedInputTokens: (a.cachedInputTokens ?? 0) + (b.cachedInputTokens ?? 0),
126
130
  cacheWriteTokens: (a.cacheWriteTokens ?? 0) + (b.cacheWriteTokens ?? 0)
127
131
  });
132
+ var lessonsOf = (skills) => skills.filter((s) => s.origin?.kind === "learned").map((s) => ({
133
+ name: s.name,
134
+ description: s.description,
135
+ revision: s.origin?.revision ?? 1,
136
+ chars: s.content.length,
137
+ sources: [...s.origin?.sources ?? [], ...s.origin?.fetched ?? []]
138
+ }));
128
139
  var createInitialAgentState = () => ({
129
140
  status: "idle",
130
141
  goal: void 0,
@@ -142,6 +153,9 @@ var createInitialAgentState = () => ({
142
153
  notes: [],
143
154
  undelivered: [],
144
155
  skills: [],
156
+ learned: [],
157
+ learnedNow: [],
158
+ fetches: [],
145
159
  discoveredTools: [],
146
160
  compactions: [],
147
161
  budget: void 0,
@@ -159,7 +173,8 @@ var resetRun = (state) => ({
159
173
  status: state.status,
160
174
  messages: state.messages,
161
175
  totalUsage: state.totalUsage,
162
- seq: state.seq
176
+ seq: state.seq,
177
+ learned: state.learned
163
178
  });
164
179
  var patchStep = (steps, id, fn) => steps.map((s) => s.id === id ? fn(s) : s);
165
180
  var patchApproval = (approvals, id, fn) => approvals.map((a) => a.id === id ? fn(a) : a);
@@ -485,6 +500,38 @@ var applyEvent = (state, event, ctx) => {
485
500
  };
486
501
  case "skill.activated":
487
502
  return state.skills.includes(event.name) ? state : { ...state, skills: [...state.skills, event.name] };
503
+ case "skill.learned": {
504
+ const before = state.learned.find((l) => l.name === event.name);
505
+ const lesson = {
506
+ name: event.name,
507
+ description: event.description,
508
+ // A rewrite of a lesson we know goes up one; a lesson we never saw (an event for a store
509
+ // loaded before this view existed) starts at 2 when the core says it is an update.
510
+ revision: event.update ? (before?.revision ?? 1) + 1 : 1,
511
+ chars: event.chars,
512
+ sources: event.sources
513
+ };
514
+ return {
515
+ ...state,
516
+ learned: before ? state.learned.map((l) => l.name === event.name ? lesson : l) : [...state.learned, lesson],
517
+ learnedNow: state.learnedNow.includes(event.name) ? state.learnedNow : [...state.learnedNow, event.name]
518
+ };
519
+ }
520
+ case "skill.forgotten":
521
+ return { ...state, learned: state.learned.filter((l) => l.name !== event.name) };
522
+ case "egress.request":
523
+ return {
524
+ ...state,
525
+ fetches: [
526
+ ...state.fetches,
527
+ {
528
+ url: event.url,
529
+ allowed: event.allowed,
530
+ ...event.status !== void 0 ? { status: event.status } : {},
531
+ ...event.reason ? { reason: event.reason } : {}
532
+ }
533
+ ]
534
+ };
488
535
  case "tools.discovered":
489
536
  return {
490
537
  ...state,
@@ -544,6 +591,9 @@ var syncRunMessage = (state) => {
544
591
  if (m.usage !== state.usage) patch.usage = state.usage;
545
592
  if ((m.reasoning ?? "") !== state.finalReasoning) patch.reasoning = state.finalReasoning;
546
593
  if (m.skills !== state.skills) patch.skills = state.skills;
594
+ if (state.learnedNow.length > 0 && m.learned !== state.learnedNow)
595
+ patch.learned = state.learnedNow;
596
+ if (state.fetches.length > 0 && m.fetches !== state.fetches) patch.fetches = state.fetches;
547
597
  if ((m.approvals?.length ?? 0) !== decided.length || decided.some((a, k) => m.approvals?.[k] !== a)) {
548
598
  patch.approvals = decided;
549
599
  }
@@ -555,7 +605,14 @@ var syncRunMessage = (state) => {
555
605
  var agentStateReducer = (state, action) => {
556
606
  switch (action.type) {
557
607
  case "reset":
558
- return { ...createInitialAgentState(), status: state.status, seq: state.seq };
608
+ return {
609
+ ...createInitialAgentState(),
610
+ status: state.status,
611
+ seq: state.seq,
612
+ learned: state.learned
613
+ };
614
+ case "notebook":
615
+ return { ...state, learned: action.lessons };
559
616
  case "status":
560
617
  return {
561
618
  ...state,
@@ -582,7 +639,8 @@ var agentStateReducer = (state, action) => {
582
639
  status: state.status,
583
640
  messages: action.messages.map((m) => m.pending ? { ...m, pending: false } : m),
584
641
  totalUsage: action.totalUsage ?? emptyUsage(),
585
- seq: maxSeq
642
+ seq: maxSeq,
643
+ learned: state.learned
586
644
  };
587
645
  }
588
646
  default:
@@ -657,6 +715,7 @@ var useAgent = (config, options = {}) => {
657
715
  if (cancelled) return;
658
716
  agent.setToolApprovalMode(modeRef.current);
659
717
  agentRef.current = agent;
718
+ dispatch({ type: "notebook", lessons: lessonsOf(agent.listLearnedSkills()) });
660
719
  setBuildStatus({ status: "ready" });
661
720
  }).catch((err) => {
662
721
  if (cancelled) return;
@@ -767,6 +826,14 @@ var useAgent = (config, options = {}) => {
767
826
  },
768
827
  []
769
828
  );
829
+ const forgetSkill = (0, import_react.useCallback)(async (name) => {
830
+ const agent = agentRef.current;
831
+ if (!agent) return false;
832
+ return agent.forgetSkill(
833
+ name,
834
+ (event) => dispatch({ type: "event", event, maxEvents: optionsRef.current.maxEvents, at: Date.now() })
835
+ );
836
+ }, []);
770
837
  const approve = (0, import_react.useCallback)((id, opts) => {
771
838
  const resolve = resolversRef.current.get(id);
772
839
  if (!resolve) return;
@@ -804,6 +871,7 @@ var useAgent = (config, options = {}) => {
804
871
  stop,
805
872
  send,
806
873
  stopSubagent,
874
+ forgetSkill,
807
875
  sendUndelivered,
808
876
  discardUndelivered,
809
877
  reset,
@@ -1393,12 +1461,20 @@ var defaultLabels = {
1393
1461
  toolCalls: (n) => plural(n, "tool call", "tool calls"),
1394
1462
  subagents: (n) => plural(n, "subagent", "subagents"),
1395
1463
  skillsUsed: (names) => `skills: ${names}`,
1464
+ learnedNow: (names) => `learned: ${names}`,
1465
+ fetches: (n) => plural(n, "web request", "web requests"),
1466
+ fetchRefused: (reason) => `refused: ${reason}`,
1396
1467
  answerThoughts: "Thinking about the answer",
1397
1468
  stepThoughts: "Thoughts",
1398
1469
  usageTitle: "Tokens this answer spent, by kind",
1399
1470
  attachments: "Attachments",
1400
1471
  planned: "Plan",
1401
1472
  replanned: (mode, reason) => `Replanned (${mode}): ${reason}`,
1473
+ notebookTitle: "Notebook",
1474
+ notebookEmpty: "The agent has not written any lessons down yet.",
1475
+ notebookForget: "Forget",
1476
+ notebookRevision: (n) => `revision ${n}`,
1477
+ notebookFrom: "from",
1402
1478
  placeholder: "Ask the agent to do something\u2026 ( / for commands, Ctrl+V to paste an image )",
1403
1479
  listening: "Listening\u2026",
1404
1480
  message: "Message",
@@ -1652,6 +1728,14 @@ var HistoryIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtim
1652
1728
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 12a9 9 0 1 0 3-6.7L3 8" }),
1653
1729
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 3v5h5M12 7v5l3 2" })
1654
1730
  ] });
1731
+ var BookIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { ...base(size), className, children: [
1732
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2Z" }),
1733
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 19V5M9 7h6" })
1734
+ ] });
1735
+ var GlobeIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { ...base(size), className, children: [
1736
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "9" }),
1737
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M3 12h18M12 3c3 3.2 3 14.8 0 18M12 3c-3 3.2-3 14.8 0 18" })
1738
+ ] });
1655
1739
  var DownloadIcon = ({ size, className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { ...base(size), className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 3v12m-5-5 5 5 5-5M5 21h14" }) });
1656
1740
 
1657
1741
  // src/components/AgentComposer.tsx
@@ -2913,12 +2997,14 @@ var AttachmentView = ({ attachment: a }) => a.dataUrl && a.mediaType.startsWith(
2913
2997
  a.name
2914
2998
  ] });
2915
2999
  var toolCallCount = (m) => (m.steps ?? []).reduce((n, s) => n + s.toolCalls.length, 0);
2916
- var activitySummary = (m, showToolCalls, L) => {
3000
+ var activitySummary = (m, showToolCalls, showLearned, L) => {
2917
3001
  const steps = m.steps ?? [];
2918
3002
  const parts = [L.steps(steps.length)];
2919
3003
  if (showToolCalls) parts.push(L.toolCalls(toolCallCount(m)));
2920
3004
  if (m.subagents?.length) parts.push(L.subagents(m.subagents.length));
2921
3005
  if (m.skills?.length) parts.push(L.skillsUsed(m.skills.join(", ")));
3006
+ if (showLearned && m.learned?.length) parts.push(L.learnedNow(m.learned.join(", ")));
3007
+ if (showLearned && m.fetches?.length) parts.push(L.fetches(m.fetches.length));
2922
3008
  return parts.join(" \xB7 ");
2923
3009
  };
2924
3010
  var MessageList = ({
@@ -2929,6 +3015,7 @@ var MessageList = ({
2929
3015
  showUsage = true,
2930
3016
  showThoughts = true,
2931
3017
  showNotes = true,
3018
+ showLearned = true,
2932
3019
  onStopSubagent,
2933
3020
  activityOpen = false,
2934
3021
  liveExtra,
@@ -2953,7 +3040,7 @@ var MessageList = ({
2953
3040
  className: `awr-msg awr-msg--${m.role}${m.error ? " awr-msg--error" : ""}${m.pending ? " is-pending" : ""}`,
2954
3041
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "awr-msg__col", children: [
2955
3042
  m.role === "assistant" && hasActivity && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "awr-activity", open: m.pending || activityOpen, children: [
2956
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { className: "awr-activity__summary", children: activitySummary(m, showToolCalls, L) }),
3043
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { className: "awr-activity__summary", children: activitySummary(m, showToolCalls, showLearned, L) }),
2957
3044
  m.pending && liveExtra,
2958
3045
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2959
3046
  StepList,
@@ -2971,6 +3058,25 @@ var MessageList = ({
2971
3058
  labels
2972
3059
  }
2973
3060
  ),
3061
+ showLearned && m.fetches?.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "awr-fetches", children: m.fetches.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3062
+ "li",
3063
+ {
3064
+ className: `awr-fetch${f.allowed ? "" : " awr-fetch--refused"}`,
3065
+ children: [
3066
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(GlobeIcon, { size: 12 }),
3067
+ " ",
3068
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { children: f.url }),
3069
+ " ",
3070
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "awr-fetch__result", children: f.allowed ? f.status ?? "ok" : L.fetchRefused(f.reason ?? "") })
3071
+ ]
3072
+ },
3073
+ i
3074
+ )) }) : null,
3075
+ showLearned && m.learned?.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "awr-learned", children: [
3076
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BookIcon, { size: 12 }),
3077
+ " ",
3078
+ L.learnedNow(m.learned.join(", "))
3079
+ ] }) : null,
2974
3080
  showThoughts && m.reasoning?.trim() && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "awr-thought", children: [
2975
3081
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { children: [
2976
3082
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BrainIcon, { size: 13 }),
@@ -3106,6 +3212,7 @@ var AgentChatInner = ({
3106
3212
  showUsage = true,
3107
3213
  showThoughts = true,
3108
3214
  showNotes = true,
3215
+ showLearned = true,
3109
3216
  stoppableSubagents = true,
3110
3217
  showTotalUsage = true,
3111
3218
  showStatus = true,
@@ -3290,6 +3397,7 @@ var AgentChatInner = ({
3290
3397
  showUsage,
3291
3398
  showThoughts,
3292
3399
  showNotes,
3400
+ showLearned,
3293
3401
  onStopSubagent: stoppableSubagents ? agent.stopSubagent : void 0,
3294
3402
  activityOpen,
3295
3403
  liveExtra,
@@ -3361,9 +3469,59 @@ var AgentChatInner = ({
3361
3469
  );
3362
3470
  };
3363
3471
 
3472
+ // src/components/LearnedSkills.tsx
3473
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3474
+ var LearnedSkills = ({
3475
+ controller,
3476
+ lessons,
3477
+ onForget,
3478
+ showSources = true,
3479
+ empty,
3480
+ hideTitle = false,
3481
+ labels,
3482
+ className
3483
+ }) => {
3484
+ const L = useLabels(labels);
3485
+ const ctx = useOptionalAgentContext();
3486
+ const c = controller ?? ctx;
3487
+ const list = lessons ?? c?.learned ?? [];
3488
+ const forget = onForget === false ? void 0 : onForget ?? c?.forgetSkill;
3489
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: ["awr-notebook", className].filter(Boolean).join(" "), children: [
3490
+ !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("h3", { className: "awr-notebook__title", children: [
3491
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(BookIcon, { size: 14 }),
3492
+ " ",
3493
+ L.notebookTitle,
3494
+ list.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-notebook__count", children: list.length })
3495
+ ] }),
3496
+ list.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-notebook__empty", children: empty ?? L.notebookEmpty }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: "awr-notebook__list", children: list.map((l) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", { className: "awr-lesson", children: [
3497
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "awr-lesson__head", children: [
3498
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { className: "awr-lesson__name", children: l.name }),
3499
+ l.revision > 1 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "awr-lesson__rev", children: L.notebookRevision(l.revision) }),
3500
+ forget && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3501
+ "button",
3502
+ {
3503
+ type: "button",
3504
+ className: "awr-lesson__forget",
3505
+ title: `${L.notebookForget}: ${l.name}`,
3506
+ "aria-label": `${L.notebookForget}: ${l.name}`,
3507
+ onClick: () => void forget(l.name),
3508
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(XIcon, { size: 12 })
3509
+ }
3510
+ )
3511
+ ] }),
3512
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "awr-lesson__when", children: l.description }),
3513
+ showSources && l.sources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "awr-lesson__from", children: [
3514
+ L.notebookFrom,
3515
+ " ",
3516
+ l.sources.join(", ")
3517
+ ] })
3518
+ ] }, l.name)) })
3519
+ ] });
3520
+ };
3521
+
3364
3522
  // src/components/Composer.tsx
3365
3523
  var import_react14 = require("react");
3366
- var import_jsx_runtime14 = require("react/jsx-runtime");
3524
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3367
3525
  var Composer = ({
3368
3526
  onSubmit,
3369
3527
  busy = false,
@@ -3385,7 +3543,7 @@ var Composer = ({
3385
3543
  submit();
3386
3544
  }
3387
3545
  };
3388
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3546
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3389
3547
  "form",
3390
3548
  {
3391
3549
  className: ["awr-composer", className].filter(Boolean).join(" "),
@@ -3394,7 +3552,7 @@ var Composer = ({
3394
3552
  submit();
3395
3553
  },
3396
3554
  children: [
3397
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3555
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3398
3556
  "textarea",
3399
3557
  {
3400
3558
  className: "awr-composer__input",
@@ -3406,23 +3564,23 @@ var Composer = ({
3406
3564
  rows: 1
3407
3565
  }
3408
3566
  ),
3409
- busy ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3567
+ busy ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3410
3568
  "button",
3411
3569
  {
3412
3570
  type: "button",
3413
3571
  className: "awr-composer__btn awr-composer__btn--stop",
3414
3572
  onClick: onStop,
3415
3573
  "aria-label": "Stop",
3416
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(StopIcon, { size: 18 })
3574
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StopIcon, { size: 18 })
3417
3575
  }
3418
- ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3576
+ ) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3419
3577
  "button",
3420
3578
  {
3421
3579
  type: "submit",
3422
3580
  className: "awr-composer__btn",
3423
3581
  disabled: disabled || !text.trim(),
3424
3582
  "aria-label": "Send",
3425
- children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SendIcon, { size: 18 })
3583
+ children: disabled ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SpinnerIcon, { size: 18 }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SendIcon, { size: 18 })
3426
3584
  }
3427
3585
  )
3428
3586
  ]
@@ -3431,17 +3589,17 @@ var Composer = ({
3431
3589
  };
3432
3590
 
3433
3591
  // src/components/PlanView.tsx
3434
- var import_jsx_runtime15 = require("react/jsx-runtime");
3592
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3435
3593
  var PlanView = ({ plan, showThought = true, className }) => {
3436
3594
  if (!plan.steps.length && !plan.thought) return null;
3437
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
3438
- showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
3439
- plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
3595
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: ["awr-plan", className].filter(Boolean).join(" "), children: [
3596
+ showThought && plan.thought.trim() && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "awr-plan__thought", children: plan.thought }),
3597
+ plan.steps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("ol", { className: "awr-plan__steps", children: plan.steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("li", { className: "awr-plan__step", children: step.description }, step.id)) })
3440
3598
  ] });
3441
3599
  };
3442
3600
 
3443
3601
  // src/components/ApprovalModeSwitch.tsx
3444
- var import_jsx_runtime16 = require("react/jsx-runtime");
3602
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3445
3603
  var DEFAULT_LABELS = {
3446
3604
  autopilot: "Autopilot",
3447
3605
  "ask-writes": "Ask before changes",
@@ -3461,13 +3619,13 @@ var ApprovalModeSwitch = ({
3461
3619
  labels,
3462
3620
  disabled,
3463
3621
  className
3464
- }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3622
+ }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3465
3623
  "div",
3466
3624
  {
3467
3625
  className: ["awr-modeswitch", className].filter(Boolean).join(" "),
3468
3626
  role: "radiogroup",
3469
3627
  "aria-label": "Tool consent",
3470
- children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3628
+ children: modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3471
3629
  "button",
3472
3630
  {
3473
3631
  type: "button",
@@ -3486,7 +3644,7 @@ var ApprovalModeSwitch = ({
3486
3644
 
3487
3645
  // src/components/ApiKeyForm.tsx
3488
3646
  var import_react15 = require("react");
3489
- var import_jsx_runtime17 = require("react/jsx-runtime");
3647
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3490
3648
  var ApiKeyForm = ({
3491
3649
  credentials,
3492
3650
  credentialRef,
@@ -3530,16 +3688,16 @@ var ApiKeyForm = ({
3530
3688
  setBusy(false);
3531
3689
  }
3532
3690
  };
3533
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
3534
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "awr-keyform__label", children: [
3691
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: ["awr-keyform", className].filter(Boolean).join(" "), children: [
3692
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "awr-keyform__label", children: [
3535
3693
  label,
3536
- present && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "awr-keyform__saved", children: [
3537
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CheckIcon, { size: 12 }),
3694
+ present && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "awr-keyform__saved", children: [
3695
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CheckIcon, { size: 12 }),
3538
3696
  " stored, encrypted"
3539
3697
  ] })
3540
3698
  ] }),
3541
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-keyform__row", children: [
3542
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3699
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "awr-keyform__row", children: [
3700
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3543
3701
  "input",
3544
3702
  {
3545
3703
  className: "awr-keyform__input",
@@ -3557,7 +3715,7 @@ var ApiKeyForm = ({
3557
3715
  disabled: busy
3558
3716
  }
3559
3717
  ),
3560
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3718
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3561
3719
  "button",
3562
3720
  {
3563
3721
  type: "button",
@@ -3567,7 +3725,7 @@ var ApiKeyForm = ({
3567
3725
  children: "Save"
3568
3726
  }
3569
3727
  ),
3570
- present && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3728
+ present && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3571
3729
  "button",
3572
3730
  {
3573
3731
  type: "button",
@@ -3600,7 +3758,9 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
3600
3758
  FilesPanel,
3601
3759
  ImagesNotSupportedError,
3602
3760
  IndexedDBStore,
3761
+ LearnedSkills,
3603
3762
  MemoryCredentialStore,
3763
+ MemorySkillStore,
3604
3764
  MemoryStore,
3605
3765
  MessageList,
3606
3766
  ModelLoadBar,
@@ -3612,6 +3772,7 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
3612
3772
  UsageBadge,
3613
3773
  UserNoteRow,
3614
3774
  VaultCredentialStore,
3775
+ VfsSkillStore,
3615
3776
  VirtualFileSystem,
3616
3777
  agentStateReducer,
3617
3778
  attachmentKindOf,
@@ -3631,6 +3792,7 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
3631
3792
  filterCommands,
3632
3793
  formatElapsed,
3633
3794
  isWebGPUAvailable,
3795
+ lessonsOf,
3634
3796
  loadSkillFromUrl,
3635
3797
  markReadOnly,
3636
3798
  mergeLabels,