@llmnative/agentico 0.16.0 → 0.17.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/README.md CHANGED
@@ -1,116 +1,117 @@
1
- # @llmnative/agentico
2
-
3
- Agentic chat orchestrator for [`@llmnative/react`](https://www.npmjs.com/package/@llmnative/react) apps.
4
-
5
- Agentico is a persistent side panel: the user says what they want, the orchestrator collects the
6
- parameters in conversation and hands the work to a **subagent** registered by the host app. Every
7
- subagent also has a deterministic fallback, so the app keeps working without AI.
8
-
9
- Agentico only orchestrates. The host provides everything concrete: subagents, result
10
- destinations, reports, cross-agent tools, model-facing prompts, user-facing strings and the
11
- current scope (tenant, company, workspace…).
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install @llmnative/agentico @llmnative/react zod
17
- ```
18
-
19
- Requires Node.js 24 LTS, React 19 and `@llmnative/react` ≥ 1.34.
20
-
21
- ## Setup (once, at startup)
22
-
23
- ```tsx
24
- import { App, locales } from '@llmnative/react';
25
- import {
26
- Agentico, AgenticoProvider, AgenticoToggle,
27
- agenticoPromptsIt, agenticoTranslations, configureAgenticoPrompts,
28
- registerCrossAgentTools, registerDestinations, registerSubagents,
29
- } from '@llmnative/agentico';
30
-
31
- registerSubagents([themeSubagent, importSubagent]); // what the orchestrator can hand off to
32
- registerDestinations({ [themeLibrary.id]: themeLibrary }); // where results can be saved
33
- registerCrossAgentTools(({ collected, attachmentsRef, proxyFetch }) => [readSitemapTool(proxyFetch, collected)]);
34
- configureAgenticoPrompts({ // optional: language and host rules for the model
35
- ...agenticoPromptsIt,
36
- responseRules: [...agenticoPromptsIt.responseRules, 'A rule only this app needs.'],
37
- });
38
-
39
- <App
40
- i18n={{ locale: 'it', translations: { it: { ...locales.it, ...agenticoTranslations.it } } }}
41
- /* … */
42
- >
43
- <AgenticoProvider scope={currentCompany && { id: currentCompany.id, dataProvider, storageProvider }}>
44
- <AgenticoToggle /> {/* in the header */}
45
- <Agentico /> {/* the panel */}
46
- </AgenticoProvider>
47
- </App>
48
- ```
49
-
50
- ## Concepts
51
-
52
- | Concept | API |
53
- |---|---|
54
- | **Subagent** — a capability with commands (Zod input), an `AgentDefinition` (prompt, parse, deterministic fallback, tools) and its index route | `defineSubagent`, `registerSubagents`, `SubagentManifest` |
55
- | **Orchestrator** — reads the CLI catalog of the registered subagents, collects parameters, invokes a `<subagent>_<command>` handoff tool | built in |
56
- | **Cross-agent tools** — data-collection tools the orchestrator may call (read a sitemap, a CSV…); complete outputs go to a per-conversation `collected` scratchpad, merged into the handoff by `SubagentManifest.withCollected` | `registerCrossAgentTools` |
57
- | **Result destinations** — where a result can be saved, in the current scope | `registerDestinations`, `ResultDestination` |
58
- | **Reports** — custom result views per subagent | `registerSubagentReports` |
59
- | **Scope** — the host's current tenant/company: id + data and storage providers | `<AgenticoProvider scope>` |
60
- | **Page context** — what the user is looking at, for the orchestrator prompt | `useAgenticoPageContext`, `useSubagentComponentContext` |
61
- | **Files for an executor** — what the person attaches (chosen, dropped, pasted) reaches the turn of a remote agent | `executor.attachments`, `AgentExecutorTurn.attachments` (CR-017) |
62
- | **Going back to a message** — Retry from here and Edit on a message of the person; the chat and the history of the model are cut there | `useAgent().rewind`, `executor.canRewind`, `AgentExecutorTurn.rewound` (CR-016) |
63
- | **No fallback for a chat** — an agent with no result without a model offers only Retry when the model fails | `AgentDefinition.offersFallback: false` (CR-015) |
64
- | **Cards in the chat** — what an agent prepared (e.g. a draft), with View and the actions of the host, their outcome kept | `AgentTool.card`, `executor.turn` `onCard`, `AgentDefinition.onCardAction` (CR-014) |
65
- | **Saved chats** — one chat per saved entity, resumable, known by when it started, kept by the host too (`backend`, `syncEntityChats`, CR-013) | `configureEntityChatStore`, `getEntityChat`, `listEntityChats`, `chatStartedAt` (CR-010); titles written by the model and renamed by the person: `autoTitle`, `chatTitle`, `renameEntityChat`, `onEntityChatsChange` (CR-011) |
66
- | **Approval of tools** — a tool that stops work, spends or cannot be undone runs only after the person approves it, on a question docked at the bottom of the chat (Approve / Reject with a reason) | `AgentTool.needsApproval`, `describeApproval` |
67
- | **Conversational subagents** — a chat with the model and its tools, nothing to apply at the end: each reply a message of the chat, no result preview or destinations | `AgentDefinition.conversational` |
68
- | **Remote subagents** — turns answered by the host (a remote agent with its own memory, e.g. an opencode session), streamed with its steps; its own models in the composer, no fallback | `AgentDefinition.executor` (`AgentExecutor`, `models`, `defaultModel`) |
69
- | **Executor alongside the AI catalog** — one subagent, its tools on the AI catalog and the turns of the executor's models answered by the host (e.g. a harness on a server); both in one picker, grouped with badges | `executor.alongside`, `executor.catalogGroup`, `groupBadge` (CR-009); `executor.catalogProviders(params)` limits the catalog of a chat (CR-010); `executor.catalogReasoning(params, provider)` sets how much it reasons there (CR-012) |
70
- | **Message parts** — a remote reply in parts, as in the Vercel AI SDK / AG-UI: Markdown text (tables, lists, code; repaired while it streams), the reasoning of the model (closed, "Reasoned for 12 s"), the steps grouped and collapsible, questions answered with a click. Answers go back structured: to the waiting turn (`onQuestions` resolves) or as a new turn with `answers`. Parts are saved with the chat; chats saved with text only still load | `AgentExecutorTurn.onText(text, { id?, done? })`, `onReasoning(text, { id?, done?, duration? })`, `onStep`, `onQuestions(questions, { id? })`, `AgentExecutorTurn.answers`, `AgentMessagePart`, `useAgent().answerQuestions` |
71
- | **Panel** — a column beside the page, resizable by dragging its inner edge (or with the arrow keys on it; double click resets), the width kept per browser (`localStorage`, key `agentico:panel-width`). Questions waiting in the latest message of the agent are docked at the bottom in place of the composer, until answered or stopped | `<Agentico defaultWidth minWidth maxWidth onWidthChange>`, `AGENTICO_WIDTH`, `AGENTICO_MIN_WIDTH`, `AGENTICO_MAX_WIDTH` |
72
- | **Direct start** — a page starts a subagent without the orchestrator; with `chatEntityId` its chat is saved at every turn under that entity and resumed from the history; `onlyWhenAnchored` keeps it off the other pages | `useAgentico().startSubagent`, `entityChatTaskId`, `SubagentManifest.chatEntityId`, `SubagentManifest.onlyWhenAnchored` |
73
- | **Controls** — the actions of the prompt of a subagent (e.g. "Finish"), its slash commands (e.g. `/to-spec`, sent as plain text to the executor) and what the host shows above it, from a hook of the host | `registerSubagentControls` |
74
- | **History** — chats per entity, the open one marked, archived on hover (with the host deciding what archiving does) | `SubagentManifest.onArchive`, `confirmArchive` |
75
- | **Prompts** — model-facing text (en default, it included) | `configureAgenticoPrompts`, `agenticoPromptsEn`, `agenticoPromptsIt` |
76
- | **Strings** — user-facing text, namespace `agentico` of the framework i18n (en/it/de) | `agenticoTranslations`, `I18nDict.agentico` |
77
-
78
- ### Controls of a subagent
79
-
80
- ```tsx
81
- import type { EditorCommand } from '@llmnative/react';
82
-
83
- // A module constant keeps its identity; inside the hook use `useMemo`.
84
- const commands: EditorCommand[] = [{ name: 'to-spec', description: 'Turn the design into a spec' }];
85
-
86
- registerSubagentControls({
87
- design: ({ running }) => {
88
- const openFinish = useFinishModal(); // the host's own
89
- return useMemo(() => ({
90
- actions: [{ key: 'finish', label: 'Finish', icon: 'git-pull-request', disabled: running, onClick: openFinish }],
91
- commands,
92
- }), [running, openFinish]);
93
- },
94
- });
95
- ```
96
-
97
- Actions, commands and content must keep their identity while nothing changes: a new one registers
98
- the task again. Typing `/` in the prompt of the task opens the commands; one without `handler`
99
- inserts `/name ` and the message reaches the executor's turn as plain `text` (`"/to-spec checkout"`):
100
- Agentico gives it no meaning. The commands live in the composer, so none are offered while docked
101
- questions take its place.
102
-
103
- ## Development
104
-
105
- ```bash
106
- npm run typecheck
107
- npm test
108
- npm run build
109
- ```
110
-
111
- Changes and releases follow `docs/directives/maintainers/llm-rule-change-release.md` (CR + GitHub
112
- issue + version + npm), tracked in `.notes/`.
113
-
114
- ## License
115
-
116
- Apache-2.0
1
+ # @llmnative/agentico
2
+
3
+ Agentic chat orchestrator for [`@llmnative/react`](https://www.npmjs.com/package/@llmnative/react) apps.
4
+
5
+ Agentico is a persistent side panel: the user says what they want, the orchestrator collects the
6
+ parameters in conversation and hands the work to a **subagent** registered by the host app. Every
7
+ subagent also has a deterministic fallback, so the app keeps working without AI.
8
+
9
+ Agentico only orchestrates. The host provides everything concrete: subagents, result
10
+ destinations, reports, cross-agent tools, model-facing prompts, user-facing strings and the
11
+ current scope (tenant, company, workspace…).
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @llmnative/agentico @llmnative/react zod
17
+ ```
18
+
19
+ Requires Node.js 24 LTS, React 19 and `@llmnative/react` ≥ 1.34.
20
+
21
+ ## Setup (once, at startup)
22
+
23
+ ```tsx
24
+ import { App, locales } from '@llmnative/react';
25
+ import {
26
+ Agentico, AgenticoProvider, AgenticoToggle,
27
+ agenticoPromptsIt, agenticoTranslations, configureAgenticoPrompts,
28
+ registerCrossAgentTools, registerDestinations, registerSubagents,
29
+ } from '@llmnative/agentico';
30
+
31
+ registerSubagents([themeSubagent, importSubagent]); // what the orchestrator can hand off to
32
+ registerDestinations({ [themeLibrary.id]: themeLibrary }); // where results can be saved
33
+ registerCrossAgentTools(({ collected, attachmentsRef, proxyFetch }) => [readSitemapTool(proxyFetch, collected)]);
34
+ configureAgenticoPrompts({ // optional: language and host rules for the model
35
+ ...agenticoPromptsIt,
36
+ responseRules: [...agenticoPromptsIt.responseRules, 'A rule only this app needs.'],
37
+ });
38
+
39
+ <App
40
+ i18n={{ locale: 'it', translations: { it: { ...locales.it, ...agenticoTranslations.it } } }}
41
+ /* … */
42
+ >
43
+ <AgenticoProvider scope={currentCompany && { id: currentCompany.id, dataProvider, storageProvider }}>
44
+ <AgenticoToggle /> {/* in the header */}
45
+ <Agentico /> {/* the panel */}
46
+ </AgenticoProvider>
47
+ </App>
48
+ ```
49
+
50
+ ## Concepts
51
+
52
+ | Concept | API |
53
+ |---|---|
54
+ | **Subagent** — a capability with commands (Zod input), an `AgentDefinition` (prompt, parse, deterministic fallback, tools) and its index route | `defineSubagent`, `registerSubagents`, `SubagentManifest` |
55
+ | **Orchestrator** — reads the CLI catalog of the registered subagents, collects parameters, invokes a `<subagent>_<command>` handoff tool | built in |
56
+ | **Cross-agent tools** — data-collection tools the orchestrator may call (read a sitemap, a CSV…); complete outputs go to a per-conversation `collected` scratchpad, merged into the handoff by `SubagentManifest.withCollected` | `registerCrossAgentTools` |
57
+ | **Result destinations** — where a result can be saved, in the current scope | `registerDestinations`, `ResultDestination` |
58
+ | **Reports** — custom result views per subagent | `registerSubagentReports` |
59
+ | **Scope** — the host's current tenant/company: id + data and storage providers | `<AgenticoProvider scope>` |
60
+ | **Page context** — what the user is looking at, for the orchestrator prompt | `useAgenticoPageContext`, `useSubagentComponentContext` |
61
+ | **Files for an executor** — what the person attaches (chosen, dropped, pasted) reaches the turn of a remote agent | `executor.attachments`, `AgentExecutorTurn.attachments` (CR-017) |
62
+ | **Going back to a message** — Retry from here and Edit on a message of the person; the chat and the history of the model are cut there | `useAgent().rewind`, `executor.canRewind`, `AgentExecutorTurn.rewound` (CR-016) |
63
+ | **No fallback for a chat** — an agent with no result without a model offers only Retry when the model fails | `AgentDefinition.offersFallback: false` (CR-015) |
64
+ | **Cards in the chat** — what an agent prepared (e.g. a draft), with View and the actions of the host, their outcome kept | `AgentTool.card`, `executor.turn` `onCard`, `AgentDefinition.onCardAction` (CR-014) |
65
+ | **Saved chats** — one chat per saved entity, resumable, known by when it started, kept by the host too (`backend`, `syncEntityChats`, CR-013) | `configureEntityChatStore`, `getEntityChat`, `listEntityChats`, `chatStartedAt` (CR-010); titles written by the model and renamed by the person: `autoTitle`, `chatTitle`, `renameEntityChat`, `onEntityChatsChange` (CR-011) |
66
+ | **Approval of tools** — a tool that stops work, spends or cannot be undone runs only after the person approves it, on a question docked at the bottom of the chat (Approve / Reject with a reason) | `AgentTool.needsApproval`, `describeApproval` |
67
+ | **Conversational subagents** — a chat with the model and its tools, nothing to apply at the end: each reply a message of the chat, no result preview or destinations | `AgentDefinition.conversational` |
68
+ | **Remote subagents** — turns answered by the host (a remote agent with its own memory, e.g. an opencode session), streamed with its steps; its own models in the composer, no fallback | `AgentDefinition.executor` (`AgentExecutor`, `models`, `defaultModel`) |
69
+ | **Executor alongside the AI catalog** — one subagent, its tools on the AI catalog and the turns of the executor's models answered by the host (e.g. a harness on a server); both in one picker, grouped with badges | `executor.alongside`, `executor.catalogGroup`, `groupBadge` (CR-009); `executor.catalogProviders(params)` limits the catalog of a chat (CR-010); `executor.catalogReasoning(params, provider)` sets how much it reasons there (CR-012) |
70
+ | **Message parts** — a remote reply in parts, as in the Vercel AI SDK / AG-UI: Markdown text (tables, lists, code; repaired while it streams), the reasoning of the model (closed, "Reasoned for 12 s"), the steps grouped and collapsible, questions answered with a click. Answers go back structured: to the waiting turn (`onQuestions` resolves) or as a new turn with `answers`. Parts are saved with the chat; chats saved with text only still load | `AgentExecutorTurn.onText(text, { id?, done? })`, `onReasoning(text, { id?, done?, duration? })`, `onStep`, `onQuestions(questions, { id? })`, `AgentExecutorTurn.answers`, `AgentMessagePart`, `useAgent().answerQuestions` |
71
+ | **Panel** — a column beside the page, resizable by dragging its inner edge (or with the arrow keys on it; double click resets), the width kept per browser (`localStorage`, key `agentico:panel-width`). Questions waiting in the latest message of the agent are docked at the bottom in place of the composer, until answered or stopped | `<Agentico defaultWidth minWidth maxWidth onWidthChange>`, `AGENTICO_WIDTH`, `AGENTICO_MIN_WIDTH`, `AGENTICO_MAX_WIDTH` |
72
+ | **Sessions of one chat and who speaks** (CR-018) — the saved chats with the same `thread` key are sessions of one chat: the earlier ones above the open one, read-only, loaded as the person scrolls up, each with its own context; the messages of the person carry their name and picture, each turn of the agent starts with its own | `SubagentManifest.thread`, `SubagentManifest.speaker`, `<AgenticoProvider person>`, `chatThreadOf`, `earlierSessions`, `ChatAuthor` |
73
+ | **Direct start** — a page starts a subagent without the orchestrator; with `chatEntityId` its chat is saved at every turn under that entity and resumed from the history; `onlyWhenAnchored` keeps it off the other pages | `useAgentico().startSubagent`, `entityChatTaskId`, `SubagentManifest.chatEntityId`, `SubagentManifest.onlyWhenAnchored` |
74
+ | **Controls** — the actions of the prompt of a subagent (e.g. "Finish"), its slash commands (e.g. `/to-spec`, sent as plain text to the executor) and what the host shows above it, from a hook of the host | `registerSubagentControls` |
75
+ | **History** — chats per entity, the open one marked, archived on hover (with the host deciding what archiving does) | `SubagentManifest.onArchive`, `confirmArchive` |
76
+ | **Prompts** — model-facing text (en default, it included) | `configureAgenticoPrompts`, `agenticoPromptsEn`, `agenticoPromptsIt` |
77
+ | **Strings** — user-facing text, namespace `agentico` of the framework i18n (en/it/de) | `agenticoTranslations`, `I18nDict.agentico` |
78
+
79
+ ### Controls of a subagent
80
+
81
+ ```tsx
82
+ import type { EditorCommand } from '@llmnative/react';
83
+
84
+ // A module constant keeps its identity; inside the hook use `useMemo`.
85
+ const commands: EditorCommand[] = [{ name: 'to-spec', description: 'Turn the design into a spec' }];
86
+
87
+ registerSubagentControls({
88
+ design: ({ running }) => {
89
+ const openFinish = useFinishModal(); // the host's own
90
+ return useMemo(() => ({
91
+ actions: [{ key: 'finish', label: 'Finish', icon: 'git-pull-request', disabled: running, onClick: openFinish }],
92
+ commands,
93
+ }), [running, openFinish]);
94
+ },
95
+ });
96
+ ```
97
+
98
+ Actions, commands and content must keep their identity while nothing changes: a new one registers
99
+ the task again. Typing `/` in the prompt of the task opens the commands; one without `handler`
100
+ inserts `/name ` and the message reaches the executor's turn as plain `text` (`"/to-spec checkout"`):
101
+ Agentico gives it no meaning. The commands live in the composer, so none are offered while docked
102
+ questions take its place.
103
+
104
+ ## Development
105
+
106
+ ```bash
107
+ npm run typecheck
108
+ npm test
109
+ npm run build
110
+ ```
111
+
112
+ Changes and releases follow `docs/directives/maintainers/llm-rule-change-release.md` (CR + GitHub
113
+ issue + version + npm), tracked in `.notes/`.
114
+
115
+ ## License
116
+
117
+ Apache-2.0