@outlit/pi 4.0.0 → 4.0.2
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/dist/extension.cjs +2 -2
- package/dist/extension.cjs.map +1 -1
- package/dist/extension.js +2 -2
- package/dist/extension.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/extension.cjs
CHANGED
|
@@ -30,7 +30,7 @@ var import_tools = require("@outlit/tools");
|
|
|
30
30
|
// package.json
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "@outlit/pi",
|
|
33
|
-
version: "4.0.
|
|
33
|
+
version: "4.0.2",
|
|
34
34
|
description: "Pi package for Outlit customer intelligence tools and skill guidance",
|
|
35
35
|
license: "Apache-2.0",
|
|
36
36
|
author: "Outlit AI",
|
|
@@ -96,7 +96,7 @@ var package_default = {
|
|
|
96
96
|
test: "vitest run"
|
|
97
97
|
},
|
|
98
98
|
dependencies: {
|
|
99
|
-
"@outlit/tools": "^4.
|
|
99
|
+
"@outlit/tools": "^4.1.0"
|
|
100
100
|
},
|
|
101
101
|
peerDependencies: {
|
|
102
102
|
"@mariozechner/pi-coding-agent": "*",
|
package/dist/extension.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extension.ts","../src/index.ts","../package.json"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.0\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAcO;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;AAAA,IACJ,YAAc;AAAA,MACZ;AAAA,IACF;AAAA,IACA,QAAU;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,WAAa;AAAA,IACb,MAAQ;AAAA,EACV;AAAA,EACA,cAAgB;AAAA,IACd,iBAAiB;AAAA,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BAAwB;;;AD1SvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
|
1
|
+
{"version":3,"sources":["../src/extension.ts","../src/index.ts","../package.json"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.2\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.1.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAcO;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;AAAA,IACJ,YAAc;AAAA,MACZ;AAAA,IACF;AAAA,IACA,QAAU;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,I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,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;;;AD1SvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/extension.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@outlit/pi",
|
|
16
|
-
version: "4.0.
|
|
16
|
+
version: "4.0.2",
|
|
17
17
|
description: "Pi package for Outlit customer intelligence tools and skill guidance",
|
|
18
18
|
license: "Apache-2.0",
|
|
19
19
|
author: "Outlit AI",
|
|
@@ -79,7 +79,7 @@ var package_default = {
|
|
|
79
79
|
test: "vitest run"
|
|
80
80
|
},
|
|
81
81
|
dependencies: {
|
|
82
|
-
"@outlit/tools": "^4.
|
|
82
|
+
"@outlit/tools": "^4.1.0"
|
|
83
83
|
},
|
|
84
84
|
peerDependencies: {
|
|
85
85
|
"@mariozechner/pi-coding-agent": "*",
|
package/dist/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.0\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EAGA;AAAA,OACK;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;AAAA,IACJ,YAAc;AAAA,MACZ;AAAA,IACF;AAAA,IACA,QAAU;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP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AS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;;;AE1SvC,IAAO,oBAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.2\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.1.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EAGA;AAAA,OACK;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAA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,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS,EAAE,UAAU,QAAQ,OAAO,GAAG,YAAY,MAAM,MAAM,SAAS,EAAE;AAAA,EAC5E;AACF;AAEA,SAAS,YACP,MACA,mBAC0C;AAC1C,QAAM,YAAY,MAAM,aAAa;AACrC,SAAO;AAAA,IACL,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,IACjC,GAAI,MAAM,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EACnD;AACF;AAEA,SAAS,iBACP,UACA,QACA,MACsC;AACtC,QAAM,UAAU,gBAAgB,IAAI;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;;;AE1SvC,IAAO,oBAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var import_tools = require("@outlit/tools");
|
|
|
42
42
|
// package.json
|
|
43
43
|
var package_default = {
|
|
44
44
|
name: "@outlit/pi",
|
|
45
|
-
version: "4.0.
|
|
45
|
+
version: "4.0.2",
|
|
46
46
|
description: "Pi package for Outlit customer intelligence tools and skill guidance",
|
|
47
47
|
license: "Apache-2.0",
|
|
48
48
|
author: "Outlit AI",
|
|
@@ -108,7 +108,7 @@ var package_default = {
|
|
|
108
108
|
test: "vitest run"
|
|
109
109
|
},
|
|
110
110
|
dependencies: {
|
|
111
|
-
"@outlit/tools": "^4.
|
|
111
|
+
"@outlit/tools": "^4.1.0"
|
|
112
112
|
},
|
|
113
113
|
peerDependencies: {
|
|
114
114
|
"@mariozechner/pi-coding-agent": "*",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.0\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAcO;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;A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Aa;AACrC,SAAO;AAAA,IACL,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,IACjC,GAAI,MAAM,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EACnD;AACF;AAEA,SAAS,iBACP,UACA,QACA,MACsC;AACtC,QAAM,UAAU,gBAAgB,IAAI;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.2\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.1.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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A,MACsC;AACtC,QAAM,SAAS,EAAE,MAAM;AACvB,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE;AAAA,MACtD,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS,EAAE,UAAU,QAAQ,OAAO,GAAG,YAAY,MAAM,MAAM,SAAS,EAAE;AAAA,EAC5E;AACF;AAEA,SAAS,YACP,MACA,mBAC0C;AAC1C,QAAM,YAAY,MAAM,aAAa;AACrC,SAAO;AAAA,IACL,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,IACjC,GAAI,MAAM,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EACnD;AACF;AAEA,SAAS,iBACP,UACA,QACA,MACsC;AACtC,QAAM,UAAU,gBAAgB,IAAI;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@outlit/pi",
|
|
16
|
-
version: "4.0.
|
|
16
|
+
version: "4.0.2",
|
|
17
17
|
description: "Pi package for Outlit customer intelligence tools and skill guidance",
|
|
18
18
|
license: "Apache-2.0",
|
|
19
19
|
author: "Outlit AI",
|
|
@@ -79,7 +79,7 @@ var package_default = {
|
|
|
79
79
|
test: "vitest run"
|
|
80
80
|
},
|
|
81
81
|
dependencies: {
|
|
82
|
-
"@outlit/tools": "^4.
|
|
82
|
+
"@outlit/tools": "^4.1.0"
|
|
83
83
|
},
|
|
84
84
|
peerDependencies: {
|
|
85
85
|
"@mariozechner/pi-coding-agent": "*",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.0\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EAGA;AAAA,OACK;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,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AAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS,EAAE,UAAU,QAAQ,OAAO,GAAG,YAAY,MAAM,MAAM,SAAS,EAAE;AAAA,EAC5E;AACF;AAEA,SAAS,YACP,MACA,mBAC0C;AAC1C,QAAM,YAAY,MAAM,aAAa;AACrC,SAAO;AAAA,IACL,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,IACjC,GAAI,MAAM,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EACnD;AACF;AAEA,SAAS,iBACP,UACA,QACA,MACsC;AACtC,QAAM,UAAU,gBAAgB,IAAI;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\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).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(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: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\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\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.2\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.1.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EAGA;AAAA,OACK;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;AAAA,IACJ,YAAc;AAAA,MACZ;AAAA,IACF;AAAA,IACA,QAAU;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,MACX,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,WAAa;AAAA,IACb,MAAQ;AAAA,EACV;AAAA,EACA,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EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outlit/pi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Pi package for Outlit customer intelligence tools and skill guidance",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Outlit AI",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"test": "vitest run"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@outlit/tools": "^4.
|
|
69
|
+
"@outlit/tools": "^4.1.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@mariozechner/pi-coding-agent": "*",
|