drive

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package drive provides an omniskill Skill for Google Drive: reading the comments on a file, and (when explicitly enabled) uploading and updating files.

All Google access goes through gogoogle's driveutil package.

Index

Constants

View Source
const (
	CodeNotFound              = "not_found"
	CodePermissionDenied      = "permission_denied"
	CodeUnsupportedConversion = "unsupported_conversion"
	CodePathOutsideRoot       = "path_outside_root"
	CodeWriteDisabled         = "write_disabled"
	CodeFileTooLarge          = "file_too_large"
	CodeInvalidRequest        = "invalid_request"
	CodeAPIError              = "api_error"
)

Error codes returned by the write tools.

View Source
const DefaultMaxUploadBytes int64 = 50 << 20

DefaultMaxUploadBytes is the largest file the write tools will send.

Variables

This section is empty.

Functions

func WriteDisabledError

func WriteDisabledError() error

WriteDisabledError is the error for a write request when write mode is off.

Types

type Option

type Option func(*Skill)

Option configures a Drive skill.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets the logger that receives the audit record of each write call.

func WithMaxUploadBytes

func WithMaxUploadBytes(n int64) Option

WithMaxUploadBytes sets the largest file the write tools will send.

func WithWrite

func WithWrite(root string) Option

WithWrite turns on the write tools, upload_file and update_file. Local paths they take are confined to root, which must be an existing directory.

type Skill

type Skill struct {
	// contains filtered or unexported fields
}

Skill provides Google Drive tools.

func New

func New(httpClient *http.Client, opts ...Option) *Skill

New creates a Drive skill with the given authenticated HTTP client. By default it is read-only: it registers no tool that can change Google data.

func NewWithService

func NewWithService(svc *driveutil.Service, opts ...Option) *Skill

NewWithService creates a Drive skill that uses an existing gogoogle service, for callers that build the service themselves (tests use a fake endpoint).

func (*Skill) Close

func (s *Skill) Close() error

Close releases resources (no-op for this skill).

func (*Skill) Description

func (s *Skill) Description() string

Description returns what this skill does.

func (*Skill) Init

func (s *Skill) Init(ctx context.Context) error

Init creates the gogoogle Drive service unless one was supplied, and in write mode resolves the upload root, which must be an existing directory.

func (*Skill) Name

func (s *Skill) Name() string

Name returns the skill identifier.

func (*Skill) Tools

func (s *Skill) Tools() []skill.Tool

Tools returns all tools provided by this skill.

The write tools, upload_file and update_file, are present only when the skill was built with WithWrite.

func (*Skill) Version

func (s *Skill) Version() string

Version returns the skill version.

type ToolError

type ToolError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ToolError is a write-tool failure with a stable code. Its text is the JSON {"code": ..., "message": ...}, which the MCP server returns to the client with isError set.

func (*ToolError) Error

func (e *ToolError) Error() string

Jump to

Keyboard shortcuts

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