@outlit/pi 2.2.0 → 4.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/dist/index.js CHANGED
@@ -4,19 +4,115 @@ import {
4
4
  DEFAULT_OUTLIT_API_URL,
5
5
  defaultToolNames,
6
6
  getPublicToolContract,
7
+ isOutlitToolsApiError,
7
8
  isPublicToolName,
8
- piToolNames
9
+ piToolNames,
10
+ toolNamesInToolsets
9
11
  } from "@outlit/tools";
12
+
13
+ // package.json
14
+ var package_default = {
15
+ name: "@outlit/pi",
16
+ version: "4.0.0",
17
+ description: "Pi package for Outlit customer intelligence tools and skill guidance",
18
+ license: "Apache-2.0",
19
+ author: "Outlit AI",
20
+ repository: {
21
+ type: "git",
22
+ url: "https://github.com/OutlitAI/outlit-sdk.git",
23
+ directory: "packages/pi"
24
+ },
25
+ bugs: {
26
+ url: "https://github.com/OutlitAI/outlit-sdk/issues"
27
+ },
28
+ homepage: "https://docs.outlit.ai/ai-integrations/pi",
29
+ keywords: [
30
+ "outlit",
31
+ "pi",
32
+ "pi-package",
33
+ "agents",
34
+ "ai-agents",
35
+ "mcp",
36
+ "customer-intelligence"
37
+ ],
38
+ pi: {
39
+ extensions: [
40
+ "./dist/extension.js"
41
+ ],
42
+ skills: [
43
+ "./skills"
44
+ ]
45
+ },
46
+ publishConfig: {
47
+ access: "public"
48
+ },
49
+ type: "module",
50
+ main: "./dist/index.cjs",
51
+ module: "./dist/index.js",
52
+ types: "./dist/index.d.ts",
53
+ exports: {
54
+ ".": {
55
+ types: "./dist/index.d.ts",
56
+ import: "./dist/index.js",
57
+ require: "./dist/index.cjs",
58
+ default: "./dist/index.js"
59
+ },
60
+ "./extension": {
61
+ types: "./dist/extension.d.ts",
62
+ import: "./dist/extension.js",
63
+ require: "./dist/extension.cjs",
64
+ default: "./dist/extension.js"
65
+ }
66
+ },
67
+ files: [
68
+ "dist",
69
+ "skills",
70
+ "README.md"
71
+ ],
72
+ scripts: {
73
+ build: "tsup",
74
+ dev: "tsup --watch",
75
+ clean: "rm -rf dist .turbo node_modules",
76
+ lint: "biome check . --write",
77
+ format: "biome format --write .",
78
+ typecheck: "tsc --noEmit",
79
+ test: "vitest run"
80
+ },
81
+ dependencies: {
82
+ "@outlit/tools": "^4.0.0"
83
+ },
84
+ peerDependencies: {
85
+ "@mariozechner/pi-coding-agent": "*",
86
+ "@sinclair/typebox": "*"
87
+ },
88
+ devDependencies: {
89
+ "@mariozechner/pi-coding-agent": "^0.67.1",
90
+ "@outlit/typescript-config": "workspace:*",
91
+ "@sinclair/typebox": "^0.34.41",
92
+ tsup: "^8.5.1",
93
+ typescript: "^5.9.3",
94
+ vitest: "^4.0.18"
95
+ }
96
+ };
97
+
98
+ // src/index.ts
10
99
  import {
11
100
  analyticalToolNames,
12
101
  defaultToolNames as defaultToolNames2,
13
102
  piToolNames as piToolNames2,
14
103
  piToolNames as piToolNames3,
15
- sqlToolNames
104
+ sqlToolNames,
105
+ toolsetNames
16
106
  } from "@outlit/tools";
17
107
  var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
18
108
  var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
109
+ var OUTLIT_PI_CLIENT = `@outlit/pi/${package_default.version}`;
19
110
  var piToolNameSet = new Set(piToolNames);
111
+ var piDefaultToolNames = [
112
+ ...defaultToolNames,
113
+ "outlit_list_toolsets",
114
+ "outlit_load_toolset"
115
+ ];
20
116
  function createOutlitPiExtension(options = {}) {
21
117
  return function outlitPiExtension(pi) {
22
118
  for (const tool of createOutlitPiTools(options)) {
@@ -25,9 +121,7 @@ function createOutlitPiExtension(options = {}) {
25
121
  };
26
122
  }
27
123
  function createOutlitPiTools(options = {}) {
28
- return resolveToolNames(options.toolNames).map(
29
- (toolName) => createOutlitPiTool(toolName, options)
30
- );
124
+ return resolveToolNames(options).map((toolName) => createOutlitPiTool(toolName, options));
31
125
  }
32
126
  function createOutlitPiTool(toolName, options = {}) {
33
127
  if (!isPublicToolName(toolName)) {
@@ -45,13 +139,28 @@ function createOutlitPiTool(toolName, options = {}) {
45
139
  promptSnippet: `${label}: ${firstLine(contract.description)}`,
46
140
  parameters: toPiToolParameters(contract.inputSchema),
47
141
  async execute(_toolCallId, params) {
142
+ let responseInfo;
48
143
  const client = createOutlitClient({
49
144
  apiKey: resolveApiKey(options),
50
145
  baseUrl: resolveBaseUrl(options),
51
- fetch: options.fetch
146
+ fetch: options.fetch,
147
+ client: OUTLIT_PI_CLIENT,
148
+ onResponse: (info) => {
149
+ responseInfo = info;
150
+ }
52
151
  });
53
- const result = await client.callTool(toolName, normalizeToolInput(params));
54
- return formatToolResult(toolName, result);
152
+ const input = normalizeToolInput(params);
153
+ try {
154
+ const result = await client.callTool(toolName, input);
155
+ return formatToolResult(toolName, result, responseInfo);
156
+ } catch (error) {
157
+ return formatToolError(
158
+ toolName,
159
+ toToolError(error, responseInfo),
160
+ responseNotices(responseInfo),
161
+ responseInfo
162
+ );
163
+ }
55
164
  }
56
165
  };
57
166
  }
@@ -65,8 +174,11 @@ function toPiToolParameters(inputSchema) {
65
174
  function formatOutlitToolLabel(toolName) {
66
175
  return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
67
176
  }
68
- function resolveToolNames(toolNames) {
69
- const names = toolNames ?? defaultToolNames;
177
+ function resolveToolNames(options) {
178
+ const names = [
179
+ ...options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames),
180
+ ...options.toolsets ? toolNamesInToolsets(options.toolsets) : []
181
+ ];
70
182
  return [...new Set(names)].map((name) => {
71
183
  if (!isPublicToolName(name)) {
72
184
  throw new Error(`Unknown Outlit public tool: ${name}`);
@@ -97,12 +209,54 @@ function normalizeToolInput(params) {
97
209
  }
98
210
  return params;
99
211
  }
100
- function formatToolResult(toolName, result) {
212
+ function responseNotices(info) {
213
+ if (!info) return [];
214
+ return [
215
+ ...info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : [],
216
+ ...info.notices
217
+ ];
218
+ }
219
+ function toToolError(error, info) {
220
+ if (isOutlitToolsApiError(error)) {
221
+ if (error.envelope) return { ...error.envelope, status: error.status };
222
+ return {
223
+ message: error.message,
224
+ retryable: error.status === 429 || error.status >= 500,
225
+ status: error.status,
226
+ ...error.requestId ?? info?.requestId ? { requestId: error.requestId ?? info?.requestId } : {}
227
+ };
228
+ }
229
+ return { message: error instanceof Error ? error.message : String(error), retryable: true };
230
+ }
231
+ function formatToolError(toolName, error, notices, info) {
232
+ const result = { error };
233
+ return {
234
+ content: [
235
+ { type: "text", text: JSON.stringify(result, null, 2) },
236
+ ...notices.length > 0 ? [{ type: "text", text: `Notice: ${notices.join(" ")}` }] : []
237
+ ],
238
+ details: { toolName, result, error, ...responseIds(info, error.requestId) }
239
+ };
240
+ }
241
+ function responseIds(info, fallbackRequestId) {
242
+ const requestId = info?.requestId ?? fallbackRequestId;
243
+ return {
244
+ ...requestId ? { requestId } : {},
245
+ ...info?.version ? { version: info.version } : {}
246
+ };
247
+ }
248
+ function formatToolResult(toolName, result, info) {
249
+ const notices = responseNotices(info);
101
250
  return {
102
- content: [{ type: "text", text: JSON.stringify(result, null, 2) ?? String(result) }],
251
+ content: [
252
+ { type: "text", text: JSON.stringify(result, null, 2) ?? String(result) },
253
+ // After the result, so a reader of the first block still gets the JSON alone.
254
+ ...notices.length > 0 ? [{ type: "text", text: `Notice: ${notices.join(" ")}` }] : []
255
+ ],
103
256
  details: {
104
257
  toolName,
105
- result
258
+ result,
259
+ ...responseIds(info)
106
260
  }
107
261
  };
108
262
  }
@@ -113,6 +267,7 @@ var src_default = createOutlitPiExtension();
113
267
  export {
114
268
  OUTLIT_API_KEY_ENV,
115
269
  OUTLIT_API_URL_ENV,
270
+ OUTLIT_PI_CLIENT,
116
271
  piToolNames3 as allPublicToolNames,
117
272
  analyticalToolNames,
118
273
  createOutlitPiExtension,
@@ -121,7 +276,9 @@ export {
121
276
  src_default as default,
122
277
  defaultToolNames2 as defaultToolNames,
123
278
  formatOutlitToolLabel,
279
+ piDefaultToolNames,
124
280
  piToolNames2 as piToolNames,
125
- sqlToolNames
281
+ sqlToolNames,
282
+ toolsetNames
126
283
  };
127
284
  //# 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 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,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,CAAC,iBAAiB,QAAQ,GAAG;AAC/B,UAAM,IAAI,MAAM,+BAA+B,QAAQ,EAAE;AAAA,EAC3D;A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;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;AAaA,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.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,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,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,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outlit/pi",
3
- "version": "2.2.0",
3
+ "version": "4.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": "^2.5.0"
69
+ "@outlit/tools": "^4.0.0"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@mariozechner/pi-coding-agent": "*",
@@ -13,19 +13,23 @@ Do not invent customer state when Outlit can answer it. Call out sparse or messy
13
13
 
14
14
  ## Tool Choice
15
15
 
16
- - Use `outlit_list_customers` to discover customers for portfolio, segment, risk, revenue, trial, or account-health questions.
17
- - Use `outlit_list_users` for user-level questions or when a customer answer depends on individual users.
16
+ - Use `outlit_list_customers` to discover customers for portfolio, segment, risk, revenue, trial, or account-health questions. `filters.partOf` lists one customer's direct subsidiaries with their ARR.
17
+ - Use `outlit_list_customer_fields` to find a CRM, support tool or trait field and the values customers hold before filtering `outlit_list_customers` by it (`filters.fields`) or returning it (`fields`). Filters live under `filters`; page with `page.nextCursor`.
18
+ - Use `outlit_list_people` for questions about the people at customers: who the champion or decision maker is, who went quiet, who last spoke to us. Pass `customer` for one account, which also lists the people its CRM companies link to. Filters live under `filters`; each person carries `lastCommunication` (the latest conversation they took part in, never product use).
18
19
  - Use `outlit_get_customer` before deep analysis of a named customer or account.
19
- - Use `outlit_get_timeline` when order, recency, activity sequence, meetings, messages, product usage, support, or billing chronology matters.
20
- - Use `outlit_list_facts` to browse structured account facts, known signals, open issues, health indicators, relationship notes, activation, billing, or renewal context. Narrow with `status`, `sourceTypes`, and `factTypes` when you know what evidence class you need.
21
- - Use `outlit_get_fact` when you already have a fact id and need the canonical fact payload.
20
+ Each included section reports a `status`: only `available` has `data`; `empty`, `not_connected`, `not_synced` and `unavailable` say why there is none, which is not the same as zero. Money values carry `formatted` text; show it as is.
21
+ Ask for what the answer needs with `include`: `relationship` (a summary and up to eight current statements), `features` (product-event features), `meters` (Autumn metered quantities) and `credits` (credit pools with balance and burn rate). `hierarchy` is the parent company and direct subsidiaries the CRM records. `features`, `meters`, `credits` and `hierarchy`'s children come in pages of 25; page one with its own `limit` and `cursor`.
22
+ - Use `outlit_get_timeline` when order, recency, activity sequence, meetings, messages, product usage, support, or billing chronology matters. Filters live under `filters`: `channels` (lowercase, such as `communication` or `product`), `eventTypes`, and a window as `within` or `after` with an optional `before`. Page with `page.nextCursor`.
23
+ - Use `outlit_list_facts` to browse structured account facts, known signals, open issues, health indicators, relationship notes, activation, billing, or renewal context. Narrow with `filters.status`, `filters.sourceTypes`, `filters.types`, and `filters.categories` when you know what evidence class you need; all values are lowercase. A listed fact is concise: it has no `reasoning` or `source.quote` unless you ask with `include` (`reasoning`, `quote`, `evidence`), and `evidence` then holds only the first three cited excerpts as `{ items, page, more }`.
24
+ - Use `outlit_get_fact` when you already have a fact id and need the whole fact; it returns `{ customer, fact }` with `reasoning` and `source.quote`. Its `include: ["evidence"]` adds the first three excerpts, not every source. To read a long field or the rest of the evidence, pass `part: { field }` (`assertion`, `reasoning`, `quote` or `evidence`) and continue with `part.cursor` and the `nextCursor` of the page before; that result is `{ customer, part }` with no `fact`.
22
25
  - Use `outlit_search_customer_context` for fuzzy or thematic questions such as pricing concern, blocked integration, not using, renewal, champion left, negative sentiment, expansion, implementation, or support escalation.
23
- - Use `outlit_list_sources` to discover the source artifacts available for a customer before retrieving one in full.
24
- - Use `outlit_get_source` when a fact or search result needs stronger evidence from the underlying source artifact.
25
- - Use `outlit_get_customer_features` for exact, customer-level Feature observations. Treat unavailable coverage as unknown, not zero usage.
26
+ - Use `outlit_list_sources` to discover the source artifacts available for a customer before retrieving one in full. Narrow with `filters` (`sourceTypes`, `after`, `before`, `participant`, `provider`, `hasTranscript`).
27
+ - Use `outlit_get_source` when a fact or search result needs stronger evidence from the underlying source artifact. Pass the `source { type, id }` that the timeline event, fact, search result or source listing returned, as it came. Content is `content.data.segments`, a page at a time (`content.data.page`).
28
+ - Use `outlit_get_customer` with `include: ["features"]` for exact, customer-level Feature observations. Treat unavailable coverage as unknown, not zero usage.
26
29
  - Use `outlit_list_features` to inspect the confirmed workspace taxonomy, historical evidence, eligible sources, and event candidates.
27
30
  - Use `outlit_create_feature` only when the user explicitly asks to configure one confirmed product capability from one exact event rule. Outlit creates the supporting usage metrics internally.
28
31
  - Use `outlit_archive_feature` only when the user explicitly asks to archive a feature and supplies the current opaque id and revision. The MVP has no restore operation and rejects archiving the final active feature.
32
+ - Use `outlit_list_toolsets` when a tool you need is not in your list; `outlit_load_toolset` summarizes one toolset's tools, and with `tools` (at most 10 names) returns their full definitions. Pi registers its tools when the session starts, so loading a toolset does not make its tools callable here: tell the user which toolset holds the tool, to enable through the extension's `toolsets` option.
29
33
  - Use `outlit_submit_feedback` when the user wants to report an Outlit product bug, idea, or friction. Feedback is product intake, not a support ticket or a guaranteed reply. Put diagnostics in `context`, never secrets or unnecessary customer data.
30
34
 
31
35
  Use customer lookups before SQL. SQL is for aggregates, joins, cohorts, time-series analysis, and custom reporting.
@@ -33,23 +37,24 @@ Use customer lookups before SQL. SQL is for aggregates, joins, cohorts, time-ser
33
37
  ## Facts vs Search vs Timeline
34
38
 
35
39
  - Use `outlit_list_facts` to list what Outlit already knows about an account.
36
- - Use `factTypes` for specific public fact classes such as `CHURN_RISK`, `EXPANSION`, `PRODUCT_USAGE`, `CONTACT_DEPARTURE`, `CONTACT_POSITION_CHANGE`, or `CONTACT_DISENGAGEMENT` when those are relevant. Do not request anomaly detector fact types such as `CORE_ACTION_DECAY`, `CADENCE_BREAK`, `QUIET_ACCOUNT`, `ACTIVATION_RATE_DROP`, or `FUNNEL_DROPOFF` as filters.
40
+ - Use `filters.types` for specific public fact classes such as `churn_risk`, `expansion`, `product_usage`, `contact_departure`, `contact_position_change`, or `contact_disengagement` when those are relevant. Do not request anomaly detector fact types such as `core_action_decay`, `cadence_break`, `quiet_account`, `activation_rate_drop`, or `funnel_dropoff` as filters.
37
41
  - Use `outlit_get_fact` when you already have a fact id and need that exact fact.
38
- - Use `outlit_search_customer_context` for a specific question or theme, including cross-customer questions.
42
+ - Use `outlit_search_customer_context` for a specific question or theme, including cross-customer questions. `limit` caps the results; `filters` take `sourceTypes`, `after` and `before`. An empty result carries `coverage.searched`, which says what was searched.
39
43
  - Use `outlit_get_source` when you need the exact email, call, calendar event, ticket, or other source artifact behind a fact or search hit.
40
44
  - Use `outlit_get_timeline` when order and sequence matter.
41
45
 
42
46
  ## SQL Tools
43
47
 
44
- Only use SQL if `outlit_schema` and `outlit_query` are available in the current Pi session.
48
+ Only use SQL if `outlit_get_schema` and `outlit_query` are available in the current Pi session.
45
49
 
46
- - Call `outlit_schema` before writing SQL.
50
+ - Call `outlit_get_schema` before writing SQL. `topic: "examples"` returns worked queries that run as written.
47
51
  - Prefer customer lookups, facts, timeline, and search before SQL for account-specific analysis.
48
52
  - Use SQL for aggregates, cohorts, joins, custom reporting, and questions that need exact counts or revenue math.
49
53
  - Use the query patterns in the SQL reference. Do not assume another database's date or JSON helpers.
50
54
  - Add explicit time filters for event queries.
51
55
  - Use `LIMIT`.
52
- - Divide money fields in cents by `100` for display.
56
+ - Money columns are minor units: divide `arr_amount` by `10^arr_decimals`, and never add amounts across `arr_currency`.
57
+ - A result page holds at most `limit` rows (default 100, max 1000); send `page.nextCursor` with the same SQL for the next page.
53
58
  - Request only the fields needed for the answer.
54
59
 
55
60
  For supported query patterns, read [references/sql-reference.md](references/sql-reference.md).
@@ -64,6 +69,7 @@ For supported query patterns, read [references/sql-reference.md](references/sql-
64
69
  - Do not send messages, create tasks, update CRM records, or take external actions unless the user explicitly asks and the necessary tools are available.
65
70
  - Do not create or archive Features unless the user explicitly asks. Treat feature usage only as observed product evidence.
66
71
  - If an Outlit tool errors because `OUTLIT_API_KEY` is missing, tell the user to set `OUTLIT_API_KEY` and retry.
72
+ - A failed call comes back as a tool result `{ "error": { code, message, retryable, requestId, ... } }`, not a crash. Act on it: `validationIssues` say which input to fix and `validValues` what it accepts; `next` names the call to make instead; `missingPermission` is the permission the key lacks (tell the user); `retryAfterSeconds` is how long to wait on a rate limit; `retryable: true` means the same call may work later. Quote `requestId` when you report the failure.
67
73
 
68
74
  ## Output
69
75
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  Use this when writing or debugging `outlit_query` queries.
4
4
 
5
- Always inspect schema first with `outlit_schema`.
5
+ Always inspect schema first with `outlit_get_schema` (`topic: "examples"` has worked queries).
6
6
 
7
7
  ## Views
8
8
 
9
9
  - `activity`: product and communication activity
10
- - `customers`: customer attributes, billing, revenue (`arr_cents` with `arr_currency`; `mrr_cents` is deprecated)
10
+ - `customers`: customer attributes, billing, revenue (`arr_amount` in minor units with `arr_currency` and `arr_decimals`; `arr_cents` and `mrr_cents` are deprecated)
11
11
  - `users`: user attributes and journey stages
12
- - `revenue`: daily MRR snapshots
12
+ - `revenue`: ARR daily, one row per customer per UTC day since 2026-11-06 (`snapshot_date`, `arr_amount`, `arr_currency`, `arr_decimals`, `arr_estimated`, `revenue_lifecycle`, customer id, name, domain and status); a day with no row was not computed. It has no MRR columns
13
13
 
14
14
  ## Useful Patterns
15
15
 
@@ -20,7 +20,7 @@ toStartOfMonth(occurred_at)
20
20
  dateDiff('day', first_seen_at, now())
21
21
  occurred_at >= now() - INTERVAL 30 DAY
22
22
  countIf(billing_status = 'PAYING')
23
- sumIf(arr_cents, billing_status = 'PAYING' AND arr_currency = 'USD')
23
+ sumIf(arr_amount, billing_status = 'PAYING' AND arr_currency = 'USD')
24
24
  JSONExtractString(properties, 'path')
25
25
  JSONExtractString(traits, 'plan')
26
26
  ```
@@ -35,7 +35,9 @@ Use the patterns above instead of unsupported date helpers like `DATE_SUB()`.
35
35
  - Add time filters for event queries.
36
36
  - Use `LIMIT`.
37
37
  - Prefer specific columns over `SELECT *`.
38
- - Divide cents by `100` for display.
38
+ - Divide `arr_amount` by `10^arr_decimals` for display, and group by `arr_currency`: amounts in different currencies never add.
39
+ - Count `activity` rows with `uniqExact(event_id)`, not `count()`.
40
+ - Pages hold at most `limit` rows (default 100, max 1000); send `page.nextCursor` with the same SQL for the next page.
39
41
 
40
42
  ## Use SQL When
41
43