UNPKG

configure

Version:

Identity layer SDK for AI agents

364 lines (362 loc) 14.5 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/tool-definitions.ts var tool_definitions_exports = {}; __export(tool_definitions_exports, { getActionToolNames: () => getActionToolNames, getActionTools: () => getActionTools, getAdvancedTools: () => getAdvancedTools, getConnectorToolNames: () => getConnectorToolNames, getConnectorTools: () => getConnectorTools, getDefaultProfileToolNames: () => getDefaultProfileToolNames, getDefaultProfileTools: () => getDefaultProfileTools, getToolsForOptions: () => getToolsForOptions, getUITools: () => getUITools, isActionToolName: () => isActionToolName, isConnectorToolName: () => isConnectorToolName, toOpenAIFunctions: () => toOpenAIFunctions }); module.exports = __toCommonJS(tool_definitions_exports); function cloneTool(tool) { return { name: tool.name, description: tool.description, input_schema: { ...tool.input_schema, properties: { ...tool.input_schema.properties }, required: tool.input_schema.required ? [...tool.input_schema.required] : void 0 } }; } var DEFAULT_PROFILE_TOOLS = [ { name: "configure_profile_read", description: 'Read compact approved profile context for the current user. Use this for a broad profile overview; use sections ["agents"] to inspect readable agent/source namespaces. This is not a raw file/path reader and not a connector list. Use configure_profile_search for source-attributed memories or facts.', input_schema: { type: "object", properties: { sections: { type: "array", items: { type: "string", enum: ["identity", "preferences", "integrations", "agents", "summary"] }, description: "Optional section filter. Omit to read the approved compact default profile. Allowed values: identity, preferences, integrations, agents, summary. This is not a path selector." } } } }, { name: "configure_profile_search", description: 'Search or list permitted attributed profile data for the current user. Omit query or pass "*" to list bounded permitted compact results. For "what does <source> know about me?", pass query "*" plus source, e.g. "tempo". For relative-date questions, resolve dates first and pass from/to. Compact results omit raw CFS paths; pass detail "full" only when you need inspectable metadata.', input_schema: { type: "object", properties: { query: { type: "string", description: 'Optional search query. Omit or use "*" to list bounded permitted attributed profile results.' }, source: { type: "string", description: 'Optional explicit source handle filter, such as "tempo". This is not a path or connector and there is no magic self value.' }, from: { type: "string", description: "Optional inclusive start date filter in YYYY-MM-DD format for date-attributed results." }, to: { type: "string", description: "Optional inclusive end date filter in YYYY-MM-DD format for date-attributed results." }, limit: { type: "number", description: "Optional maximum result count. The backend enforces a default and hard cap." }, detail: { type: "string", enum: ["compact", "full"], description: "Optional result detail. Defaults to compact. Full includes safe path, markers, provenance, and updated_at metadata." } } } }, { name: "configure_profile_remember", description: "Save one explicit durable user fact, preference, or memory for the current user under the API-key-resolved acting agent handle's namespace. Do not use for raw transcripts or message arrays.", input_schema: { type: "object", properties: { fact: { type: "string", description: "Required explicit durable memory text to save for the current user." } }, required: ["fact"] } } ]; var CONNECTOR_TOOL_BY_CONNECTOR = { gmail: { name: "configure_gmail_search", description: "Search the user's connected Gmail account when Gmail is connected and this connector tool is enabled. Returns email search results, not stored profile memories.", input_schema: { type: "object", properties: { query: { type: "string", description: "Required Gmail search query." }, max_results: { type: "number", description: "Optional maximum result count. The backend enforces a default and hard cap." } }, required: ["query"] } }, calendar: { name: "configure_calendar_get", description: "Get events from the user's connected calendar when Calendar is connected and this connector tool is enabled.", input_schema: { type: "object", properties: { range: { type: "string", enum: ["today", "tomorrow", "week", "month"], description: "Optional bounded calendar range to retrieve. Omit to use week." } } } }, drive: { name: "configure_drive_search", description: "Search the user's connected Google Drive files when Drive is connected and this connector tool is enabled. Returns file search results, not stored profile memories.", input_schema: { type: "object", properties: { query: { type: "string", description: "Required Drive search query." }, max_results: { type: "number", description: "Optional maximum result count. The backend enforces a default and hard cap." } }, required: ["query"] } }, notion: { name: "configure_notion_search", description: "Search the user's connected Notion pages when Notion is connected and this connector tool is enabled. Returns page search results, not stored profile memories.", input_schema: { type: "object", properties: { query: { type: "string", description: "Required Notion search query." }, max_results: { type: "number", description: "Optional maximum result count. The backend enforces a default and hard cap." } }, required: ["query"] } } }; var ACTION_TOOL_BY_ACTION = { "email.send": { name: "configure_email_send", description: "Send an email from the user's connected Gmail account. This is an action and may require user or runtime approval.", input_schema: { type: "object", properties: { to: { type: "string", description: "Required recipient email address." }, subject: { type: "string", description: "Required email subject." }, body: { type: "string", description: "Required email body." } }, required: ["to", "subject", "body"] } }, "calendar.create_event": { name: "configure_calendar_create_event", description: "Create an event in the user's connected calendar. This is an action and may require user or runtime approval.", input_schema: { type: "object", properties: { title: { type: "string", description: "Required event title." }, start_time: { type: "string", description: "Required event start time in ISO 8601 format, including timezone or offset when known." }, end_time: { type: "string", description: "Required event end time in ISO 8601 format, including timezone or offset when known." }, description: { type: "string", description: "Optional event description." }, location: { type: "string", description: "Optional event location." } }, required: ["title", "start_time", "end_time"] } } }; var ADVANCED_COMMIT_TOOL = { name: "configure_profile_commit", description: "Submit bounded source material for a prior Configure profile read/search. This is advanced adapter/runtime plumbing, not a default model tool and not a bulk import tool.", input_schema: { type: "object", properties: { read_id: { type: "string", description: "Optional read id returned by a prior profile read/search when the runtime provides one." }, messages: { type: "array", items: { type: "object" }, description: "Bounded surrounding turn messages to process for durable user memories." }, memories: { type: "array", items: { type: "string" }, description: "Explicit memory candidates to attribute to the API-key-resolved acting agent." } } } }; var ADVANCED_FILE_TOOLS = [ { name: "configure_file_read", description: "Advanced: read a raw profile file path.", input_schema: { type: "object", properties: { path: { type: "string", description: "Profile file path to read." } }, required: ["path"] } }, { name: "configure_file_write", description: "Advanced: write raw content to a profile file path.", input_schema: { type: "object", properties: { path: { type: "string", description: "Profile file path to write." }, content: { type: "string", description: "Content to write." }, type: { type: "string", enum: ["markdown", "json"], description: "Content type." }, mode: { type: "string", enum: ["overwrite", "append", "merge"], description: "Write mode." } }, required: ["path", "content"] } }, { name: "configure_file_list", description: "Advanced: list raw profile files under a profile file path.", input_schema: { type: "object", properties: { path: { type: "string", description: "Profile file path to list." }, depth: { type: "number", description: "Listing depth." }, limit: { type: "number", description: "Maximum number of entries." } } } }, { name: "configure_file_search", description: "Advanced: search raw profile file contents.", input_schema: { type: "object", properties: { query: { type: "string", description: "Search query." }, path: { type: "string", description: "Optional profile file path prefix." }, limit: { type: "number", description: "Maximum number of results." } }, required: ["query"] } }, { name: "configure_file_delete", description: "Advanced: delete a raw profile file path.", input_schema: { type: "object", properties: { path: { type: "string", description: "Profile file path to delete." } }, required: ["path"] } } ]; var UTILITY_TOOLS = [ { name: "configure_web_search", description: "Search the web for current information. This is an opt-in utility, not a connector.", input_schema: { type: "object", properties: { query: { type: "string", description: "Required web search query." }, max_results: { type: "number", description: "Optional maximum result count. The backend enforces a default and hard cap." } }, required: ["query"] } }, { name: "configure_url_fetch", description: "Fetch readable text from a URL. This is an opt-in utility, not a connector.", input_schema: { type: "object", properties: { url: { type: "string", description: "Required URL to fetch." }, max_length: { type: "number", description: "Optional maximum content length. The backend enforces a default and hard cap." } }, required: ["url"] } } ]; function getDefaultProfileTools() { return DEFAULT_PROFILE_TOOLS.map(cloneTool); } function getConnectorTools(connectors = []) { return unique(connectors).map((connector) => cloneTool(CONNECTOR_TOOL_BY_CONNECTOR[connector])); } function getActionTools(actions = []) { return unique(actions).map((action) => cloneTool(ACTION_TOOL_BY_ACTION[action])); } function getAdvancedTools(options = {}) { const tools = []; if (options.commit) tools.push(cloneTool(ADVANCED_COMMIT_TOOL)); if (options.files) tools.push(...ADVANCED_FILE_TOOLS.map(cloneTool)); if (options.utilitySearch) tools.push(...UTILITY_TOOLS.map(cloneTool)); return tools; } function getUITools() { return [ { name: "configure_show_ui_component", description: "Render a Configure-hosted UI component when the host runtime supports UI tools.", input_schema: { type: "object", properties: { component_type: { type: "string", description: "Component type to render." }, props: { type: "object", description: "Component props." } }, required: ["component_type"] } } ]; } function getToolsForOptions(options = {}) { return [ ...getDefaultProfileTools(), ...getConnectorTools(options.connectors), ...getActionTools(options.actions), ...getAdvancedTools(options.advanced) ]; } function toOpenAIFunctions(tools) { return tools.map((tool) => ({ type: "function", function: { name: tool.name, description: tool.description, parameters: tool.input_schema } })); } function isConnectorToolName(name) { return Object.values(CONNECTOR_TOOL_BY_CONNECTOR).some((tool) => tool.name === name); } function isActionToolName(name) { return Object.values(ACTION_TOOL_BY_ACTION).some((tool) => tool.name === name); } function getDefaultProfileToolNames() { return DEFAULT_PROFILE_TOOLS.map((tool) => tool.name); } function getConnectorToolNames() { return Object.values(CONNECTOR_TOOL_BY_CONNECTOR).map((tool) => tool.name); } function getActionToolNames() { return Object.values(ACTION_TOOL_BY_ACTION).map((tool) => tool.name); } function unique(items) { return [...new Set(items)]; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getActionToolNames, getActionTools, getAdvancedTools, getConnectorToolNames, getConnectorTools, getDefaultProfileToolNames, getDefaultProfileTools, getToolsForOptions, getUITools, isActionToolName, isConnectorToolName, toOpenAIFunctions });