@outlit/pi 0.1.2 → 0.1.4
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 +8 -1
- package/dist/extension.cjs.map +1 -1
- package/dist/extension.js +8 -1
- package/dist/extension.js.map +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/extension.cjs
CHANGED
|
@@ -49,7 +49,7 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
49
49
|
label,
|
|
50
50
|
description: contract.description,
|
|
51
51
|
promptSnippet: `${label}: ${firstLine(contract.description)}`,
|
|
52
|
-
parameters: contract.inputSchema,
|
|
52
|
+
parameters: toPiToolParameters(contract.inputSchema),
|
|
53
53
|
async execute(_toolCallId, params) {
|
|
54
54
|
const client = (0, import_tools.createOutlitClient)({
|
|
55
55
|
apiKey: resolveApiKey(options),
|
|
@@ -61,6 +61,13 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
function toPiToolParameters(inputSchema) {
|
|
65
|
+
if (inputSchema === null || typeof inputSchema !== "object" || Array.isArray(inputSchema)) {
|
|
66
|
+
return inputSchema;
|
|
67
|
+
}
|
|
68
|
+
const { $schema: _schema, ...schema } = inputSchema;
|
|
69
|
+
return schema;
|
|
70
|
+
}
|
|
64
71
|
function formatOutlitToolLabel(toolName) {
|
|
65
72
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
66
73
|
}
|
package/dist/extension.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/extension.ts","../src/index.ts"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema
|
|
1
|
+
{"version":3,"sources":["../src/extension.ts","../src/index.ts"],"sourcesContent":["import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n","import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\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: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings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ACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;;;ADhKvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/extension.js
CHANGED
|
@@ -35,7 +35,7 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
35
35
|
label,
|
|
36
36
|
description: contract.description,
|
|
37
37
|
promptSnippet: `${label}: ${firstLine(contract.description)}`,
|
|
38
|
-
parameters: contract.inputSchema,
|
|
38
|
+
parameters: toPiToolParameters(contract.inputSchema),
|
|
39
39
|
async execute(_toolCallId, params) {
|
|
40
40
|
const client = createOutlitClient({
|
|
41
41
|
apiKey: resolveApiKey(options),
|
|
@@ -47,6 +47,13 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
+
function toPiToolParameters(inputSchema) {
|
|
51
|
+
if (inputSchema === null || typeof inputSchema !== "object" || Array.isArray(inputSchema)) {
|
|
52
|
+
return inputSchema;
|
|
53
|
+
}
|
|
54
|
+
const { $schema: _schema, ...schema } = inputSchema;
|
|
55
|
+
return schema;
|
|
56
|
+
}
|
|
50
57
|
function formatOutlitToolLabel(toolName) {
|
|
51
58
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
52
59
|
}
|
package/dist/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/extension.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\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: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAiJP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;AApJA,IAAM,qBAAqB;AAC3B,IAAM,qBA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O,oBAAQ,wBAAwB;","names":["defaultAgentToolNames"]}
|
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,7 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
58
58
|
label,
|
|
59
59
|
description: contract.description,
|
|
60
60
|
promptSnippet: `${label}: ${firstLine(contract.description)}`,
|
|
61
|
-
parameters: contract.inputSchema,
|
|
61
|
+
parameters: toPiToolParameters(contract.inputSchema),
|
|
62
62
|
async execute(_toolCallId, params) {
|
|
63
63
|
const client = (0, import_tools.createOutlitClient)({
|
|
64
64
|
apiKey: resolveApiKey(options),
|
|
@@ -70,6 +70,13 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
function toPiToolParameters(inputSchema) {
|
|
74
|
+
if (inputSchema === null || typeof inputSchema !== "object" || Array.isArray(inputSchema)) {
|
|
75
|
+
return inputSchema;
|
|
76
|
+
}
|
|
77
|
+
const { $schema: _schema, ...schema } = inputSchema;
|
|
78
|
+
return schema;
|
|
79
|
+
}
|
|
73
80
|
function formatOutlitToolLabel(toolName) {
|
|
74
81
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
75
82
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\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: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAQO;AAiJP,IAAAA,gBAMO;AApJA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAkB3B,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GAAG;AAC/C,SAAG,aAAa,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAA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AAI,MAAM,iCAAiC,IAAI,EAAE;AAAA,IACzD;AAEA,WAAO;AAAA,EACT,CAAC;AACH;AAEA,SAAS,cAAc,SAA2C;AAChE,QAAM,SAAS,gBAAgB,QAAQ,MAAM,KAAK,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC;AAEjG,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,GAAG,kBAAkB,sCAAsC;AAAA,EAC7E;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,SAA2C;AACjE,SACE,gBAAgB,QAAQ,OAAO,KAC/B,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC,KAC/C;AAEJ;AAEA,SAAS,gBAAgB,OAA+C;AACtE,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,mBAAmB,QAA0C;AACpE,MAAI,WAAW,QAAW;AACxB,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG;AAC1E,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AAEA,SAAO;AACT;AAEA,SAAS,iBACP,UACA,QACsC;AACtC,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE,CAAC;AAAA,IACnF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
35
35
|
label,
|
|
36
36
|
description: contract.description,
|
|
37
37
|
promptSnippet: `${label}: ${firstLine(contract.description)}`,
|
|
38
|
-
parameters: contract.inputSchema,
|
|
38
|
+
parameters: toPiToolParameters(contract.inputSchema),
|
|
39
39
|
async execute(_toolCallId, params) {
|
|
40
40
|
const client = createOutlitClient({
|
|
41
41
|
apiKey: resolveApiKey(options),
|
|
@@ -47,6 +47,13 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
+
function toPiToolParameters(inputSchema) {
|
|
51
|
+
if (inputSchema === null || typeof inputSchema !== "object" || Array.isArray(inputSchema)) {
|
|
52
|
+
return inputSchema;
|
|
53
|
+
}
|
|
54
|
+
const { $schema: _schema, ...schema } = inputSchema;
|
|
55
|
+
return schema;
|
|
56
|
+
}
|
|
50
57
|
function formatOutlitToolLabel(toolName) {
|
|
51
58
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
52
59
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: contract.inputSchema
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n type CustomerToolName,\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultAgentToolNames,\n getCustomerToolContract,\n isCustomerToolName,\n type OutlitToolsFetch,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly CustomerToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: CustomerToolName\n result: unknown\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options.toolNames).map((toolName) =>\n createOutlitPiTool(toolName, options),\n )\n}\n\nexport function createOutlitPiTool(\n toolName: CustomerToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n const contract = getCustomerToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n })\n const result = await client.callTool(toolName, normalizeToolInput(params))\n\n return formatToolResult(toolName, result)\n },\n }\n}\n\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: CustomerToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly CustomerToolName[] | undefined): CustomerToolName[] {\n const names = toolNames ?? defaultAgentToolNames\n\n return [...new Set(names)].map((name) => {\n if (!isCustomerToolName(name)) {\n throw new Error(`Unknown Outlit customer tool: ${name}`)\n }\n\n return name\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\nfunction formatToolResult(\n toolName: CustomerToolName,\n result: unknown,\n): AgentToolResult<OutlitPiToolDetails> {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) }],\n details: {\n toolName,\n result,\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { CustomerToolName } from \"@outlit/tools\"\nexport {\n actionToolNames,\n allCustomerToolNames,\n analyticalAgentToolNames,\n defaultAgentToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAiJP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA;AAAA,OACK;AApJA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAkB3B,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GAAG;AAC/C,SAAG,aAAa,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,oBACd,UAAoC,CAAC,GACX;AAC1B,SAAO,iBAAiB,QAAQ,SAAS,EAAE;AAAA,IAAI,CAAC,aAC9C,mBAAmB,UAAU,OAAO;AAAA,EACtC;AACF;AAEO,SAAS,mBACd,UACA,UAAoC,CAAC,GACb;AACxB,QAAM,WAAW,wBAAwB,QAAQ;AACjD,QAAM,QAAQ,sBAAsB,QAAQ;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kBAAkB,sCAAsC;AAAA,EAC7E;AAEA,SAAO;AACT;AAEA,SAAS,eAAe,SAA2C;AACjE,SACE,gBAAgB,QAAQ,OAAO,KAC/B,gBAAgB,QAAQ,IAAI,kBAAkB,CAAC,KAC/C;AAEJ;AAEA,SAAS,gBAAgB,OAA+C;AACtE,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,mBAAmB,QAA0C;AACpE,MAAI,WAAW,QAAW;AACxB,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GAAG;AAC1E,UAAM,IAAI,UAAU,wCAAwC;AAAA,EAC9D;AAEA,SAAO;AACT;AAEA,SAAS,iBACP,UACA,QACsC;AACtC,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE,CAAC;AAAA,IACnF,SAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAWA,IAAO,cAAQ,wBAAwB;","names":["defaultAgentToolNames"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outlit/pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Pi package for Outlit customer intelligence tools",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Outlit AI",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"test": "vitest run"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@outlit/tools": "^0.1
|
|
67
|
+
"@outlit/tools": "^0.2.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@mariozechner/pi-coding-agent": "*",
|