@outlit/pi 0.1.0 → 0.1.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/README.md +2 -1
- package/dist/extension.cjs.map +1 -1
- package/dist/extension.js +1 -0
- package/dist/extension.js.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/outlit/references/sql-reference.md +2 -0
package/README.md
CHANGED
|
@@ -27,8 +27,9 @@ The default extension registers the default customer intelligence tools from `@o
|
|
|
27
27
|
- `outlit_get_fact`
|
|
28
28
|
- `outlit_get_source`
|
|
29
29
|
- `outlit_search_customer_context`
|
|
30
|
+
- `outlit_send_notification`
|
|
30
31
|
|
|
31
|
-
SQL tools are available from `@outlit/tools`, but they are not enabled by default. Integration-management commands are intentionally not part of this package.
|
|
32
|
+
SQL tools are available from `@outlit/tools`, but they are not enabled by default. Notification action tools are included in the default Pi toolset, but they should only be used when the user explicitly asks to send, post, or notify a result. Integration-management commands are intentionally not part of this package.
|
|
32
33
|
|
|
33
34
|
For analytical agents that need cohorts, usage trends, revenue filters, activation gaps, or aggregate checks, import `analyticalAgentToolNames`. It combines the default customer intelligence tools with `outlit_schema` and `outlit_query` without exposing every customer tool:
|
|
34
35
|
|
package/dist/extension.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extension.ts","../src/index.ts"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAQO;AAwIP,IAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/extension.ts","../src/index.ts"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAQO;AAwIP,IAAAA,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IAAI,GAAG;AAC7B,YAAM,IAAI,MAAM,iCAAiC,IAAI,EAAE;AAAA,IACzD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAEA,SAAS,cAAc,SAA2C;AAChE,QAAM,SAAS,gBAAgB,QAAQ,MAAM,KAAK,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC;AAEjG,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,GAAG,kBAAkB,sCAAsC;AAAA,EAC7E;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,SAA2C;AACjE,SACE,gBAAgB,QAAQ,OAAO,KAC/B,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC,KAC/C;AAEJ;AAEA,SAAS,gBAAgB,OAA+C;AACtE,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,mBAAmB,QAA0C;AACpE,MAAI,WAAW,QAAW;AACxB,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG;AAC1E,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AAEA,SAAO;AACT;AAEA,SAAS,iBACP,UACA,QACsC;AACtC,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE,CAAC;AAAA,IACnF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;;;ADvJvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/extension.js
CHANGED
package/dist/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAwIP;AAAA,EACE;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAwIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;AA3IA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAkB3B,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GAAG;AAC/C,SAAG,aAAa,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,oBACd,UAAoC,CAAC,GACX;AAC1B,SAAO,iBAAiB,QAAQ,SAAS,EAAE;AAAA,IAAI,CAAC,aAC9C,mBAAmB,UAAU,OAAO;AAAA,EACtC;AACF;AAEO,SAAS,mBACd,UACA,UAAoC,CAAC,GACb;AACxB,QAAM,WAAW,wBAAwB,QAAQ;AACjD,QAAM,QAAQ,sBAAsB,QAAQ;AAE5C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,aAAa,SAAS;AAAA,IACtB,eAAe,GAAG,KAAK,KAAK,UAAU,SAAS,WAAW,CAAC;AAAA,IAC3D,YAAY,SAAS;AAAA,IACrB,MAAM,QAAQ,aAAa,QAAQ;AACjC,YAAM,SAAS,mBAAmB;AAAA,QAChC,QAAQ,cAAc,OAAO;AAAA,QAC7B,SAAS,eAAe,OAAO;AAAA,QAC/B,OAAO,QAAQ;AAAA,MACjB,CAAC;AACD,YAAM,SAAS,MAAM,OAAO,SAAS,UAAU,mBAAmB,MAAM,CAAC;AAEzE,aAAO,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AAM,EAAE,CAAC;AAAA,IACnF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;;;ACvJvC,IAAO,oBAAQ,wBAAwB;","names":["defaultAgentToolNames"]}
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
OUTLIT_API_KEY_ENV: () => OUTLIT_API_KEY_ENV,
|
|
24
24
|
OUTLIT_API_URL_ENV: () => OUTLIT_API_URL_ENV,
|
|
25
|
+
actionToolNames: () => import_tools2.actionToolNames,
|
|
25
26
|
allCustomerToolNames: () => import_tools2.allCustomerToolNames,
|
|
26
27
|
analyticalAgentToolNames: () => import_tools2.analyticalAgentToolNames,
|
|
27
28
|
createOutlitPiExtension: () => createOutlitPiExtension,
|
|
@@ -121,6 +122,7 @@ var src_default = createOutlitPiExtension();
|
|
|
121
122
|
0 && (module.exports = {
|
|
122
123
|
OUTLIT_API_KEY_ENV,
|
|
123
124
|
OUTLIT_API_URL_ENV,
|
|
125
|
+
actionToolNames,
|
|
124
126
|
allCustomerToolNames,
|
|
125
127
|
analyticalAgentToolNames,
|
|
126
128
|
createOutlitPiExtension,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAQO;AAwIP,IAAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAQO;AAwIP,IAAAA,gBAMO;AA3IA,IAAM,qBA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,IAAI,MAAM,iCAAiC,IAAI,EAAE;AAAA,IACzD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAEA,SAAS,cAAc,SAA2C;AAChE,QAAM,SAAS,gBAAgB,QAAQ,MAAM,KAAK,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC;AAEjG,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,GAAG,kBAAkB,sCAAsC;AAAA,EAC7E;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,SAA2C;AACjE,SACE,gBAAgB,QAAQ,OAAO,KAC/B,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC,KAC/C;AAEJ;AAEA,SAAS,gBAAgB,OAA+C;AACtE,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,mBAAmB,QAA0C;AACpE,MAAI,WAAW,QAAW;AACxB,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG;AAC1E,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AAEA,SAAO;AACT;AAEA,SAAS,iBACP,UACA,QACsC;AACtC,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE,CAAC;AAAA,IACnF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
|
|
2
2
|
import { OutlitToolsFetch, CustomerToolName } from '@outlit/tools';
|
|
3
|
-
export { CustomerToolName, allCustomerToolNames, analyticalAgentToolNames, defaultAgentToolNames, sqlToolNames } from '@outlit/tools';
|
|
3
|
+
export { CustomerToolName, actionToolNames, allCustomerToolNames, analyticalAgentToolNames, defaultAgentToolNames, sqlToolNames } from '@outlit/tools';
|
|
4
4
|
import { TSchema } from '@sinclair/typebox';
|
|
5
5
|
|
|
6
6
|
declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
|
|
2
2
|
import { OutlitToolsFetch, CustomerToolName } from '@outlit/tools';
|
|
3
|
-
export { CustomerToolName, allCustomerToolNames, analyticalAgentToolNames, defaultAgentToolNames, sqlToolNames } from '@outlit/tools';
|
|
3
|
+
export { CustomerToolName, actionToolNames, allCustomerToolNames, analyticalAgentToolNames, defaultAgentToolNames, sqlToolNames } from '@outlit/tools';
|
|
4
4
|
import { TSchema } from '@sinclair/typebox';
|
|
5
5
|
|
|
6
6
|
declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
isCustomerToolName
|
|
8
8
|
} from "@outlit/tools";
|
|
9
9
|
import {
|
|
10
|
+
actionToolNames,
|
|
10
11
|
allCustomerToolNames,
|
|
11
12
|
analyticalAgentToolNames,
|
|
12
13
|
defaultAgentToolNames as defaultAgentToolNames2,
|
|
@@ -97,6 +98,7 @@ var src_default = createOutlitPiExtension();
|
|
|
97
98
|
export {
|
|
98
99
|
OUTLIT_API_KEY_ENV,
|
|
99
100
|
OUTLIT_API_URL_ENV,
|
|
101
|
+
actionToolNames,
|
|
100
102
|
allCustomerToolNames,
|
|
101
103
|
analyticalAgentToolNames,
|
|
102
104
|
createOutlitPiExtension,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAwIP;AAAA,EACE;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema as unknown as TSchema,\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\nexport function formatOutlitToolLabel(toolName: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAwIP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;AA3IA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAkB3B,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GAAG;AAC/C,SAAG,aAAa,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,oBACd,UAAoC,CAAC,GACX;AAC1B,SAAO,iBAAiB,QAAQ,SAAS,EAAE;AAAA,IAAI,CAAC,aAC9C,mBAAmB,UAAU,OAAO;AAAA,EACtC;AACF;AAEO,SAAS,mBACd,UACA,UAAoC,CAAC,GACb;AACxB,QAAM,WAAW,wBAAwB,QAAQ;AACjD,QAAM,QAAQ,sBAAsB,QAAQ;AAE5C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,aAAa,SAAS;AAAA,IACtB,eAAe,GAAG,KAAK,KAAK,UAAU,SAAS,WAAW,CAAC;AAAA,IAC3D,YAAY,SAAS;AAAA,IACrB,MAAM,QAAQ,aAAa,QAAQ;AACjC,YAAM,SAAS,mBAAmB;AAAA,QAChC,QAAQ,cAAc,OAAO;AAAA,QAC7B,SAAS,eAAe,OAAO;AAAA,QAC/B,OAAO,QAAQ;AAAA,MACjB,CAAC;AACD,YAAM,SAAS,MAAM,OAAO,SAAS,UAAU,mBAAmB,MAAM,CAAC;AAEzE,aAAO,iBAAiB,UAAU,MAAM;AAAA,IAC1C;AAAA,EACF;AACF;AAEO,SAAS,sBAAsB,UAAoC;AACxE,SAAO,SACJ,M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AAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;","names":["defaultAgentToolNames"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outlit/pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Pi package for Outlit customer intelligence tools",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Outlit AI",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"test": "vitest run"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@outlit/tools": "^0.1.
|
|
67
|
+
"@outlit/tools": "^0.1.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@mariozechner/pi-coding-agent": "*",
|
|
@@ -24,6 +24,8 @@ sumIf(mrr_cents, billing_status = 'PAYING')
|
|
|
24
24
|
JSONExtractString(properties, 'path')
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Prefer `event_name` when you need the raw tracked event name for include/exclude lists or product workflow analysis, and `event_type` for broader event classes.
|
|
28
|
+
|
|
27
29
|
Use ClickHouse syntax, not MySQL or Postgres helpers like `DATE_SUB()`.
|
|
28
30
|
|
|
29
31
|
## Rules
|