@smallwebco/tinypivot-mcp 0.4.0 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -207,11 +207,21 @@ interface TraceStep {
207
207
  pivotConfig?: Partial<PivotConfig>;
208
208
  historyId?: string;
209
209
  }
210
+ /** Data the user sends along with a message: a selected row, a drilled-into slice, a view. */
211
+ interface NoteAttachment {
212
+ label: string;
213
+ text: string;
214
+ }
210
215
  interface StudioNote {
211
216
  id: string;
212
217
  at: string;
213
218
  text: string;
219
+ /** A note asks the agent to do something; a question is from the AI Analyst and expects an answer. */
220
+ kind: 'note' | 'question';
214
221
  stepId?: string;
222
+ attachment?: NoteAttachment;
223
+ /** `live` when it went straight into the agent's conversation, `queued` when it waits for the next reply. */
224
+ delivery: 'live' | 'queued';
215
225
  }
216
226
  /** What the browser Studio shows: the trace, notes not yet delivered, and saved pulls. */
217
227
  interface StudioSnapshot {
@@ -224,6 +234,48 @@ interface StudioSnapshot {
224
234
  historyEnabled: boolean;
225
235
  /** Ids of the datasets loaded right now, so a step can open its dataset directly. */
226
236
  loadedIds: string[];
237
+ /** The agent the Studio talks to, and the ways it reaches it live right now (empty when only queued). */
238
+ agent: {
239
+ name?: string;
240
+ live: string[];
241
+ busy: boolean;
242
+ };
243
+ }
244
+
245
+ /**
246
+ * How the Studio reaches the user's own agent. Each harness offers something different:
247
+ * pi's extension and Claude Code's channels put a message into the live conversation, MCP sampling
248
+ * answers with the agent's model outside it, and every other agent gets Studio messages with its
249
+ * next TinyPivot reply. The bridge keeps whichever ways are connected and waits for answers.
250
+ */
251
+ interface ChatTurn {
252
+ role: 'user' | 'assistant';
253
+ content: string;
254
+ }
255
+ interface AgentConnector {
256
+ /** Shown to the user, e.g. "pi" or "Claude Code channel". */
257
+ name: string;
258
+ /** Puts a message into the agent's conversation now. Returns false when it could not. */
259
+ push?: (note: StudioNote, text: string) => boolean;
260
+ /** Answers with the agent's own model, outside the conversation (MCP sampling). */
261
+ complete?: (turns: ChatTurn[]) => Promise<string>;
262
+ }
263
+ declare class AgentBridge {
264
+ private readonly onChange;
265
+ private readonly connectors;
266
+ private readonly waiters;
267
+ constructor(onChange: () => void);
268
+ /** Adds a way to reach the agent; the returned function removes it. */
269
+ connect(connector: AgentConnector): () => void;
270
+ /** Names of the ways that reach the agent right now. */
271
+ live(): string[];
272
+ /** Delivers into the conversation through the first connector that can. */
273
+ push(note: StudioNote, text: string): string | undefined;
274
+ completer(): AgentConnector['complete'];
275
+ /** Resolves with the agent's answer to `id`, or undefined after `ms`. */
276
+ waitForReply(id: string, ms: number): Promise<string | undefined>;
277
+ /** Hands an answer to whoever waits for `re`, or to the oldest waiter when `re` is unknown. */
278
+ answer(text: string, re?: string): boolean;
227
279
  }
228
280
 
229
281
  type DuckDbModule = typeof _duckdb_node_api;
@@ -281,6 +333,10 @@ declare class Studio {
281
333
  private readonly pullsByDataset;
282
334
  private readonly listeners;
283
335
  private changeQueued;
336
+ /** Ways to reach the user's agent: live channels, sampling, or nothing (queued notes). */
337
+ readonly agent: AgentBridge;
338
+ private agentName?;
339
+ private agentBusy;
284
340
  constructor(store: DatasetStore, options?: {
285
341
  history?: HistoryStore;
286
342
  duck?: DuckDbRunner;
@@ -289,6 +345,10 @@ declare class Studio {
289
345
  subscribe(listener: () => void): () => void;
290
346
  private changed;
291
347
  snapshot(sessionKey?: string): StudioSnapshot;
348
+ /** Whether the agent is in the middle of a turn, as its extension reports it. */
349
+ setAgentBusy(busy: boolean): void;
350
+ /** The MCP client's name, e.g. `claude-code`, shown in the Studio. */
351
+ setAgentName(name: string | undefined): void;
292
352
  private get traceFile();
293
353
  private readTraceFile;
294
354
  private appendToTraceFile;
@@ -323,8 +383,33 @@ declare class Studio {
323
383
  sessionKey?: string;
324
384
  record?: boolean;
325
385
  }): Promise<StoredDataset>;
326
- /** Queues a note for the agent; it is delivered with the next TinyPivot reply. */
327
- addNote(text: string, stepId?: string): StudioNote;
386
+ /**
387
+ * Sends the user's message to the agent: straight into its conversation when a live connector
388
+ * takes it, otherwise queued for its next TinyPivot reply.
389
+ */
390
+ addNote(text: string, options?: {
391
+ stepId?: string;
392
+ attachment?: NoteAttachment;
393
+ kind?: StudioNote['kind'];
394
+ }): StudioNote;
395
+ /**
396
+ * How a message reads to the agent: the text, the step it is about, and any attached data.
397
+ * `withSource` says where it came from, for messages that arrive on their own in the conversation.
398
+ */
399
+ describeNote(note: StudioNote, { withSource }?: {
400
+ withSource?: boolean | undefined;
401
+ }): string;
402
+ /**
403
+ * Answers an AI Analyst question with the user's own agent: its model directly when the host
404
+ * offers sampling, otherwise through its conversation, waiting for the reply.
405
+ */
406
+ ask(question: string, options?: {
407
+ turns?: ChatTurn[];
408
+ attachment?: NoteAttachment;
409
+ waitMs?: number;
410
+ }): Promise<string>;
411
+ /** The agent's answer to a Studio message: recorded in the trace and handed to whoever waits for it. */
412
+ reply(text: string, re?: string): TraceStep;
328
413
  /** Drops a queued note the user no longer wants sent. */
329
414
  removeNote(id: string): boolean;
330
415
  pendingNotes(): StudioNote[];
@@ -369,6 +454,8 @@ declare function runInitCommand(args: string[]): Promise<void>;
369
454
  * - Intercepts TinyPivot MCP tool outputs (including nested codemode calls) on `tool_execution_end`
370
455
  * and renders framed charts & pivot tables directly in pi's TUI in full 24-bit ANSI truecolor
371
456
  * using TinyPivot's unified theme palettes (zero extra LLM context tokens).
457
+ * - Connects pi to TinyPivot Studio: Studio messages start a turn here, and the agent's answer
458
+ * goes back to the Studio.
372
459
  * - Registers `/tinypivot-theme [theme-id]` inside pi for instant interactive theme switching
373
460
  * persisted to `~/.config/tinypivot/preferences.json` and synced to the live Studio.
374
461
  */
@@ -408,6 +495,8 @@ interface CreateTinyPivotMcpServerOptions {
408
495
  reprintCards?: boolean;
409
496
  /** The shared trace, history and SQL engine; the CLI passes the same one to the Studio page. */
410
497
  studio?: Studio;
498
+ /** Offer Claude Code channels; defaults to whether Claude Code was started with this server's channel flag. */
499
+ claudeChannel?: boolean;
411
500
  }
412
501
  declare function clientSupportsMcpAppsUi(capabilities?: {
413
502
  extensions?: Record<string, unknown>;
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  startCompanionServer,
34
34
  tokensToUsd,
35
35
  upsertTinyPivotRuleBlock
36
- } from "./chunk-ZZOVYGIU.js";
36
+ } from "./chunk-E6DYPT62.js";
37
37
  import "./chunk-2ESYSVXG.js";
38
38
  export {
39
39
  APP_MIME_TYPE,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@smallwebco/tinypivot-mcp",
3
3
  "mcpName": "io.github.Small-Web-Co/tinypivot",
4
4
  "type": "module",
5
- "version": "0.4.0",
5
+ "version": "0.5.0",
6
6
  "description": "TinyPivot MCP Server, Interactive MCP App & Claude Plugin — turn CSV, JSON, API/MCP outputs, and queries from any database into interactive charts, pivot tables, terminal cards, live TUI, drill-through, and Excel exports inside AI agents.",
7
7
  "author": "Small Web, LLC",
8
8
  "license": "MIT",
@@ -80,9 +80,9 @@
80
80
  "typescript": "~5.6.2",
81
81
  "vite": "^6.4.6",
82
82
  "vite-plugin-singlefile": "^2.2.0",
83
- "@smallwebco/tinypivot-core": "1.4.5",
84
- "@smallwebco/tinypivot-react": "1.4.5",
85
- "@smallwebco/tinypivot-server": "1.4.5"
83
+ "@smallwebco/tinypivot-react": "1.4.6",
84
+ "@smallwebco/tinypivot-core": "1.4.6",
85
+ "@smallwebco/tinypivot-server": "1.4.6"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "pnpm run build:server && pnpm run build:app",
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.Small-Web-Co/tinypivot",
4
4
  "title": "TinyPivot — Data Analysis Studio for AI Agents",
5
5
  "description": "Interactive charts, pivot tables, terminal cards, live TUI, and Excel export inside AI agents.",
6
- "version": "0.4.0",
6
+ "version": "0.5.0",
7
7
  "websiteUrl": "https://tiny-pivot.com",
8
8
  "repository": {
9
9
  "url": "https://github.com/Small-Web-Co/tinypivot",
@@ -14,7 +14,7 @@
14
14
  {
15
15
  "registryType": "npm",
16
16
  "identifier": "@smallwebco/tinypivot-mcp",
17
- "version": "0.4.0",
17
+ "version": "0.5.0",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },