notebook

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package notebook implements all Jupyter notebook tools: file management (create, read, write, edit) and kernel execution (execute, run, kernel).

Index

Constants

View Source
const (
	CreateToolName    = "notebook_create"
	CreateDisplayName = "Create Notebook"
	CreateDescription = `` /* 484-byte string literal not displayed */

)
View Source
const (
	EditToolName    = "notebook_edit"
	EditDisplayName = "Edit Notebook"
	EditDescription = `` /* 877-byte string literal not displayed */

)
View Source
const (
	ExecuteToolName    = "notebook_execute"
	ExecuteDisplayName = "Execute Notebook"
	ExecuteDescription = `` /* 755-byte string literal not displayed */

)
View Source
const (
	KernelToolName    = "notebook_kernel"
	KernelDisplayName = "Manage Kernels"
	KernelDescription = `` /* 655-byte string literal not displayed */

)
View Source
const (
	ReadToolName    = "notebook_read"
	ReadDisplayName = "Read Notebook"
	ReadDescription = `` /* 442-byte string literal not displayed */

)
View Source
const (
	RunToolName    = "notebook_run"
	RunDisplayName = "Run Code in Kernel"
	RunDescription = `` /* 582-byte string literal not displayed */

)
View Source
const (
	WriteToolName    = "notebook_write"
	WriteDisplayName = "Write Notebook"
	WriteDescription = `` /* 498-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type CellSpec

type CellSpec struct {
	CellType string `json:"cell_type"` // "code" or "markdown"
	Source   string `json:"source"`
}

CellSpec describes a single cell for create/write/edit operations.

type CreateTool

type CreateTool struct{}

CreateTool implements notebook_create.

func NewCreateTool

func NewCreateTool() *CreateTool

func (*CreateTool) BackfillInput

func (t *CreateTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*CreateTool) Call

func (t *CreateTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*CreateTool) CheckPermissions

func (t *CreateTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*CreateTool) Definition

func (t *CreateTool) Definition() tool.Definition

func (*CreateTool) Description

func (t *CreateTool) Description(_ context.Context) (string, error)

func (*CreateTool) FormatResult

func (t *CreateTool) FormatResult(data any) string

func (*CreateTool) IsConcurrencySafe

func (t *CreateTool) IsConcurrencySafe(_ map[string]any) bool

func (*CreateTool) IsEnabled

func (t *CreateTool) IsEnabled() bool

func (*CreateTool) IsReadOnly

func (t *CreateTool) IsReadOnly(_ map[string]any) bool

func (*CreateTool) ValidateInput

func (t *CreateTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type EditMode

type EditMode string
const (
	EditModeReplace EditMode = "replace"
	EditModeInsert  EditMode = "insert"
	EditModeDelete  EditMode = "delete"
)

type EditOp

type EditOp struct {
	EditMode  EditMode `json:"edit_mode"`
	CellID    string   `json:"cell_id,omitempty"`
	NewSource string   `json:"new_source,omitempty"`
	CellType  string   `json:"cell_type,omitempty"`
}

type EditTool

type EditTool struct{}

EditTool implements notebook_edit.

func NewEditTool

func NewEditTool() *EditTool

func (*EditTool) BackfillInput

func (t *EditTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*EditTool) Call

func (t *EditTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*EditTool) CheckPermissions

func (t *EditTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*EditTool) Definition

func (t *EditTool) Definition() tool.Definition

func (*EditTool) Description

func (t *EditTool) Description(_ context.Context) (string, error)

func (*EditTool) FormatResult

func (t *EditTool) FormatResult(data any) string

func (*EditTool) IsConcurrencySafe

func (t *EditTool) IsConcurrencySafe(_ map[string]any) bool

func (*EditTool) IsEnabled

func (t *EditTool) IsEnabled() bool

func (*EditTool) IsReadOnly

func (t *EditTool) IsReadOnly(_ map[string]any) bool

func (*EditTool) ValidateInput

func (t *EditTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type ExecuteTool

type ExecuteTool struct{}

ExecuteTool implements notebook_execute.

func NewExecuteTool

func NewExecuteTool() *ExecuteTool

func (*ExecuteTool) BackfillInput

func (t *ExecuteTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*ExecuteTool) Call

func (t *ExecuteTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*ExecuteTool) CheckPermissions

func (t *ExecuteTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*ExecuteTool) Definition

func (t *ExecuteTool) Definition() tool.Definition

func (*ExecuteTool) Description

func (t *ExecuteTool) Description(_ context.Context) (string, error)

func (*ExecuteTool) FormatResult

func (t *ExecuteTool) FormatResult(data any) string

func (*ExecuteTool) IsConcurrencySafe

func (t *ExecuteTool) IsConcurrencySafe(_ map[string]any) bool

func (*ExecuteTool) IsEnabled

func (t *ExecuteTool) IsEnabled() bool

func (*ExecuteTool) IsReadOnly

func (t *ExecuteTool) IsReadOnly(_ map[string]any) bool

func (*ExecuteTool) ValidateInput

func (t *ExecuteTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type KernelTool

type KernelTool struct{}

KernelTool implements notebook_kernel.

func NewKernelTool

func NewKernelTool() *KernelTool

func (*KernelTool) BackfillInput

func (t *KernelTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*KernelTool) Call

func (t *KernelTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*KernelTool) CheckPermissions

func (t *KernelTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*KernelTool) Definition

func (t *KernelTool) Definition() tool.Definition

func (*KernelTool) Description

func (t *KernelTool) Description(_ context.Context) (string, error)

func (*KernelTool) FormatResult

func (t *KernelTool) FormatResult(data any) string

func (*KernelTool) IsConcurrencySafe

func (t *KernelTool) IsConcurrencySafe(_ map[string]any) bool

func (*KernelTool) IsEnabled

func (t *KernelTool) IsEnabled() bool

func (*KernelTool) IsReadOnly

func (t *KernelTool) IsReadOnly(_ map[string]any) bool

func (*KernelTool) ValidateInput

func (t *KernelTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type ReadTool

type ReadTool struct{}

ReadTool implements notebook_read.

func NewReadTool

func NewReadTool() *ReadTool

func (*ReadTool) BackfillInput

func (t *ReadTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*ReadTool) Call

func (*ReadTool) CheckPermissions

func (t *ReadTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*ReadTool) Definition

func (t *ReadTool) Definition() tool.Definition

func (*ReadTool) Description

func (t *ReadTool) Description(_ context.Context) (string, error)

func (*ReadTool) FormatResult

func (t *ReadTool) FormatResult(data any) string

func (*ReadTool) IsConcurrencySafe

func (t *ReadTool) IsConcurrencySafe(_ map[string]any) bool

func (*ReadTool) IsEnabled

func (t *ReadTool) IsEnabled() bool

func (*ReadTool) IsReadOnly

func (t *ReadTool) IsReadOnly(_ map[string]any) bool

func (*ReadTool) ValidateInput

func (t *ReadTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type RunTool

type RunTool struct{}

RunTool implements notebook_run.

func NewRunTool

func NewRunTool() *RunTool

func (*RunTool) BackfillInput

func (t *RunTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*RunTool) Call

func (t *RunTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*RunTool) CheckPermissions

func (t *RunTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*RunTool) Definition

func (t *RunTool) Definition() tool.Definition

func (*RunTool) Description

func (t *RunTool) Description(_ context.Context) (string, error)

func (*RunTool) FormatResult

func (t *RunTool) FormatResult(data any) string

func (*RunTool) IsConcurrencySafe

func (t *RunTool) IsConcurrencySafe(_ map[string]any) bool

func (*RunTool) IsEnabled

func (t *RunTool) IsEnabled() bool

func (*RunTool) IsReadOnly

func (t *RunTool) IsReadOnly(_ map[string]any) bool

func (*RunTool) ValidateInput

func (t *RunTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

type WriteTool

type WriteTool struct{}

WriteTool implements notebook_write.

func NewWriteTool

func NewWriteTool() *WriteTool

func (*WriteTool) BackfillInput

func (t *WriteTool) BackfillInput(_ context.Context, input map[string]any) map[string]any

func (*WriteTool) Call

func (t *WriteTool) Call(ctx context.Context, input tool.CallInput, permissionCheck types.CanUseToolFn) (tool.CallResult, error)

func (*WriteTool) CheckPermissions

func (t *WriteTool) CheckPermissions(_ context.Context, input map[string]any, _ tool.ToolUseContext) types.PermissionResult

func (*WriteTool) Definition

func (t *WriteTool) Definition() tool.Definition

func (*WriteTool) Description

func (t *WriteTool) Description(_ context.Context) (string, error)

func (*WriteTool) FormatResult

func (t *WriteTool) FormatResult(data any) string

func (*WriteTool) IsConcurrencySafe

func (t *WriteTool) IsConcurrencySafe(_ map[string]any) bool

func (*WriteTool) IsEnabled

func (t *WriteTool) IsEnabled() bool

func (*WriteTool) IsReadOnly

func (t *WriteTool) IsReadOnly(_ map[string]any) bool

func (*WriteTool) ValidateInput

func (t *WriteTool) ValidateInput(_ context.Context, input map[string]any) (map[string]any, error)

Directories

Path Synopsis
Package kernel implements an HTTP + WebSocket client for the Jupyter Server REST API.
Package kernel implements an HTTP + WebSocket client for the Jupyter Server REST API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL