@sendbird/actionbook-core 0.8.1 → 0.9.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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2024-2026 Sendbird, Inc. All rights reserved.
2
+
3
+ This software and associated documentation files (the "Software") are the
4
+ proprietary property of Sendbird, Inc. The Software is made available for
5
+ viewing purposes only. No permission is granted to use, copy, modify, merge,
6
+ publish, distribute, sublicense, and/or sell copies of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
9
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
11
+ SENDBIRD, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
12
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
13
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Framework-agnostic core library for Actionbook documents.
4
4
 
5
- ## Installation
5
+ ## Install
6
6
 
7
7
  ```bash
8
8
  npm install @sendbird/actionbook-core
@@ -10,4 +10,4 @@ npm install @sendbird/actionbook-core
10
10
 
11
11
  ## License
12
12
 
13
- Proprietary - Sendbird, Inc. All rights reserved.
13
+ Proprietary see [LICENSE](./LICENSE).
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BlockNode, a as BlockquoteNode, b as BoldMark, L as ListItemNode, c as BulletListNode, C as CodeMark, D as DocumentNode, H as HardBreakNode, I as InlineNode, d as HeadingNode, e as HorizontalRuleNode, f as ItalicMark, J as JinjaIfBranch, g as JinjaIfBlockNode, h as JinjaIfInlineNode, i as JumpPointNode, j as LinkMark, O as OrderedListNode, P as ParagraphNode, R as ResourceTagType, k as ResourceTagNode, S as StrikethroughMark, T as TableRowNode, l as TableNode, m as TableCellNode, M as Mark, n as TextNode, U as UnderlineMark, A as AstNode, N as NodePath, o as LintRule, p as LintContext, q as LintResult, r as LlmLintRule, s as LlmCompletionEndpoint, t as LintSection } from './types-rEXLrfo_.js';
2
- export { u as JSONContent, v as JUMP_POINT_ID_PATTERN, w as LintSeverity, x as RESOURCE_TAG_TYPES, y as fromProseMirrorJSON } from './types-rEXLrfo_.js';
1
+ import { B as BlockNode, a as BlockquoteNode, b as BoldMark, L as ListItemNode, c as BulletListNode, C as CodeMark, D as DocumentNode, H as HardBreakNode, I as InlineNode, d as HeadingNode, e as HorizontalRuleNode, f as ItalicMark, J as JinjaIfBranch, g as JinjaIfBlockNode, h as JinjaIfInlineNode, i as JumpPointNode, j as LinkMark, N as NoteBlockNode, O as OrderedListNode, P as ParagraphNode, R as ResourceTagType, k as ResourceTagNode, S as StrikethroughMark, T as TableRowNode, l as TableNode, m as TableCellNode, M as Mark, n as TextNode, U as UnderlineMark, A as AstNode, o as NodePath, p as LintRule, q as LintContext, r as LintResult, s as LlmLintRule, t as LlmCompletionEndpoint, u as LintSection } from './types-DK_GhIWZ.js';
2
+ export { v as JSONContent, w as JUMP_POINT_ID_PATTERN, x as LintSeverity, y as RESOURCE_TAG_TYPES, z as fromProseMirrorJSON } from './types-DK_GhIWZ.js';
3
3
  import { Root } from 'mdast';
4
4
 
5
5
  declare const bold: () => BoldMark;
@@ -21,6 +21,7 @@ declare function listItem(checked: boolean | null, ...content: BlockNode[]): Lis
21
21
  declare const todoItem: (checked: boolean, ...content: BlockNode[]) => ListItemNode;
22
22
  declare const blockquote: (...content: BlockNode[]) => BlockquoteNode;
23
23
  declare const horizontalRule: () => HorizontalRuleNode;
24
+ declare const noteBlock: (...content: BlockNode[]) => NoteBlockNode;
24
25
  declare const tableCell: (header: boolean, ...content: InlineNode[]) => TableCellNode;
25
26
  declare const tableRow: (...cells: TableCellNode[]) => TableRowNode;
26
27
  declare const table: (...rows: TableRowNode[]) => TableNode;
@@ -222,6 +223,15 @@ declare function collectAllVariables(structures: JinjaIfStructure[]): Variable[]
222
223
  */
223
224
  declare function evaluateCondition(condition: string, variables: Map<string, VariableValue>): boolean | null;
224
225
 
226
+ type HighlightCategory = 'variable' | 'operator' | 'value' | 'punctuation';
227
+ interface ConditionToken {
228
+ readonly text: string;
229
+ readonly start: number;
230
+ readonly end: number;
231
+ readonly category: HighlightCategory;
232
+ }
233
+ declare function tokenizeCondition(input: string): ConditionToken[];
234
+
225
235
  /**
226
236
  * Evaluate Jinja if-block AST nodes by selecting the first truthy branch.
227
237
  * Post-processes adjacent same-type lists to merge and renumber.
@@ -338,6 +348,30 @@ interface BranchDecision {
338
348
  contextRequirements?: Record<string, string>;
339
349
  }
340
350
 
351
+ /**
352
+ * Extract a hierarchical tree structure from a DocumentNode for the preview tree view.
353
+ *
354
+ * Walks the AST and produces a tree of:
355
+ * - Headings (H1/H2 as sections, H3-H6 as subsections)
356
+ * - Jump points with their IDs
357
+ * - Jinja if blocks with condition branches
358
+ * - Resource tags (tool, handoff, etc.)
359
+ */
360
+
361
+ type DocumentTreeNodeType = 'heading' | 'jumpPoint' | 'jinjaIf' | 'jinjaBranch' | 'resourceTag' | 'noteBlock' | 'endAction';
362
+ interface DocumentTreeNode {
363
+ readonly type: DocumentTreeNodeType;
364
+ readonly label: string;
365
+ readonly blockIndex: number;
366
+ readonly children: readonly DocumentTreeNode[];
367
+ readonly meta?: Record<string, unknown>;
368
+ }
369
+ /**
370
+ * Build a document outline tree from a DocumentNode.
371
+ * Extracts both structured jinjaIfBlock nodes and text-based {% if %} patterns.
372
+ */
373
+ declare function buildDocumentTree(doc: DocumentNode): DocumentTreeNode[];
374
+
341
375
  /**
342
376
  * Tree Generator for Actionbook Decision Trees
343
377
  *
@@ -390,4 +424,4 @@ declare function actionbookToAST(manual: {
390
424
  logic: LogicV2;
391
425
  }): DocumentNode;
392
426
 
393
- export { ActionbookConversionError, type ActionbookJSON, AstNode, BlockNode, BlockquoteNode, BoldMark, type BranchDecision, BulletListNode, CodeMark, type DecisionTree, type DeleteOp, DeserializationError, DocumentNode, type EnumeratePathsIterOptions, type GotoEdge, type GotoEntryResolution, HardBreakNode, HeadingNode, HorizontalRuleNode, InlineNode, type InsertOp, ItalicMark, type JinjaBlock, JinjaIfBlockNode, JinjaIfBranch, JinjaIfInlineNode, type JinjaIfStructure, type JinjaVisualBranch, type JinjaVisualStructure, JumpPointNode, LinkMark, type LintAsyncOptions, LintContext, LintResult, LintRule, LintSection, ListItemNode, LlmCompletionEndpoint, LlmLintRule, Mark, NodePath, type Operation, OperationError, OrderedListNode, ParagraphNode, type ParseMarkdownOptions, type ReplaceOp, ResourceTagNode, ResourceTagType, StrikethroughMark, TableCellNode, TableNode, TableRowNode, TextNode, type Transaction, type TreeNode, type TreeNodeClassification, type TreeNodeLine, type TreeNodeType, type TreePath, type TreeSection, UnderlineMark, type ValidationError, type Variable, type VariableValue, type VisitOptions, actionbookToAST, analyzeJinjaBlocks, applyOperation, applyTransaction, blockquote, bold, bulletList, chunkByHeading, code, collectAllVariables, comparePaths, defaultLlmRules, defaultRules, deserializeFromJSON, doc, enumeratePaths, enumeratePathsBySection, enumeratePathsIter, evaluateCondition, evaluateJinjaNodes, extractResourceTags, extractVariables, findAll, findDuplicateJumpPoints, fromMdast, generateDecisionTree, hardBreak, heading, horizontalRule, invertOperation, isBlock, isDocument, isInline, isTextNode, italic, jinjaBranch, jinjaIfBlock, jinjaIfInline, jumpPoint, link, lint, lintAsync, listItem, map, nodeAtPath, orderedList, paragraph, parentPath, parseFragment, parseMarkdown, pathFromString, pathToString, resolveGotoEntryPath, resourceTag, scanJinjaBlocks, serializeFragment, serializeToJSON, serializeToMarkdown, strikethrough, structureJinjaBlocks, table, tableCell, tableRow, text, textContent, toMdast, todoItem, underline, validate, visit };
427
+ export { ActionbookConversionError, type ActionbookJSON, AstNode, BlockNode, BlockquoteNode, BoldMark, type BranchDecision, BulletListNode, CodeMark, type ConditionToken, type DecisionTree, type DeleteOp, DeserializationError, DocumentNode, type DocumentTreeNode, type DocumentTreeNodeType, type EnumeratePathsIterOptions, type GotoEdge, type GotoEntryResolution, HardBreakNode, HeadingNode, type HighlightCategory, HorizontalRuleNode, InlineNode, type InsertOp, ItalicMark, type JinjaBlock, JinjaIfBlockNode, JinjaIfBranch, JinjaIfInlineNode, type JinjaIfStructure, type JinjaVisualBranch, type JinjaVisualStructure, JumpPointNode, LinkMark, type LintAsyncOptions, LintContext, LintResult, LintRule, LintSection, ListItemNode, LlmCompletionEndpoint, LlmLintRule, Mark, NodePath, NoteBlockNode, type Operation, OperationError, OrderedListNode, ParagraphNode, type ParseMarkdownOptions, type ReplaceOp, ResourceTagNode, ResourceTagType, StrikethroughMark, TableCellNode, TableNode, TableRowNode, TextNode, type Transaction, type TreeNode, type TreeNodeClassification, type TreeNodeLine, type TreeNodeType, type TreePath, type TreeSection, UnderlineMark, type ValidationError, type Variable, type VariableValue, type VisitOptions, actionbookToAST, analyzeJinjaBlocks, applyOperation, applyTransaction, blockquote, bold, buildDocumentTree, bulletList, chunkByHeading, code, collectAllVariables, comparePaths, defaultLlmRules, defaultRules, deserializeFromJSON, doc, enumeratePaths, enumeratePathsBySection, enumeratePathsIter, evaluateCondition, evaluateJinjaNodes, extractResourceTags, extractVariables, findAll, findDuplicateJumpPoints, fromMdast, generateDecisionTree, hardBreak, heading, horizontalRule, invertOperation, isBlock, isDocument, isInline, isTextNode, italic, jinjaBranch, jinjaIfBlock, jinjaIfInline, jumpPoint, link, lint, lintAsync, listItem, map, nodeAtPath, noteBlock, orderedList, paragraph, parentPath, parseFragment, parseMarkdown, pathFromString, pathToString, resolveGotoEntryPath, resourceTag, scanJinjaBlocks, serializeFragment, serializeToJSON, serializeToMarkdown, strikethrough, structureJinjaBlocks, table, tableCell, tableRow, text, textContent, toMdast, todoItem, tokenizeCondition, underline, validate, visit };