@llmnative/agentico 0.12.0 → 0.13.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,6 +1,6 @@
1
1
  import type { z } from 'zod';
2
2
  import type { AIAttachment } from '@llmnative/react';
3
- import type { AgentQuestion, AgentQuestionAnswer, AgentQuestionsAnswers } from './messageParts';
3
+ import type { AgentCard, AgentCardOutcome, AgentCardPart, AgentQuestion, AgentQuestionAnswer, AgentQuestionsAnswers } from './messageParts';
4
4
  /** Rif mutabile, sempre aggiornato da useAgent.ts all'inizio di ogni turno (roundTrip 0) con
5
5
  * gli allegati grezzi (base64) di QUESTO turno — mai un valore statico catturato una volta:
6
6
  * un tool creato da getTools() (chiamato una sola volta per sessione) deve comunque vedere gli
@@ -46,6 +46,8 @@ export interface AgentTool {
46
46
  /** What the tool is about to do, said to the person in the approval (e.g. "Close #141: duplicate of
47
47
  * #139"). Absent = `describeInvocation`, else the name of the tool. */
48
48
  describeApproval?: (input: Record<string, unknown>) => string;
49
+ /** CR-014: a card in the chat once the tool ran (e.g. the draft it wrote, with its actions); none: nothing shown. */
50
+ card?: (input: Record<string, unknown>, output: unknown) => AgentCard | undefined;
49
51
  }
50
52
  export interface AgentDefinition<TParams, TContext, TResult> {
51
53
  /** Gira sempre, con o senza AI — estrazione/parsing deterministico dei dati grezzi. */
@@ -93,6 +95,11 @@ export interface AgentDefinition<TParams, TContext, TResult> {
93
95
  * For an agent that talks and uses tools, with nothing to save at the end. `parseResponse`
94
96
  * still runs on each reply (what `run` and `sendMessage` resolve to). */
95
97
  conversational?: boolean;
98
+ /**
99
+ * CR-014: runs an action of a card of the chat (the host's: open what it drafted, discard it…); its outcome
100
+ * goes into the card, whose buttons are then off. A rejection is shown as an error of the card.
101
+ */
102
+ onCardAction?(params: TParams, card: AgentCardPart, actionId: string): Promise<AgentCardOutcome | undefined>;
96
103
  /** Present = the turns of this agent are answered by the host, not by the AI provider of
97
104
  * Agentico (CR-003): a remote agent with its own memory, for example an opencode session on
98
105
  * a server. `useAgent` then builds no prompt, needs no model and never falls back: it gives
@@ -140,6 +147,8 @@ export interface AgentExecutorTurn<TParams, TContext> {
140
147
  /** A step of the agent: added the first time its id is seen, updated after. Consecutive steps
141
148
  * are shown as one collapsible group. */
142
149
  onStep(step: AgentExecutorStep): void;
150
+ /** CR-014: a card in the message (e.g. what a tool of the host prepared), with its actions. */
151
+ onCard?(card: AgentCard): void;
143
152
  /** Questions to the person, answered with a click (CR-004). The promise resolves with the
144
153
  * answers if they come while this turn is still running (e.g. the session waits for them);
145
154
  * once the turn has ended (or the chat was reloaded), the answers arrive as a new turn with
@@ -63,7 +63,45 @@ export interface AgentQuestionsPart {
63
63
  questions: AgentQuestion[];
64
64
  answers?: AgentQuestionAnswer[];
65
65
  }
66
- export type AgentMessagePart = AgentTextPart | AgentReasoningPart | AgentToolPart | AgentQuestionsPart;
66
+ /** An action of a card (CR-014), run by the host (`AgentDefinition.onCardAction`). */
67
+ export interface AgentCardAction {
68
+ id: string;
69
+ label: string;
70
+ icon?: string;
71
+ variant?: 'primary' | 'outline-primary' | 'outline-secondary' | 'outline-danger';
72
+ }
73
+ /** What came of an action of a card: its buttons are then off. */
74
+ export interface AgentCardOutcome {
75
+ status: 'done' | 'dismissed' | 'error';
76
+ text: string;
77
+ link?: {
78
+ label: string;
79
+ url: string;
80
+ };
81
+ }
82
+ /**
83
+ * A card in a message (CR-014): what the agent prepared for the person (e.g. a draft of a CR) with the actions
84
+ * of the host. `details`: the whole text, opened by Agentico (View) in a side modal; `data`: of the host, given
85
+ * back with an action. Saved with the chat, outcome included.
86
+ */
87
+ export interface AgentCardPart {
88
+ type: 'card';
89
+ id: string;
90
+ title: string;
91
+ badge?: {
92
+ label: string;
93
+ variant?: 'info' | 'light' | 'success' | 'warning' | 'danger';
94
+ };
95
+ /** Markdown: what to read at once. */
96
+ body?: string;
97
+ details?: string;
98
+ actions?: AgentCardAction[];
99
+ data?: Record<string, unknown>;
100
+ outcome?: AgentCardOutcome;
101
+ }
102
+ /** A card as a tool or an executor gives it. */
103
+ export type AgentCard = Omit<AgentCardPart, 'type'>;
104
+ export type AgentMessagePart = AgentTextPart | AgentReasoningPart | AgentToolPart | AgentQuestionsPart | AgentCardPart;
67
105
  /** The id of the text part of an executor that calls `onText` without an id (the reply of CR-003). */
68
106
  export declare const DEFAULT_TEXT_PART_ID = "text";
69
107
  /** The id of the reasoning part of an executor that calls `onReasoning` without an id. */
@@ -45,6 +45,9 @@ export interface AgenticoDict {
45
45
  newInstance: string;
46
46
  chatHistory: string;
47
47
  /** CR-011: renaming a saved chat. */
48
+ /** CR-014: the whole text of a card, and closing it. */
49
+ cardView: string;
50
+ cardClose: string;
48
51
  renameChat: string;
49
52
  chatTitleLabel: string;
50
53
  chatTitleHint: string;
@@ -1,6 +1,6 @@
1
1
  import './i18n/types';
2
2
  export type { AgentDefinition, AgentTool, LatestAttachmentsRef, AgentExecutor, AgentExecutorTurn, AgentExecutorStep, AgentExecutorPartOptions, AgentExecutorModel, AgentModelGroupBadge } from './domain/agentDefinition';
3
- export { DEFAULT_TEXT_PART_ID, DEFAULT_REASONING_PART_ID, upsertMessagePart, messagePartsText, formatQuestionAnswers, type AgentMessagePart, type AgentTextPart, type AgentReasoningPart, type AgentToolPart, type AgentQuestionsPart, type AgentQuestion, type AgentQuestionOption, type AgentQuestionAnswer, type AgentQuestionsAnswers, } from './domain/messageParts';
3
+ export { DEFAULT_TEXT_PART_ID, DEFAULT_REASONING_PART_ID, upsertMessagePart, messagePartsText, formatQuestionAnswers, type AgentMessagePart, type AgentTextPart, type AgentReasoningPart, type AgentToolPart, type AgentQuestionsPart, type AgentCard, type AgentCardPart, type AgentCardAction, type AgentCardOutcome, type AgentQuestion, type AgentQuestionOption, type AgentQuestionAnswer, type AgentQuestionsAnswers, } from './domain/messageParts';
4
4
  export type { SubagentCommand, SubagentManifest, SubagentComponentContext } from './domain/subagentManifest';
5
5
  export { defineSubagent } from './domain/defineSubagent';
6
6
  export { registerSubagents, getSubagentRegistry, findSubagentManifest } from './domain/subagentRegistry';
@@ -1,12 +1,23 @@
1
1
  import type { AgentActivityEntry } from './useAgent';
2
- import type { AgentQuestionAnswer, AgentQuestionsPart } from '../domain/messageParts';
2
+ import type { AgentCardPart, AgentQuestionAnswer, AgentQuestionsPart } from '../domain/messageParts';
3
3
  /** What the log needs to let the person answer questions (CR-004): the entries of the live
4
4
  * conversation (`canAnswer`) and where the answers go. Without it, unanswered questions are shown
5
5
  * disabled. */
6
6
  export interface AgentActivityLogQuestions {
7
7
  canAnswer: (entryId: string) => boolean;
8
8
  onAnswer: (entryId: string, partId: string, answers: AgentQuestionAnswer[]) => Promise<unknown>;
9
+ /** CR-014: an action of a card, run by the host. Without it the actions of the cards are off. */
10
+ onCardAction?: (entryId: string, partId: string, actionId: string) => Promise<unknown>;
9
11
  }
12
+ /**
13
+ * A card of the host in a message (CR-014): its title and badge, what to read at once, View for the whole text
14
+ * (a side modal), the actions of the host in its footer; once one ran, what came of it and the buttons off.
15
+ */
16
+ export declare function CardPart({ entry, part, questions }: {
17
+ entry: AgentActivityEntry;
18
+ part: AgentCardPart;
19
+ questions?: AgentActivityLogQuestions;
20
+ }): import("react").JSX.Element;
10
21
  /** The questions part shown docked at the bottom of the panel instead of in the thread (CR-005). */
11
22
  export interface DockedQuestions {
12
23
  entry: AgentActivityEntry;
@@ -156,11 +156,13 @@ export interface UseAgentResult<TParams, TResult> extends AgentControlState {
156
156
  * answers and shows them read-only. Resolves with the result of that new turn, if any; rejects
157
157
  * (leaving the form open) when another turn is running or the entry is not of this conversation. */
158
158
  answerQuestions: (entryId: string, partId: string, answers: AgentQuestionAnswer[]) => Promise<TResult | null>;
159
+ /** CR-014: an action of a card of the chat, run by the host; its outcome goes into the card. */
160
+ cardAction: (entryId: string, partId: string, actionId: string) => Promise<void>;
159
161
  }
160
162
  /** Solo la fetta di UseAgentResult che serve a un consumer del pannello globale (Agentico.tsx)
161
163
  * per continuare una conversazione già avviata da run() — TParams non compare in nessuno dei
162
164
  * membri qui sotto, quindi `never` è innocuo. */
163
- export type AgentConversation<TResult> = Pick<UseAgentResult<never, TResult>, 'canContinue' | 'remote' | 'remoteModels' | 'alongside' | 'catalogGroup' | 'running' | 'error' | 'activity' | 'sendMessage' | 'stop' | 'runFallback' | 'snapshot' | 'answerQuestions'>;
165
+ export type AgentConversation<TResult> = Pick<UseAgentResult<never, TResult>, 'canContinue' | 'remote' | 'remoteModels' | 'alongside' | 'catalogGroup' | 'running' | 'error' | 'activity' | 'sendMessage' | 'stop' | 'runFallback' | 'snapshot' | 'answerQuestions' | 'cardAction'>;
164
166
  export declare function useAgent<TParams, TContext, TResult>(definition: AgentDefinition<TParams, TContext, TResult>, options?: {
165
167
  defaultEnabled?: boolean;
166
168
  }): UseAgentResult<TParams, TResult>;
package/llms.txt CHANGED
@@ -45,6 +45,7 @@ buildContext (always runs) · buildPrompt · buildFollowUpPrompt · parseRespons
45
45
  `executor.turn({ params, context, text, first, signal, model?, onText(whole reply so far), onStep({ id, label, status }) }) → { text, result? }`; `executor.models(params)` / `defaultModel(params)` put the models of the executor in the composer: the turns go to the host instead of the AI provider; `text` is what the person typed (opening message on the first turn). The conversation is `remote: true`: no attachments, no fallback; the picker shows `remoteModels`.
46
46
  CR-009: `executor.alongside: true` keeps the agent on the AI catalog (prompts, tools, approvals): only the turns whose model is one of `executor.models` go to `executor.turn` (`first` on its first one); the picker shows the executor's models (`{ label, value, group?, groupBadge?: { label, variant? } }`) then the catalog's, grouped by `executor.catalogGroup(provider, label) → { group, badge? }`; `useAgent` gives `alongside`, `catalogGroup`.
47
47
  CR-010: `executor.catalogProviders(params) → string[] | undefined` limits the AI catalog of a chat to those providers (composer and turns; a model of another provider is never used: the executor's first model, else the first allowed one). A saved chat keeps `startedAt` (first save; `chatStartedAt(snapshot)` falls back to `savedAt`); `listEntityChats` lists the last started first and the history shows the start.
48
+ CR-014: cards in messages — part `{ type: 'card', id, title, badge?, body?, details?, actions?: [{ id, label, icon?, variant? }], data?, outcome? }`; `AgentTool.card(input, output)` adds one after the tool ran, `turn.onCard(card)` for an executor; `AgentDefinition.onCardAction(params, card, actionId) → { status: 'done' | 'dismissed' | 'error', text, link? }` (stored in the card, buttons off); View opens `details` in a side modal; `useAgent().cardAction(entryId, partId, actionId)`.
48
49
  CR-013: `configureEntityChatStore({ storageKey, backend })` — `EntityChatBackend { load(scopeId), save(snapshot), remove(scopeId, subagentId, entityId) }`: the browser copy stays (sync reads), writes also go to the backend; `syncEntityChats(scopeId)` (AgenticoProvider on scope change) merges by `changedAt`, drops chats gone remotely, sends never-sent ones; a refused removal comes back.
49
50
  CR-012: `executor.catalogReasoning(params, provider) → 'low' | 'medium' | 'high' | 'max' | undefined`: the turns of the chat on that provider of the catalog send `reasoning` on each request (@llmnative/react 1.46 maps it per provider).
50
51
  CR-011: `SubagentManifest.autoTitle: true` gives its saved chats a title from the model (after a turn; once per session for older ones; a model of the catalog the chat may use), drops conversational chats where the person never wrote; `snapshot.name`/`namedBy`, `chatTitle(snapshot)`, `renameEntityChat(scopeId, subagentId, entityId, title, 'person' | 'model')` (the person's wins; empty resets), `onEntityChatsChange(listener)`; the history has Rename.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmnative/agentico",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Agentic chat orchestrator for @llmnative/react apps: a persistent panel that talks with the user and hands the work to host-registered subagents.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",