Cotton code
47 lines · 2.3 KB · TypeScriptRaw
/** * The generic record tools over every table the personal object holds — the * personal package's and the owner's own made tables (quota, machine) — * plus the todos and the vault. The Rust * handlers are the reference (crates/cotton-tools/src/mcp/handlers/tables, * records_1/todos.rs, secrets.rs, dev.rs). */import type { Handler } from "../context.ts";import { emptyBin, listBin, restoreFromBin } from "./records/bin.ts";import { listChanges, restoreVersionTool, undoTool } from "./records/changes.ts";import { storageSummary, summarizeRecords } from "./records/summary.ts";import { listTools, updateDefinition } from "./records/definition.ts";import { getRecordByTable, listRecords } from "./records/list.ts";import { mergePeople } from "./records/people.ts";import { searchRecords } from "./records/search.ts";import { createSecret, devRevealSecret, listSecrets } from "./records/secrets.ts";import { createTodo, listTodos, updateTodo } from "./records/todos.ts";import { picksOf } from "./records/picks.ts";import { resolveTable, tableArg } from "./records/table.ts";import { createRecord, deleteRecord, updateRecord } from "./records/write.ts";export const RECORDS_HANDLERS: Record<string, Handler> = {  list_records: listRecords,  search_records: searchRecords,  get_record_by_table: getRecordByTable,  // A place picked in the values is read from Cotton's published places first, then copied in (./records/picks.ts).  create_record: async (ctx, args) => createRecord(ctx, args, await picksOf(ctx, resolveTable(ctx, tableArg(args), args.table), args.data)),  update_record: async (ctx, args) => updateRecord(ctx, args, await picksOf(ctx, resolveTable(ctx, tableArg(args), args.table), args.patch)),  delete_record: deleteRecord,  list_bin: listBin,  restore_from_bin: restoreFromBin,  empty_bin: emptyBin,  merge_people: mergePeople,  undo: undoTool,  restore_version: restoreVersionTool,  list_changes: listChanges,  summarize_records: summarizeRecords,  storage_summary: (ctx, args) => storageSummary(ctx, args),  list_tools: (ctx) => listTools(ctx),  update_definition: updateDefinition,  list_todos: listTodos,  create_todo: createTodo,  update_todo: updateTodo,  list_secrets: listSecrets,  create_secret: createSecret,  dev_reveal_secret: devRevealSecret,};