@superatomai/sdk-node 0.0.53-dsp → 0.0.54-dsp

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
@@ -1696,19 +1696,16 @@ declare const ComponentSchema: z.ZodObject<{
1696
1696
  title: z.ZodOptional<z.ZodString>;
1697
1697
  description: z.ZodOptional<z.ZodString>;
1698
1698
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1699
- actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1700
1699
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
1701
1700
  query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
1702
1701
  title: z.ZodOptional<z.ZodString>;
1703
1702
  description: z.ZodOptional<z.ZodString>;
1704
1703
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1705
- actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1706
1704
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
1707
1705
  query: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>]>>>;
1708
1706
  title: z.ZodOptional<z.ZodString>;
1709
1707
  description: z.ZodOptional<z.ZodString>;
1710
1708
  config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1711
- actions: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
1712
1709
  }, z.ZodTypeAny, "passthrough">>;
1713
1710
  category: z.ZodOptional<z.ZodString>;
1714
1711
  keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -1722,7 +1719,6 @@ declare const ComponentSchema: z.ZodObject<{
1722
1719
  query?: string | {} | null | undefined;
1723
1720
  title?: string | undefined;
1724
1721
  config?: Record<string, unknown> | undefined;
1725
- actions?: any[] | undefined;
1726
1722
  } & {
1727
1723
  [k: string]: unknown;
1728
1724
  };
@@ -1740,7 +1736,6 @@ declare const ComponentSchema: z.ZodObject<{
1740
1736
  query?: string | {} | null | undefined;
1741
1737
  title?: string | undefined;
1742
1738
  config?: Record<string, unknown> | undefined;
1743
- actions?: any[] | undefined;
1744
1739
  } & {
1745
1740
  [k: string]: unknown;
1746
1741
  };
@@ -3027,16 +3022,6 @@ declare class MainAgent {
3027
3022
  getSourceSummaries(): SourceSummary[];
3028
3023
  }
3029
3024
 
3030
- /**
3031
- * Represents an action that can be performed on a UIBlock
3032
- */
3033
- interface Action {
3034
- id: string;
3035
- name: string;
3036
- type: string;
3037
- [key: string]: any;
3038
- }
3039
-
3040
3025
  type SystemPrompt = string | Anthropic.Messages.TextBlockParam[];
3041
3026
  interface LLMMessages {
3042
3027
  sys: SystemPrompt;
@@ -3296,7 +3281,7 @@ declare class UILogCollector {
3296
3281
 
3297
3282
  /**
3298
3283
  * UIBlock represents a single user and assistant message block in a thread
3299
- * Contains user question, component metadata, component data, text response, and available actions
3284
+ * Contains user question, component metadata, component data, and text response
3300
3285
  */
3301
3286
  declare class UIBlock {
3302
3287
  private id;
@@ -3304,7 +3289,6 @@ declare class UIBlock {
3304
3289
  private generatedComponentMetadata;
3305
3290
  private componentData;
3306
3291
  private textResponse;
3307
- private actions;
3308
3292
  private createdAt;
3309
3293
  /**
3310
3294
  * Which script recipe produced this answer, when a script did. Read on the
@@ -3318,11 +3302,10 @@ declare class UIBlock {
3318
3302
  * @param userQuestion - The user's question or input
3319
3303
  * @param componentData - The component data object
3320
3304
  * @param generatedComponentMetadata - Optional metadata about the generated component
3321
- * @param actions - Optional array of available actions
3322
3305
  * @param id - Optional custom ID, generates UUID if not provided
3323
3306
  * @param textResponse - Optional text response from LLM
3324
3307
  */
3325
- constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
3308
+ constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, id?: string, textResponse?: string | null);
3326
3309
  /**
3327
3310
  * Get the UIBlock ID
3328
3311
  */
@@ -3372,38 +3355,6 @@ declare class UIBlock {
3372
3355
  * Set or update text response
3373
3356
  */
3374
3357
  setTextResponse(textResponse: string | null): void;
3375
- /**
3376
- * Get all actions (only if they are resolved, not if fetching)
3377
- */
3378
- getActions(): Action[] | null | Promise<Action[]>;
3379
- /**
3380
- * Get or fetch actions
3381
- * If actions don't exist or are a Promise, calls the generateFn and stores the promise
3382
- * If actions already exist, returns them
3383
- * @param generateFn - Async function to generate actions
3384
- * @returns Promise resolving to Action[]
3385
- */
3386
- getOrFetchActions(generateFn: () => Promise<Action[]>): Promise<Action[]>;
3387
- /**
3388
- * Set or replace all actions
3389
- */
3390
- setActions(actions: Action[]): void;
3391
- /**
3392
- * Add a single action (only if actions are resolved)
3393
- */
3394
- addAction(action: Action): void;
3395
- /**
3396
- * Add multiple actions (only if actions are resolved)
3397
- */
3398
- addActions(actions: Action[]): void;
3399
- /**
3400
- * Remove an action by ID (only if actions are resolved)
3401
- */
3402
- removeAction(actionId: string): boolean;
3403
- /**
3404
- * Clear all actions
3405
- */
3406
- clearActions(): void;
3407
3358
  /** The program-generated half of the answer — see setProgramAnswer. */
3408
3359
  programAnswer?: string | null;
3409
3360
  /**
@@ -3519,8 +3470,23 @@ declare class Thread {
3519
3470
  * since-edited) live body. Owned by the caller (needs a ScriptStore, which
3520
3471
  * Thread doesn't hold) — omit it and every turn falls back to the
3521
3472
  * no-script summary below.
3522
- */
3523
- getConversationContext(limit?: number, currentUIBlockId?: string, getScriptBody?: (recipeId: string, version: number) => Promise<string | null>): Promise<string>;
3473
+ * @param fetchRecentFromDb When provided, this is now the SOURCE OF TRUTH
3474
+ * for history instead of this process's in-memory `uiblocks` map — reads
3475
+ * the persisted `user_conversations` rows (DB `response` jsonb shape, see
3476
+ * transformUIBlockForDB in conversation-saver.ts) via the caller's own
3477
+ * `user-conversations.getRecentForContext` collection. Rows come back
3478
+ * newest-first (already excluding status='aborted' — the query itself
3479
+ * filters that, matching what the in-memory path achieved via
3480
+ * thread.removeUIBlock() on abort). Fixes the standing gap where a backend
3481
+ * restart lost every thread's history (ThreadManager has no DB-backed
3482
+ * rehydration) — DB-backed history survives that, and is correct even if
3483
+ * a different process instance saved the row. Omit it and this falls back
3484
+ * to the in-memory map, for any caller not yet updated.
3485
+ */
3486
+ getConversationContext(limit?: number, currentUIBlockId?: string, getScriptBody?: (recipeId: string, version: number) => Promise<string | null>, fetchRecentFromDb?: (limit: number) => Promise<Array<{
3487
+ userprompt?: string;
3488
+ response?: Record<string, any>;
3489
+ }>>): Promise<string>;
3524
3490
  /**
3525
3491
  * Convert Thread to JSON-serializable object
3526
3492
  */
@@ -4114,21 +4080,20 @@ declare abstract class BaseLLM {
4114
4080
  */
4115
4081
  protected containsFormComponent(component: any): boolean;
4116
4082
  /**
4117
- * Match components from text response suggestions and generate follow-up questions
4083
+ * Match components from text response suggestions
4118
4084
  * Takes a text response with component suggestions (c1:type format) and matches with available components
4119
- * Also generates title, description, and intelligent follow-up questions (actions) based on the analysis
4085
+ * Also generates title and description based on the analysis
4120
4086
  * All components are placed in a default MultiComponentContainer layout
4121
4087
  * @param analysisContent - The text response containing component suggestions
4122
4088
  * @param components - List of available components
4123
4089
  * @param apiKey - Optional API key
4124
4090
  * @param componentStreamCallback - Optional callback to stream primary KPI component as soon as it's identified
4125
- * @returns Object containing matched components, layout title/description, and follow-up actions
4091
+ * @returns Object containing matched components and layout title/description
4126
4092
  */
4127
4093
  matchComponentsFromAnalysis(analysisContent: string, components: Component[], userPrompt: string, apiKey?: string, componentStreamCallback?: (component: Component) => void, deferredTools?: any[], executedTools?: any[], collections?: any, userId?: string): Promise<{
4128
4094
  components: Component[];
4129
4095
  layoutTitle: string;
4130
4096
  layoutDescription: string;
4131
- actions: Action[];
4132
4097
  }>;
4133
4098
  /**
4134
4099
  * Classify user question into category and detect external tools needed
@@ -4177,12 +4142,6 @@ declare abstract class BaseLLM {
4177
4142
  * 3. Route appropriately based on category and response mode
4178
4143
  */
4179
4144
  handleUserRequest(userPrompt: string, components: Component[], apiKey?: string, conversationHistory?: string, responseMode?: 'component' | 'text', streamCallback?: (chunk: string) => void, collections?: any, externalTools?: any[], userId?: string): Promise<T_RESPONSE>;
4180
- /**
4181
- * Generate next questions that the user might ask based on the original prompt and generated component
4182
- * This helps provide intelligent suggestions for follow-up queries
4183
- * For general/conversational questions without components, pass textResponse instead
4184
- */
4185
- generateNextQuestions(originalUserPrompt: string, component?: Component | null, componentData?: Record<string, unknown>, apiKey?: string, conversationHistory?: string, textResponse?: string, signal?: AbortSignal): Promise<string[]>;
4186
4145
  }
4187
4146
 
4188
4147
  interface AnthropicLLMConfig extends BaseLLMConfig {
@@ -4639,40 +4598,67 @@ declare function createCodexSession(opts: CodexSessionOptions): CodingAgentSessi
4639
4598
  * emitAgentEvent('kb-node.changed', { id, op: 'update' })
4640
4599
  *
4641
4600
  * Which agents care, and how many events it takes, is the agents' business.
4601
+ * The emitter therefore speaks the WORLD's vocabulary, never any one agent's —
4602
+ * translating an event into a particular agent's input is `buildInput` below.
4642
4603
  */
4604
+ /** One announced fact, as it reaches a trigger. */
4605
+ interface TriggerEvent {
4606
+ /** The event name passed to emitAgentEvent. */
4607
+ name: string;
4608
+ payload?: unknown;
4609
+ }
4610
+ /**
4611
+ * Turns the events that caused this run into the agent's `input`.
4612
+ *
4613
+ * Takes the whole list, not one payload, because every batching trigger here
4614
+ * fires for MANY events: a debounced burst, or N counted occurrences. Handing
4615
+ * over only the last one silently discarded the rest — five edited nodes became
4616
+ * one.
4617
+ *
4618
+ * Omit it and the agent receives the most recent payload unchanged, which is
4619
+ * the historical behaviour. Any agent that batches should declare one.
4620
+ */
4621
+ type BuildTriggerInput = (events: TriggerEvent[]) => unknown;
4643
4622
  type AgentTrigger =
4644
4623
  /** Only runCodingAgent(). The default. */
4645
4624
  {
4646
4625
  type: 'manual';
4647
4626
  }
4648
- /** Every N milliseconds while the process is up. */
4627
+ /** Every N milliseconds while the process is up. Fires with no events. */
4649
4628
  | {
4650
4629
  type: 'interval';
4651
4630
  everyMs: number;
4631
+ buildInput?: BuildTriggerInput;
4652
4632
  }
4653
4633
  /**
4654
4634
  * On a named event. `debounceMs` collapses a burst into one run — editing
4655
- * five knowledge nodes in a row is one reason to rebuild, not five.
4635
+ * five knowledge nodes in a row is one reason to rebuild, not five. The run
4636
+ * still receives all five events; only the RUNS are collapsed.
4656
4637
  */
4657
4638
  | {
4658
4639
  type: 'event';
4659
4640
  on: string | string[];
4660
4641
  debounceMs?: number;
4642
+ buildInput?: BuildTriggerInput;
4661
4643
  }
4662
4644
  /**
4663
- * Every Nth occurrence of an event. The count is PERSISTED, so "after 10
4645
+ * Every Nth occurrence of an event. The events are PERSISTED, so "after 10
4664
4646
  * questions" survives a restart instead of silently starting over.
4665
4647
  */
4666
4648
  | {
4667
4649
  type: 'count';
4668
4650
  on: string;
4669
4651
  every: number;
4652
+ buildInput?: BuildTriggerInput;
4670
4653
  };
4671
4654
  interface TriggerFireInfo {
4672
4655
  agentId: string;
4673
4656
  /** What set it off, for the log line. */
4674
4657
  reason: string;
4675
- payload?: unknown;
4658
+ /** Everything that caused this run, in arrival order. */
4659
+ events: TriggerEvent[];
4660
+ /** What buildInput produced — exactly what the agent was handed. */
4661
+ input?: unknown;
4676
4662
  }
4677
4663
  /** Notified after every triggered run — for recording history or alerting. */
4678
4664
  type RunListener = (record: AgentRunRecord, info: TriggerFireInfo) => void;
@@ -5002,6 +4988,24 @@ interface RunAgentOptions<TInput> extends AgentRunContext {
5002
4988
  resumeId?: string;
5003
4989
  /** Overrides the definition's prompt entirely. Chat mode: this is the user's message. */
5004
4990
  prompt?: string;
4991
+ /**
4992
+ * A person is typing, rather than a job running.
4993
+ *
4994
+ * For an agent whose mode is 'task' this turns off the JOB — prepare(), the
4995
+ * deliverable contract and apply() are one unit that sets work up and
4996
+ * consumes it, and a conversation should do neither. The turn joins the
4997
+ * workspace as it stands and its answer is the whole result.
4998
+ *
4999
+ * Without this, chatting with a task agent could only ever fail: the user's
5000
+ * message replaces the prompt that names the output path, so the agent never
5001
+ * writes the deliverable, and the run is then reported as an error despite
5002
+ * having answered perfectly well. Worse, prepare() ran on every turn — for a
5003
+ * batching agent that means a chat turn quietly consumed a batch of work.
5004
+ *
5005
+ * An agent whose mode is 'chat' is unaffected: its prepare() is per-turn
5006
+ * context setup, not job setup, so it still runs.
5007
+ */
5008
+ chat?: boolean;
5005
5009
  }
5006
5010
  /**
5007
5011
  * Run one agent, end to end.
@@ -5082,24 +5086,6 @@ interface CodingAgentCollectionConfig {
5082
5086
  }
5083
5087
  declare function registerCodingAgentCollection(sdk: SuperatomSDK, config?: CodingAgentCollectionConfig): void;
5084
5088
 
5085
- /**
5086
- * ScriptMatcher — LLM-Based Script Matching + Parameter Extraction
5087
- *
5088
- * Uses ONE LLM call to:
5089
- * 1. Pick the best matching script from the library (or "none")
5090
- * 2. Extract parameter values from the user question
5091
- *
5092
- * Why LLM over embeddings:
5093
- * - Embeddings capture topic similarity ("overstock" ≈ "inventory" ≈ "revenue")
5094
- * but can't distinguish structurally different questions about the same domain
5095
- * - LLM understands that "overstock by warehouse" needs a different script than
5096
- * "revenue by warehouse" even though they're semantically close
5097
- * - One call does both matching AND parameter extraction
5098
- *
5099
- * When script library grows past ~50, add an embedding pre-filter
5100
- * (ChromaDB narrows to top 10 → LLM picks from those 10).
5101
- */
5102
-
5103
5089
  declare class ScriptMatcher {
5104
5090
  private store;
5105
5091
  private collections?;
@@ -5146,15 +5132,16 @@ declare class ScriptMatcher {
5146
5132
  */
5147
5133
  private buildPromptHistoryCatalog;
5148
5134
  /**
5149
- * The recent script-backed answers in this thread — the bounded set an edit
5150
- * may target. Rendered as its own prompt section (never merged into the
5151
- * ranked catalog) so the `edit` rules have an unambiguous referent set, and
5152
- * numbered newest-first so the prompt's "prefer the most recent when the
5153
- * instruction is ambiguous" tie-break has something to point at.
5135
+ * The most recent script-backed answer in this thread — the one an `edit`
5136
+ * targets. Rendered as its own prompt section (never merged into the ranked
5137
+ * catalog) so the `edit` rules have an unambiguous referent.
5138
+ *
5139
+ * `candidates` holds at most one entry (see doMatch) — `edit` always means
5140
+ * "the answer I just got", so there is nothing else to show here.
5154
5141
  *
5155
- * Each entry carries the QUESTION that produced it plus the columns it
5156
- * returned — that is what lets the matcher resolve "use the mode for the WSP
5157
- * one" instead of blindly taking the newest.
5142
+ * Carries the QUESTION that produced it plus the columns it returned — that
5143
+ * is what lets the matcher resolve "use the mode for the WSP one" against
5144
+ * this one script's own context.
5158
5145
  */
5159
5146
  private buildActiveScriptBlock;
5160
5147
  }
@@ -5393,4 +5380,4 @@ declare class SuperatomSDK {
5393
5380
  getConversationSimilarityThreshold(): number;
5394
5381
  }
5395
5382
 
5396
- export { type Action, type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type CollectionHandler, type CollectionOperation, type DBUIBlock, DEFAULT_AGENT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type Harness, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, type ModelStrategy, type OutputContract, type OutputField, type OutputValidator, type RerankedResult, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, UIBlock, UILogCollector, type User, UserManager, type UsersData, type WorkflowDescriptor, type Workspace, anthropicLLM, assertReadOnlySql, createCodexSession, createCodingAgentSession, dashboardConversationHistory, describeTriggers, emitAgentEvent, geminiLLM, getCodingAgent, getCodingAgentsConfig, groqLLM, hybridRerank, listCodingAgents, llmUsageLogger, logger, normalizeScriptBody, onAgentRun, openaiLLM, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, rerankChromaResults, rerankConversationResults, resolveScriptRecipeStore, runCodingAgent, runScript, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, writeBridgeShims };
5383
+ export { type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, type BuildTriggerInput, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type CollectionHandler, type CollectionOperation, type DBUIBlock, DEFAULT_AGENT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type Harness, type HybridSearchOptions, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, type ModelStrategy, type OutputContract, type OutputField, type OutputValidator, type RerankedResult, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, SuperatomSDK, type SuperatomSDKConfig, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, type TriggerEvent, type TriggerFireInfo, UIBlock, UILogCollector, type User, UserManager, type UsersData, type WorkflowDescriptor, type Workspace, anthropicLLM, assertReadOnlySql, createCodexSession, createCodingAgentSession, dashboardConversationHistory, describeTriggers, emitAgentEvent, geminiLLM, getCodingAgent, getCodingAgentsConfig, groqLLM, hybridRerank, listCodingAgents, llmUsageLogger, logger, normalizeScriptBody, onAgentRun, openaiLLM, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, rerankChromaResults, rerankConversationResults, resolveScriptRecipeStore, runCodingAgent, runScript, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, writeBridgeShims };