@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.cjs CHANGED
@@ -22,6 +22,7 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  OUTLIT_API_KEY_ENV: () => OUTLIT_API_KEY_ENV,
24
24
  OUTLIT_API_URL_ENV: () => OUTLIT_API_URL_ENV,
25
+ OUTLIT_PI_CLIENT: () => OUTLIT_PI_CLIENT,
25
26
  allPublicToolNames: () => import_tools2.piToolNames,
26
27
  analyticalToolNames: () => import_tools2.analyticalToolNames,
27
28
  createOutlitPiExtension: () => createOutlitPiExtension,
@@ -30,15 +31,110 @@ __export(src_exports, {
30
31
  default: () => src_default,
31
32
  defaultToolNames: () => import_tools2.defaultToolNames,
32
33
  formatOutlitToolLabel: () => formatOutlitToolLabel,
34
+ piDefaultToolNames: () => piDefaultToolNames,
33
35
  piToolNames: () => import_tools2.piToolNames,
34
- sqlToolNames: () => import_tools2.sqlToolNames
36
+ sqlToolNames: () => import_tools2.sqlToolNames,
37
+ toolsetNames: () => import_tools2.toolsetNames
35
38
  });
36
39
  module.exports = __toCommonJS(src_exports);
37
40
  var import_tools = require("@outlit/tools");
41
+
42
+ // package.json
43
+ var package_default = {
44
+ name: "@outlit/pi",
45
+ version: "4.0.0",
46
+ description: "Pi package for Outlit customer intelligence tools and skill guidance",
47
+ license: "Apache-2.0",
48
+ author: "Outlit AI",
49
+ repository: {
50
+ type: "git",
51
+ url: "https://github.com/OutlitAI/outlit-sdk.git",
52
+ directory: "packages/pi"
53
+ },
54
+ bugs: {
55
+ url: "https://github.com/OutlitAI/outlit-sdk/issues"
56
+ },
57
+ homepage: "https://docs.outlit.ai/ai-integrations/pi",
58
+ keywords: [
59
+ "outlit",
60
+ "pi",
61
+ "pi-package",
62
+ "agents",
63
+ "ai-agents",
64
+ "mcp",
65
+ "customer-intelligence"
66
+ ],
67
+ pi: {
68
+ extensions: [
69
+ "./dist/extension.js"
70
+ ],
71
+ skills: [
72
+ "./skills"
73
+ ]
74
+ },
75
+ publishConfig: {
76
+ access: "public"
77
+ },
78
+ type: "module",
79
+ main: "./dist/index.cjs",
80
+ module: "./dist/index.js",
81
+ types: "./dist/index.d.ts",
82
+ exports: {
83
+ ".": {
84
+ types: "./dist/index.d.ts",
85
+ import: "./dist/index.js",
86
+ require: "./dist/index.cjs",
87
+ default: "./dist/index.js"
88
+ },
89
+ "./extension": {
90
+ types: "./dist/extension.d.ts",
91
+ import: "./dist/extension.js",
92
+ require: "./dist/extension.cjs",
93
+ default: "./dist/extension.js"
94
+ }
95
+ },
96
+ files: [
97
+ "dist",
98
+ "skills",
99
+ "README.md"
100
+ ],
101
+ scripts: {
102
+ build: "tsup",
103
+ dev: "tsup --watch",
104
+ clean: "rm -rf dist .turbo node_modules",
105
+ lint: "biome check . --write",
106
+ format: "biome format --write .",
107
+ typecheck: "tsc --noEmit",
108
+ test: "vitest run"
109
+ },
110
+ dependencies: {
111
+ "@outlit/tools": "^4.0.0"
112
+ },
113
+ peerDependencies: {
114
+ "@mariozechner/pi-coding-agent": "*",
115
+ "@sinclair/typebox": "*"
116
+ },
117
+ devDependencies: {
118
+ "@mariozechner/pi-coding-agent": "^0.67.1",
119
+ "@outlit/typescript-config": "workspace:*",
120
+ "@sinclair/typebox": "^0.34.41",
121
+ tsup: "^8.5.1",
122
+ typescript: "^5.9.3",
123
+ vitest: "^4.0.18"
124
+ }
125
+ };
126
+
127
+ // src/index.ts
38
128
  var import_tools2 = require("@outlit/tools");
39
129
  var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
40
130
  var OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
131
+ var OUTLIT_PI_CLIENT = `@outlit/pi/${package_default.version}`;
41
132
  var piToolNameSet = new Set(import_tools.piToolNames);
133
+ var piDefaultToolNames = [
134
+ ...import_tools.defaultToolNames,
135
+ "outlit_list_toolsets",
136
+ "outlit_load_toolset"
137
+ ];
42
138
  function createOutlitPiExtension(options = {}) {
43
139
  return function outlitPiExtension(pi) {
44
140
  for (const tool of createOutlitPiTools(options)) {
@@ -47,9 +143,7 @@ function createOutlitPiExtension(options = {}) {
47
143
  };
48
144
  }
49
145
  function createOutlitPiTools(options = {}) {
50
- return resolveToolNames(options.toolNames).map(
51
- (toolName) => createOutlitPiTool(toolName, options)
52
- );
146
+ return resolveToolNames(options).map((toolName) => createOutlitPiTool(toolName, options));
53
147
  }
54
148
  function createOutlitPiTool(toolName, options = {}) {
55
149
  if (!(0, import_tools.isPublicToolName)(toolName)) {
@@ -67,13 +161,28 @@ function createOutlitPiTool(toolName, options = {}) {
67
161
  promptSnippet: `${label}: ${firstLine(contract.description)}`,
68
162
  parameters: toPiToolParameters(contract.inputSchema),
69
163
  async execute(_toolCallId, params) {
164
+ let responseInfo;
70
165
  const client = (0, import_tools.createOutlitClient)({
71
166
  apiKey: resolveApiKey(options),
72
167
  baseUrl: resolveBaseUrl(options),
73
- fetch: options.fetch
168
+ fetch: options.fetch,
169
+ client: OUTLIT_PI_CLIENT,
170
+ onResponse: (info) => {
171
+ responseInfo = info;
172
+ }
74
173
  });
75
- const result = await client.callTool(toolName, normalizeToolInput(params));
76
- return formatToolResult(toolName, result);
174
+ const input = normalizeToolInput(params);
175
+ try {
176
+ const result = await client.callTool(toolName, input);
177
+ return formatToolResult(toolName, result, responseInfo);
178
+ } catch (error) {
179
+ return formatToolError(
180
+ toolName,
181
+ toToolError(error, responseInfo),
182
+ responseNotices(responseInfo),
183
+ responseInfo
184
+ );
185
+ }
77
186
  }
78
187
  };
79
188
  }
@@ -87,8 +196,11 @@ function toPiToolParameters(inputSchema) {
87
196
  function formatOutlitToolLabel(toolName) {
88
197
  return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
89
198
  }
90
- function resolveToolNames(toolNames) {
91
- const names = toolNames ?? import_tools.defaultToolNames;
199
+ function resolveToolNames(options) {
200
+ const names = [
201
+ ...options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames),
202
+ ...options.toolsets ? (0, import_tools.toolNamesInToolsets)(options.toolsets) : []
203
+ ];
92
204
  return [...new Set(names)].map((name) => {
93
205
  if (!(0, import_tools.isPublicToolName)(name)) {
94
206
  throw new Error(`Unknown Outlit public tool: ${name}`);
@@ -119,12 +231,54 @@ function normalizeToolInput(params) {
119
231
  }
120
232
  return params;
121
233
  }
122
- function formatToolResult(toolName, result) {
234
+ function responseNotices(info) {
235
+ if (!info) return [];
236
+ return [
237
+ ...info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : [],
238
+ ...info.notices
239
+ ];
240
+ }
241
+ function toToolError(error, info) {
242
+ if ((0, import_tools.isOutlitToolsApiError)(error)) {
243
+ if (error.envelope) return { ...error.envelope, status: error.status };
244
+ return {
245
+ message: error.message,
246
+ retryable: error.status === 429 || error.status >= 500,
247
+ status: error.status,
248
+ ...error.requestId ?? info?.requestId ? { requestId: error.requestId ?? info?.requestId } : {}
249
+ };
250
+ }
251
+ return { message: error instanceof Error ? error.message : String(error), retryable: true };
252
+ }
253
+ function formatToolError(toolName, error, notices, info) {
254
+ const result = { error };
255
+ return {
256
+ content: [
257
+ { type: "text", text: JSON.stringify(result, null, 2) },
258
+ ...notices.length > 0 ? [{ type: "text", text: `Notice: ${notices.join(" ")}` }] : []
259
+ ],
260
+ details: { toolName, result, error, ...responseIds(info, error.requestId) }
261
+ };
262
+ }
263
+ function responseIds(info, fallbackRequestId) {
264
+ const requestId = info?.requestId ?? fallbackRequestId;
265
+ return {
266
+ ...requestId ? { requestId } : {},
267
+ ...info?.version ? { version: info.version } : {}
268
+ };
269
+ }
270
+ function formatToolResult(toolName, result, info) {
271
+ const notices = responseNotices(info);
123
272
  return {
124
- content: [{ type: "text", text: JSON.stringify(result, null, 2) ?? String(result) }],
273
+ content: [
274
+ { type: "text", text: JSON.stringify(result, null, 2) ?? String(result) },
275
+ // After the result, so a reader of the first block still gets the JSON alone.
276
+ ...notices.length > 0 ? [{ type: "text", text: `Notice: ${notices.join(" ")}` }] : []
277
+ ],
125
278
  details: {
126
279
  toolName,
127
- result
280
+ result,
281
+ ...responseIds(info)
128
282
  }
129
283
  };
130
284
  }
@@ -136,6 +290,7 @@ var src_default = createOutlitPiExtension();
136
290
  0 && (module.exports = {
137
291
  OUTLIT_API_KEY_ENV,
138
292
  OUTLIT_API_URL_ENV,
293
+ OUTLIT_PI_CLIENT,
139
294
  allPublicToolNames,
140
295
  analyticalToolNames,
141
296
  createOutlitPiExtension,
@@ -143,7 +298,9 @@ var src_default = createOutlitPiExtension();
143
298
  createOutlitPiTools,
144
299
  defaultToolNames,
145
300
  formatOutlitToolLabel,
301
+ piDefaultToolNames,
146
302
  piToolNames,
147
- sqlToolNames
303
+ sqlToolNames,
304
+ toolsetNames
148
305
  });
149
306
  //# sourceMappingURL=index.cjs.map
@@ -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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,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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OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAaA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
1
+ {"version":3,"sources":["../src/index.ts","../package.json"],"sourcesContent":["import type { AgentToolResult, ExtensionAPI, ToolDefinition } from \"@mariozechner/pi-coding-agent\"\nimport {\n createOutlitClient,\n DEFAULT_OUTLIT_API_URL,\n defaultToolNames,\n getPublicToolContract,\n isOutlitToolsApiError,\n isPublicToolName,\n type OutlitToolsFetch,\n type OutlitToolsResponseInfo,\n type PiToolName,\n piToolNames,\n type ToolGatewayErrorEnvelope,\n type ToolsetName,\n toolNamesInToolsets,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\nimport pkg from \"../package.json\" with { type: \"json\" }\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\n/** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */\nexport const OUTLIT_PI_CLIENT = `@outlit/pi/${pkg.version}`\n\nconst piToolNameSet = new Set<string>(piToolNames)\n\n/**\n * What the extension registers with no options: Core's default customer intelligence tools, plus the\n * two read-only toolset tools, so an agent that needs a tool outside this list can find out which\n * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools\n * when the session starts, so loading a toolset never adds callable tools mid-session.\n */\nexport const piDefaultToolNames: readonly PiToolName[] = [\n ...defaultToolNames,\n \"outlit_list_toolsets\",\n \"outlit_load_toolset\",\n]\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PiToolName[]\n /**\n * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`\n * too, both apply; with neither, the default read-only tools are registered.\n */\n toolsets?: readonly ToolsetName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\n/**\n * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,\n * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,\n * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope\n * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.\n */\nexport type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {\n message: string\n retryable: boolean\n status?: number\n}\n\nexport type OutlitPiToolDetails = {\n toolName: PiToolName\n /** The tool's result; `{ error }` when the call failed (see `error`). */\n result: unknown\n /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */\n error?: OutlitPiToolError\n /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */\n requestId?: string\n /** Core's `outlit-version`: the dated output version that answered. */\n version?: string\n}\n\nexport type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>\n\nexport function createOutlitPiExtension(options: OutlitPiExtensionOptions = {}) {\n return function outlitPiExtension(pi: OutlitPiRegistry) {\n for (const tool of createOutlitPiTools(options)) {\n pi.registerTool(tool)\n }\n }\n}\n\nexport function createOutlitPiTools(\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition[] {\n return resolveToolNames(options).map((toolName) => createOutlitPiTool(toolName, options))\n}\n\nexport function createOutlitPiTool(\n toolName: PiToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${toolName}`)\n }\n if (!piToolNameSet.has(toolName)) {\n throw new Error(`Tool is not available in @outlit/pi: ${toolName}`)\n }\n\n const contract = getPublicToolContract(toolName)\n const label = formatOutlitToolLabel(toolName)\n\n return {\n name: toolName,\n label,\n description: contract.description,\n promptSnippet: `${label}: ${firstLine(contract.description)}`,\n parameters: toPiToolParameters(contract.inputSchema),\n async execute(_toolCallId, params) {\n let responseInfo: OutlitToolsResponseInfo | undefined\n const client = createOutlitClient({\n apiKey: resolveApiKey(options),\n baseUrl: resolveBaseUrl(options),\n fetch: options.fetch,\n client: OUTLIT_PI_CLIENT,\n onResponse: (info) => {\n responseInfo = info\n },\n })\n const input = normalizeToolInput(params)\n try {\n const result = await client.callTool(toolName, input)\n return formatToolResult(toolName, result, responseInfo)\n } catch (error) {\n // A failed call is something the agent can act on, not a crash: hand it the envelope.\n return formatToolError(\n toolName,\n toToolError(error, responseInfo),\n responseNotices(responseInfo),\n responseInfo,\n )\n }\n },\n }\n}\n\nfunction toPiToolParameters(inputSchema: unknown): TSchema {\n if (inputSchema === null || typeof inputSchema !== \"object\" || Array.isArray(inputSchema)) {\n return inputSchema as TSchema\n }\n\n const { $schema: _schema, ...schema } = inputSchema as Record<string, unknown>\n return schema as unknown as TSchema\n}\n\nexport function formatOutlitToolLabel(toolName: PiToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(options: OutlitPiExtensionOptions): PiToolName[] {\n const names: readonly string[] = [\n ...(options.toolNames ?? (options.toolsets ? [] : piDefaultToolNames)),\n ...(options.toolsets ? toolNamesInToolsets(options.toolsets) : []),\n ]\n\n return [...new Set(names)].map((name) => {\n if (!isPublicToolName(name)) {\n throw new Error(`Unknown Outlit public tool: ${name}`)\n }\n\n return name as PiToolName\n })\n}\n\nfunction resolveApiKey(options: OutlitPiExtensionOptions): string {\n const apiKey = normalizeString(options.apiKey) ?? normalizeString(process.env[OUTLIT_API_KEY_ENV])\n\n if (!apiKey) {\n throw new Error(`${OUTLIT_API_KEY_ENV} is required to use @outlit/pi tools`)\n }\n\n return apiKey\n}\n\nfunction resolveBaseUrl(options: OutlitPiExtensionOptions): string {\n return (\n normalizeString(options.baseUrl) ??\n normalizeString(process.env[OUTLIT_API_URL_ENV]) ??\n DEFAULT_OUTLIT_API_URL\n )\n}\n\nfunction normalizeString(value: string | undefined): string | undefined {\n const trimmed = value?.trim()\n return trimmed ? trimmed : undefined\n}\n\nfunction normalizeToolInput(params: unknown): Record<string, unknown> {\n if (params === undefined) {\n return {}\n }\n\n if (params === null || typeof params !== \"object\" || Array.isArray(params)) {\n throw new TypeError(\"Outlit Pi tool input must be an object\")\n }\n\n return params as Record<string, unknown>\n}\n\n/** What the gateway said beside the result, as sentences for the agent: a deprecation, then notices. */\nfunction responseNotices(info: OutlitToolsResponseInfo | undefined): string[] {\n if (!info) return []\n return [\n ...(info.deprecation ? [`${info.deprecation.message} (until ${info.deprecation.until})`] : []),\n ...info.notices,\n ]\n}\n\nfunction toToolError(error: unknown, info?: OutlitToolsResponseInfo): OutlitPiToolError {\n if (isOutlitToolsApiError(error)) {\n if (error.envelope) return { ...error.envelope, status: error.status }\n return {\n message: error.message,\n retryable: error.status === 429 || error.status >= 500,\n status: error.status,\n ...((error.requestId ?? info?.requestId)\n ? { requestId: error.requestId ?? info?.requestId }\n : {}),\n }\n }\n // fetch rejecting (offline, DNS, reset) or a 200 whose body was not JSON.\n return { message: error instanceof Error ? error.message : String(error), retryable: true }\n}\n\nfunction formatToolError(\n toolName: PiToolName,\n error: OutlitPiToolError,\n notices: string[],\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const result = { error }\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) },\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: { toolName, result, error, ...responseIds(info, error.requestId) },\n }\n}\n\nfunction responseIds(\n info: OutlitToolsResponseInfo | undefined,\n fallbackRequestId?: string,\n): { requestId?: string; version?: string } {\n const requestId = info?.requestId ?? fallbackRequestId\n return {\n ...(requestId ? { requestId } : {}),\n ...(info?.version ? { version: info.version } : {}),\n }\n}\n\nfunction formatToolResult(\n toolName: PiToolName,\n result: unknown,\n info?: OutlitToolsResponseInfo,\n): AgentToolResult<OutlitPiToolDetails> {\n const notices = responseNotices(info)\n return {\n content: [\n { type: \"text\", text: JSON.stringify(result, null, 2) ?? String(result) },\n // After the result, so a reader of the first block still gets the JSON alone.\n ...(notices.length > 0\n ? [{ type: \"text\" as const, text: `Notice: ${notices.join(\" \")}` }]\n : []),\n ],\n details: {\n toolName,\n result,\n ...responseIds(info),\n },\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(\"\\n\", 1)[0] ?? value\n}\n\nexport type { PiToolName } from \"@outlit/tools\"\n/** @deprecated Use PiToolName. */\nexport type PublicToolName = PiToolName\nexport type { ToolsetName } from \"@outlit/tools\"\nexport {\n analyticalToolNames,\n defaultToolNames,\n piToolNames,\n piToolNames as allPublicToolNames,\n sqlToolNames,\n toolsetNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n","{\n \"name\": \"@outlit/pi\",\n \"version\": \"4.0.0\",\n \"description\": \"Pi package for Outlit customer intelligence tools and skill guidance\",\n \"license\": \"Apache-2.0\",\n \"author\": \"Outlit AI\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/OutlitAI/outlit-sdk.git\",\n \"directory\": \"packages/pi\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/OutlitAI/outlit-sdk/issues\"\n },\n \"homepage\": \"https://docs.outlit.ai/ai-integrations/pi\",\n \"keywords\": [\n \"outlit\",\n \"pi\",\n \"pi-package\",\n \"agents\",\n \"ai-agents\",\n \"mcp\",\n \"customer-intelligence\"\n ],\n \"pi\": {\n \"extensions\": [\n \"./dist/extension.js\"\n ],\n \"skills\": [\n \"./skills\"\n ]\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"type\": \"module\",\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.js\"\n },\n \"./extension\": {\n \"types\": \"./dist/extension.d.ts\",\n \"import\": \"./dist/extension.js\",\n \"require\": \"./dist/extension.cjs\",\n \"default\": \"./dist/extension.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"clean\": \"rm -rf dist .turbo node_modules\",\n \"lint\": \"biome check . --write\",\n \"format\": \"biome format --write .\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run\"\n },\n \"dependencies\": {\n \"@outlit/tools\": \"^4.0.0\"\n },\n \"peerDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"*\",\n \"@sinclair/typebox\": \"*\"\n },\n \"devDependencies\": {\n \"@mariozechner/pi-coding-agent\": \"^0.67.1\",\n \"@outlit/typescript-config\": \"workspace:*\",\n \"@sinclair/typebox\": \"^0.34.41\",\n \"tsup\": \"^8.5.1\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAcO;;;ACfP;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,QAAU;AAAA,EACV,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,IACP,WAAa;AAAA,EACf;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,IAAM;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,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UACA,QACA,MACsC;AACtC,QAAM,UAAU,gBAAgB,IAAI;AACpC,SAAO;AAAA,IACL,SAAS;AAAA,MACP,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,CAAC,KAAK,OAAO,MAAM,EAAE;AAAA;AAAA,MAExE,GAAI,QAAQ,SAAS,IACjB,CAAC,EAAE,MAAM,QAAiB,MAAM,WAAW,QAAQ,KAAK,GAAG,CAAC,GAAG,CAAC,IAChE,CAAC;AAAA,IACP;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA,GAAG,YAAY,IAAI;AAAA,IACrB;AAAA,EACF;AACF;AAEA,SAAS,UAAU,OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAeA,IAAO,cAAQ,wBAAwB;","names":["import_tools"]}
package/dist/index.d.cts CHANGED
@@ -1,20 +1,52 @@
1
1
  import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
2
- import { OutlitToolsFetch, PiToolName } from '@outlit/tools';
3
- export { PiToolName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames } from '@outlit/tools';
2
+ import { OutlitToolsFetch, PiToolName, ToolsetName, ToolGatewayErrorEnvelope } from '@outlit/tools';
3
+ export { PiToolName, ToolsetName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames, toolsetNames } from '@outlit/tools';
4
4
  import { TSchema } from '@sinclair/typebox';
5
5
 
6
6
  declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
7
7
  declare const OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
8
+ /** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */
9
+ declare const OUTLIT_PI_CLIENT: string;
10
+ /**
11
+ * What the extension registers with no options: Core's default customer intelligence tools, plus the
12
+ * two read-only toolset tools, so an agent that needs a tool outside this list can find out which
13
+ * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools
14
+ * when the session starts, so loading a toolset never adds callable tools mid-session.
15
+ */
16
+ declare const piDefaultToolNames: readonly PiToolName[];
8
17
  type OutlitPiExtensionOptions = {
9
18
  apiKey?: string;
10
19
  baseUrl?: string;
11
20
  fetch?: OutlitToolsFetch;
12
21
  toolNames?: readonly PiToolName[];
22
+ /**
23
+ * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`
24
+ * too, both apply; with neither, the default read-only tools are registered.
25
+ */
26
+ toolsets?: readonly ToolsetName[];
13
27
  };
14
28
  type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
29
+ /**
30
+ * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,
31
+ * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,
32
+ * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope
33
+ * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.
34
+ */
35
+ type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {
36
+ message: string;
37
+ retryable: boolean;
38
+ status?: number;
39
+ };
15
40
  type OutlitPiToolDetails = {
16
41
  toolName: PiToolName;
42
+ /** The tool's result; `{ error }` when the call failed (see `error`). */
17
43
  result: unknown;
44
+ /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */
45
+ error?: OutlitPiToolError;
46
+ /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */
47
+ requestId?: string;
48
+ /** Core's `outlit-version`: the dated output version that answered. */
49
+ version?: string;
18
50
  };
19
51
  type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>;
20
52
  declare function createOutlitPiExtension(options?: OutlitPiExtensionOptions): (pi: OutlitPiRegistry) => void;
@@ -27,4 +59,4 @@ type PublicToolName = PiToolName;
27
59
 
28
60
  declare const _default: (pi: OutlitPiRegistry) => void;
29
61
 
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 };
62
+ export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, OUTLIT_PI_CLIENT, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, type OutlitPiToolError, type PublicToolName, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel, piDefaultToolNames };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,52 @@
1
1
  import { ExtensionAPI, ToolDefinition } from '@mariozechner/pi-coding-agent';
2
- import { OutlitToolsFetch, PiToolName } from '@outlit/tools';
3
- export { PiToolName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames } from '@outlit/tools';
2
+ import { OutlitToolsFetch, PiToolName, ToolsetName, ToolGatewayErrorEnvelope } from '@outlit/tools';
3
+ export { PiToolName, ToolsetName, piToolNames as allPublicToolNames, analyticalToolNames, defaultToolNames, piToolNames, sqlToolNames, toolsetNames } from '@outlit/tools';
4
4
  import { TSchema } from '@sinclair/typebox';
5
5
 
6
6
  declare const OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
7
7
  declare const OUTLIT_API_URL_ENV = "OUTLIT_API_URL";
8
+ /** Sent as `x-outlit-client`, so Core can tell a Pi extension below a release's minimum version. */
9
+ declare const OUTLIT_PI_CLIENT: string;
10
+ /**
11
+ * What the extension registers with no options: Core's default customer intelligence tools, plus the
12
+ * two read-only toolset tools, so an agent that needs a tool outside this list can find out which
13
+ * toolset holds it and tell the user to enable it (the `toolsets` option below). Pi registers tools
14
+ * when the session starts, so loading a toolset never adds callable tools mid-session.
15
+ */
16
+ declare const piDefaultToolNames: readonly PiToolName[];
8
17
  type OutlitPiExtensionOptions = {
9
18
  apiKey?: string;
10
19
  baseUrl?: string;
11
20
  fetch?: OutlitToolsFetch;
12
21
  toolNames?: readonly PiToolName[];
22
+ /**
23
+ * Register every tool in these Core toolsets (core, work, identity, admin, meta). With `toolNames`
24
+ * too, both apply; with neither, the default read-only tools are registered.
25
+ */
26
+ toolsets?: readonly ToolsetName[];
13
27
  };
14
28
  type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
29
+ /**
30
+ * What a failed call hands the agent: the gateway's whole error envelope (`code`, `message`,
31
+ * `retryable`, `requestId`, and when present `next`, `missingPermission`, `validationIssues`,
32
+ * `retryAfterSeconds`), plus the HTTP `status` when there was a response. A failure with no envelope
33
+ * (a proxy's HTML error page, a dropped connection) carries a `message` and `retryable` only.
34
+ */
35
+ type OutlitPiToolError = Partial<ToolGatewayErrorEnvelope> & {
36
+ message: string;
37
+ retryable: boolean;
38
+ status?: number;
39
+ };
15
40
  type OutlitPiToolDetails = {
16
41
  toolName: PiToolName;
42
+ /** The tool's result; `{ error }` when the call failed (see `error`). */
17
43
  result: unknown;
44
+ /** Set when the call failed at the gateway or the network; the agent sees it as the tool result. */
45
+ error?: OutlitPiToolError;
46
+ /** Core's `outlit-request-id` for this call, success or failure: quote it when reporting a problem. */
47
+ requestId?: string;
48
+ /** Core's `outlit-version`: the dated output version that answered. */
49
+ version?: string;
18
50
  };
19
51
  type OutlitPiToolDefinition = ToolDefinition<TSchema, OutlitPiToolDetails>;
20
52
  declare function createOutlitPiExtension(options?: OutlitPiExtensionOptions): (pi: OutlitPiRegistry) => void;
@@ -27,4 +59,4 @@ type PublicToolName = PiToolName;
27
59
 
28
60
  declare const _default: (pi: OutlitPiRegistry) => void;
29
61
 
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 };
62
+ export { OUTLIT_API_KEY_ENV, OUTLIT_API_URL_ENV, OUTLIT_PI_CLIENT, type OutlitPiExtensionOptions, type OutlitPiRegistry, type OutlitPiToolDefinition, type OutlitPiToolDetails, type OutlitPiToolError, type PublicToolName, createOutlitPiExtension, createOutlitPiTool, createOutlitPiTools, _default as default, formatOutlitToolLabel, piDefaultToolNames };