@outlit/pi 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/extension.cjs +4 -0
- package/dist/extension.cjs.map +1 -1
- package/dist/extension.js +8 -2
- package/dist/extension.js.map +1 -1
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ The default extension registers the default customer intelligence tools from `@o
|
|
|
31
31
|
- `outlit_list_sources`
|
|
32
32
|
- `outlit_search_customer_context`
|
|
33
33
|
|
|
34
|
-
SQL and the other
|
|
34
|
+
SQL and the other Pi-supported Platform capabilities are available from `@outlit/tools`, but the default Pi policy intentionally stays focused on customer intelligence. A custom Pi extension can opt into every Pi-supported tool with `piToolNames`, including safe integration setup, destination, activation, and workspace-settings actions. Behavior Metric source discovery, event discovery, and creation; responsibility-only commands; and other internal commands are not available through Pi.
|
|
35
35
|
|
|
36
36
|
For analytical agents that need cohorts, usage trends, revenue filters, activation gaps, or aggregate checks, import `analyticalToolNames`. It combines the default customer intelligence tools with `outlit_schema` and `outlit_query` without exposing every customer tool:
|
|
37
37
|
|
|
@@ -60,10 +60,10 @@ The facts tool supports `factTypes` filters for narrowing structured customer-me
|
|
|
60
60
|
Create a small Pi extension when you want a narrower or broader toolset:
|
|
61
61
|
|
|
62
62
|
```ts
|
|
63
|
-
import {
|
|
63
|
+
import { createOutlitPiExtension, piToolNames } from "@outlit/pi"
|
|
64
64
|
|
|
65
65
|
export default createOutlitPiExtension({
|
|
66
|
-
toolNames:
|
|
66
|
+
toolNames: piToolNames,
|
|
67
67
|
})
|
|
68
68
|
```
|
|
69
69
|
|
package/dist/extension.cjs
CHANGED
|
@@ -29,6 +29,7 @@ var import_tools = require("@outlit/tools");
|
|
|
29
29
|
var import_tools2 = require("@outlit/tools");
|
|
30
30
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
31
31
|
var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
|
|
32
|
+
var piToolNameSet = new Set(import_tools.piToolNames);
|
|
32
33
|
function createOutlitPiExtension(options = {}) {
|
|
33
34
|
return function outlitPiExtension(pi) {
|
|
34
35
|
for (const tool of createOutlitPiTools(options)) {
|
|
@@ -45,6 +46,9 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
45
46
|
if (!(0, import_tools.isPublicToolName)(toolName)) {
|
|
46
47
|
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
47
48
|
}
|
|
49
|
+
if (!piToolNameSet.has(toolName)) {
|
|
50
|
+
throw new Error(`Tool is not available in @outlit/pi: ${toolName}`);
|
|
51
|
+
}
|
|
48
52
|
const contract = (0, import_tools.getPublicToolContract)(toolName);
|
|
49
53
|
const label = formatOutlitToolLabel(toolName);
|
|
50
54
|
return {
|
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 createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isPublicToolName,\n type OutlitToolsFetch,\n type
|
|
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 createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isPublicToolName,\n type OutlitToolsFetch,\n type PiToolName,\n piToolNames,\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\nconst piToolNameSet = new Set<string>(piToolNames)\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\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: 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 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: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PiToolName[] | undefined): PiToolName[] {\n const names = toolNames ?? defaultToolNames\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\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: PiToolName,\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 { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBASO;AA4JP,IAAAA,gBAMO;AA/JA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,gBAAgB,IAAI,IAAY,wBAAW;AAkB1C,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,MAAI,KAAC,+BAAiB,QAAQ,GAAG;AAC/B,UAAM,IAAI,MAAM,+BAA+B,QAAQ,EAAE;AAAA,EAC3D;AACA,MAAI,CAAC,cAAc,IAAI,QAAQ,GAAG;AAChC,UAAM,IAAI,MAAM,wCAAwC,QAAQ,EAAE;AAAA,EACpE;AAEA,QAAM,eAAW,oCAAsB,QAAQ;AAC/C,QAAM,QAAQ,sBAAsB,QAAQ;AAE5C,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,aAAa,SAAS;AAAA,IACtB,eAAe,GAAG,KAAK,KAAK,UAAU,SAAS,WAAW,CAAC;AAAA,IAC3D,YAAY,mBAAmB,SAAS,WAAW;AAAA,IACnD,MAAM,QAAQ,aAAa,QAAQ;AACjC,YAAM,aAAS,iCAAmB;AAAA,QAChC,QAAQ,cAAc,OAAO;AAAA,QAC7B,SAAS,eAAe,OAAO;AAAA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W,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;AAaA,IAAO,cAAQ,wBAAwB;;;AD5KvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/extension.js
CHANGED
|
@@ -4,16 +4,19 @@ import {
|
|
|
4
4
|
DEFAULT_OUTLIT_API_URL,
|
|
5
5
|
defaultToolNames,
|
|
6
6
|
getPublicToolContract,
|
|
7
|
-
isPublicToolName
|
|
7
|
+
isPublicToolName,
|
|
8
|
+
piToolNames
|
|
8
9
|
} from "@outlit/tools";
|
|
9
10
|
import {
|
|
10
|
-
allPublicToolNames,
|
|
11
11
|
analyticalToolNames,
|
|
12
12
|
defaultToolNames as defaultToolNames2,
|
|
13
|
+
piToolNames as piToolNames2,
|
|
14
|
+
piToolNames as piToolNames3,
|
|
13
15
|
sqlToolNames
|
|
14
16
|
} from "@outlit/tools";
|
|
15
17
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
16
18
|
var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
|
|
19
|
+
var piToolNameSet = new Set(piToolNames);
|
|
17
20
|
function createOutlitPiExtension(options = {}) {
|
|
18
21
|
return function outlitPiExtension(pi) {
|
|
19
22
|
for (const tool of createOutlitPiTools(options)) {
|
|
@@ -30,6 +33,9 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
30
33
|
if (!isPublicToolName(toolName)) {
|
|
31
34
|
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
32
35
|
}
|
|
36
|
+
if (!piToolNameSet.has(toolName)) {
|
|
37
|
+
throw new Error(`Tool is not available in @outlit/pi: ${toolName}`);
|
|
38
|
+
}
|
|
33
39
|
const contract = getPublicToolContract(toolName);
|
|
34
40
|
const label = formatOutlitToolLabel(toolName);
|
|
35
41
|
return {
|
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 createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isPublicToolName,\n type OutlitToolsFetch,\n type
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../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 isPublicToolName,\n type OutlitToolsFetch,\n type PiToolName,\n piToolNames,\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\nconst piToolNameSet = new Set<string>(piToolNames)\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\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: 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 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: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PiToolName[] | undefined): PiToolName[] {\n const names = toolNames ?? defaultToolNames\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\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: PiToolName,\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 { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","import { createOutlitPiExtension } from \"./index.js\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AA4JP;AAAA,EACE;AAAA,EACA,oBAAAA;AAAA,EACA,eAAAC;AAAA,EACe,eAAfA;AAAA,EACA;AAAA,OACK;AA/JA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,g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AAK,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;AAaA,IAAO,cAAQ,wBAAwB;;;AC5KvC,IAAO,oBAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
OUTLIT_API_KEY_ENV: () => OUTLIT_API_KEY_ENV,
|
|
24
24
|
OUTLIT_API_URL_ENV: () => OUTLIT_API_URL_ENV,
|
|
25
|
-
allPublicToolNames: () => import_tools2.
|
|
25
|
+
allPublicToolNames: () => import_tools2.piToolNames,
|
|
26
26
|
analyticalToolNames: () => import_tools2.analyticalToolNames,
|
|
27
27
|
createOutlitPiExtension: () => createOutlitPiExtension,
|
|
28
28
|
createOutlitPiTool: () => createOutlitPiTool,
|
|
@@ -30,6 +30,7 @@ __export(src_exports, {
|
|
|
30
30
|
default: () => src_default,
|
|
31
31
|
defaultToolNames: () => import_tools2.defaultToolNames,
|
|
32
32
|
formatOutlitToolLabel: () => formatOutlitToolLabel,
|
|
33
|
+
piToolNames: () => import_tools2.piToolNames,
|
|
33
34
|
sqlToolNames: () => import_tools2.sqlToolNames
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -37,6 +38,7 @@ var import_tools = require("@outlit/tools");
|
|
|
37
38
|
var import_tools2 = require("@outlit/tools");
|
|
38
39
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
39
40
|
var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
|
|
41
|
+
var piToolNameSet = new Set(import_tools.piToolNames);
|
|
40
42
|
function createOutlitPiExtension(options = {}) {
|
|
41
43
|
return function outlitPiExtension(pi) {
|
|
42
44
|
for (const tool of createOutlitPiTools(options)) {
|
|
@@ -53,6 +55,9 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
53
55
|
if (!(0, import_tools.isPublicToolName)(toolName)) {
|
|
54
56
|
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
55
57
|
}
|
|
58
|
+
if (!piToolNameSet.has(toolName)) {
|
|
59
|
+
throw new Error(`Tool is not available in @outlit/pi: ${toolName}`);
|
|
60
|
+
}
|
|
56
61
|
const contract = (0, import_tools.getPublicToolContract)(toolName);
|
|
57
62
|
const label = formatOutlitToolLabel(toolName);
|
|
58
63
|
return {
|
|
@@ -138,6 +143,7 @@ var src_default = createOutlitPiExtension();
|
|
|
138
143
|
createOutlitPiTools,
|
|
139
144
|
defaultToolNames,
|
|
140
145
|
formatOutlitToolLabel,
|
|
146
|
+
piToolNames,
|
|
141
147
|
sqlToolNames
|
|
142
148
|
});
|
|
143
149
|
//# sourceMappingURL=index.cjs.map
|
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 createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isPublicToolName,\n type OutlitToolsFetch,\n type
|
|
1
|
+
{"version":3,"sources":["../src/index.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 isPublicToolName,\n type OutlitToolsFetch,\n type PiToolName,\n piToolNames,\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\nconst piToolNameSet = new Set<string>(piToolNames)\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\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: 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 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: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PiToolName[] | undefined): PiToolName[] {\n const names = toolNames ?? defaultToolNames\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\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: PiToolName,\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 { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;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AAG;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;AAaA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
|
|
2
|
-
import { OutlitToolsFetch,
|
|
3
|
-
export {
|
|
2
|
+
import { OutlitToolsFetch, PiToolName } from '@outlit/tools';
|
|
3
|
+
export { PiToolName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames } from '@outlit/tools';
|
|
4
4
|
import { TSchema } from '@sinclair/typebox';
|
|
5
5
|
|
|
6
6
|
declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
@@ -9,19 +9,22 @@ type OutlitPiExtensionOptions = {
|
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
fetch?: OutlitToolsFetch;
|
|
12
|
-
toolNames?: readonly
|
|
12
|
+
toolNames?: readonly PiToolName[];
|
|
13
13
|
};
|
|
14
14
|
type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
|
|
15
15
|
type OutlitPiToolDetails = {
|
|
16
|
-
toolName:
|
|
16
|
+
toolName: PiToolName;
|
|
17
17
|
result: unknown;
|
|
18
18
|
};
|
|
19
19
|
type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>;
|
|
20
20
|
declare function createOutlitPiExtension(options?: OutlitPiExtensionOptions): (pi: OutlitPiRegistry) => void;
|
|
21
21
|
declare function createOutlitPiTools(options?: OutlitPiExtensionOptions): OutlitPiToolDefinition[];
|
|
22
|
-
declare function createOutlitPiTool(toolName:
|
|
23
|
-
declare function formatOutlitToolLabel(toolName:
|
|
22
|
+
declare function createOutlitPiTool(toolName: PiToolName, options?: OutlitPiExtensionOptions): OutlitPiToolDefinition;
|
|
23
|
+
declare function formatOutlitToolLabel(toolName: PiToolName): string;
|
|
24
|
+
|
|
25
|
+
/** @deprecated Use PiToolName. */
|
|
26
|
+
type PublicToolName = PiToolName;
|
|
24
27
|
|
|
25
28
|
declare const _default: (pi: OutlitPiRegistry) => void;
|
|
26
29
|
|
|
27
|
-
export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel };
|
|
30
|
+
export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, type PublicToolName, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
|
|
2
|
-
import { OutlitToolsFetch,
|
|
3
|
-
export {
|
|
2
|
+
import { OutlitToolsFetch, PiToolName } from '@outlit/tools';
|
|
3
|
+
export { PiToolName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames } from '@outlit/tools';
|
|
4
4
|
import { TSchema } from '@sinclair/typebox';
|
|
5
5
|
|
|
6
6
|
declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
@@ -9,19 +9,22 @@ type OutlitPiExtensionOptions = {
|
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
fetch?: OutlitToolsFetch;
|
|
12
|
-
toolNames?: readonly
|
|
12
|
+
toolNames?: readonly PiToolName[];
|
|
13
13
|
};
|
|
14
14
|
type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
|
|
15
15
|
type OutlitPiToolDetails = {
|
|
16
|
-
toolName:
|
|
16
|
+
toolName: PiToolName;
|
|
17
17
|
result: unknown;
|
|
18
18
|
};
|
|
19
19
|
type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>;
|
|
20
20
|
declare function createOutlitPiExtension(options?: OutlitPiExtensionOptions): (pi: OutlitPiRegistry) => void;
|
|
21
21
|
declare function createOutlitPiTools(options?: OutlitPiExtensionOptions): OutlitPiToolDefinition[];
|
|
22
|
-
declare function createOutlitPiTool(toolName:
|
|
23
|
-
declare function formatOutlitToolLabel(toolName:
|
|
22
|
+
declare function createOutlitPiTool(toolName: PiToolName, options?: OutlitPiExtensionOptions): OutlitPiToolDefinition;
|
|
23
|
+
declare function formatOutlitToolLabel(toolName: PiToolName): string;
|
|
24
|
+
|
|
25
|
+
/** @deprecated Use PiToolName. */
|
|
26
|
+
type PublicToolName = PiToolName;
|
|
24
27
|
|
|
25
28
|
declare const _default: (pi: OutlitPiRegistry) => void;
|
|
26
29
|
|
|
27
|
-
export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel };
|
|
30
|
+
export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, type PublicToolName, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel };
|
package/dist/index.js
CHANGED
|
@@ -4,16 +4,19 @@ import {
|
|
|
4
4
|
DEFAULT_OUTLIT_API_URL,
|
|
5
5
|
defaultToolNames,
|
|
6
6
|
getPublicToolContract,
|
|
7
|
-
isPublicToolName
|
|
7
|
+
isPublicToolName,
|
|
8
|
+
piToolNames
|
|
8
9
|
} from "@outlit/tools";
|
|
9
10
|
import {
|
|
10
|
-
allPublicToolNames,
|
|
11
11
|
analyticalToolNames,
|
|
12
12
|
defaultToolNames as defaultToolNames2,
|
|
13
|
+
piToolNames as piToolNames2,
|
|
14
|
+
piToolNames as piToolNames3,
|
|
13
15
|
sqlToolNames
|
|
14
16
|
} from "@outlit/tools";
|
|
15
17
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
16
18
|
var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
|
|
19
|
+
var piToolNameSet = new Set(piToolNames);
|
|
17
20
|
function createOutlitPiExtension(options = {}) {
|
|
18
21
|
return function outlitPiExtension(pi) {
|
|
19
22
|
for (const tool of createOutlitPiTools(options)) {
|
|
@@ -30,6 +33,9 @@ function createOutlitPiTool(toolName, options = {}) {
|
|
|
30
33
|
if (!isPublicToolName(toolName)) {
|
|
31
34
|
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
32
35
|
}
|
|
36
|
+
if (!piToolNameSet.has(toolName)) {
|
|
37
|
+
throw new Error(`Tool is not available in @outlit/pi: ${toolName}`);
|
|
38
|
+
}
|
|
33
39
|
const contract = getPublicToolContract(toolName);
|
|
34
40
|
const label = formatOutlitToolLabel(toolName);
|
|
35
41
|
return {
|
|
@@ -107,7 +113,7 @@ var src_default = createOutlitPiExtension();
|
|
|
107
113
|
export {
|
|
108
114
|
OUTLIT_API_KEY_ENV,
|
|
109
115
|
OUTLIT_API_URL_ENV,
|
|
110
|
-
allPublicToolNames,
|
|
116
|
+
piToolNames3 as allPublicToolNames,
|
|
111
117
|
analyticalToolNames,
|
|
112
118
|
createOutlitPiExtension,
|
|
113
119
|
createOutlitPiTool,
|
|
@@ -115,6 +121,7 @@ export {
|
|
|
115
121
|
src_default as default,
|
|
116
122
|
defaultToolNames2 as defaultToolNames,
|
|
117
123
|
formatOutlitToolLabel,
|
|
124
|
+
piToolNames2 as piToolNames,
|
|
118
125
|
sqlToolNames
|
|
119
126
|
};
|
|
120
127
|
//# sourceMappingURL=index.js.map
|
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 createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isPublicToolName,\n type OutlitToolsFetch,\n type
|
|
1
|
+
{"version":3,"sources":["../src/index.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 isPublicToolName,\n type OutlitToolsFetch,\n type PiToolName,\n piToolNames,\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\nconst piToolNameSet = new Set<string>(piToolNames)\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\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: 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 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: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PiToolName[] | undefined): PiToolName[] {\n const names = toolNames ?? defaultToolNames\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\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: PiToolName,\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 { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AA4JP;AAAA,EACE;AAAA,EACA,oBAAAA;AAAA,EACA,eAAAC;AAAA,EACe,eAAfA;AAAA,EACA;AAAA,OACK;AA/JA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,gBAAgB,IAAI,IAAY,WAAW;AAkB1C,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GA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MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAaA,IAAO,cAAQ,wBAAwB;","names":["defaultToolNames","piToolNames"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outlit/pi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": "^
|
|
69
|
+
"@outlit/tools": "^2.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@mariozechner/pi-coding-agent": "*",
|