@outlit/pi 0.1.5 → 1.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 +7 -7
- package/dist/extension.cjs +7 -4
- package/dist/extension.cjs.map +1 -1
- package/dist/extension.js +13 -11
- package/dist/extension.js.map +1 -1
- package/dist/index.cjs +13 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/outlit/SKILL.md +1 -0
package/README.md
CHANGED
|
@@ -28,18 +28,18 @@ The default extension registers the default customer intelligence tools from `@o
|
|
|
28
28
|
- `outlit_list_facts`
|
|
29
29
|
- `outlit_get_fact`
|
|
30
30
|
- `outlit_get_source`
|
|
31
|
+
- `outlit_list_sources`
|
|
31
32
|
- `outlit_search_customer_context`
|
|
32
|
-
- `outlit_send_notification`
|
|
33
33
|
|
|
34
|
-
SQL
|
|
34
|
+
SQL and the other customer-facing 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 the full public catalog with `allPublicToolNames`, including safe integration setup, destination, activation, and workspace-settings actions. Responsibility-only and other internal commands are never part of that public catalog.
|
|
35
35
|
|
|
36
|
-
For analytical agents that need cohorts, usage trends, revenue filters, activation gaps, or aggregate checks, import `
|
|
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
|
|
|
38
38
|
```ts
|
|
39
|
-
import {
|
|
39
|
+
import { analyticalToolNames, createOutlitPiExtension } from "@outlit/pi"
|
|
40
40
|
|
|
41
41
|
export default createOutlitPiExtension({
|
|
42
|
-
toolNames:
|
|
42
|
+
toolNames: analyticalToolNames,
|
|
43
43
|
})
|
|
44
44
|
```
|
|
45
45
|
|
|
@@ -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 { allPublicToolNames, createOutlitPiExtension } from "@outlit/pi"
|
|
64
64
|
|
|
65
65
|
export default createOutlitPiExtension({
|
|
66
|
-
toolNames:
|
|
66
|
+
toolNames: allPublicToolNames,
|
|
67
67
|
})
|
|
68
68
|
```
|
|
69
69
|
|
package/dist/extension.cjs
CHANGED
|
@@ -42,7 +42,10 @@ function createOutlitPiTools(options = {}) {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
function createOutlitPiTool(toolName, options = {}) {
|
|
45
|
-
|
|
45
|
+
if (!(0, import_tools.isPublicToolName)(toolName)) {
|
|
46
|
+
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
47
|
+
}
|
|
48
|
+
const contract = (0, import_tools.getPublicToolContract)(toolName);
|
|
46
49
|
const label = formatOutlitToolLabel(toolName);
|
|
47
50
|
return {
|
|
48
51
|
name: toolName,
|
|
@@ -72,10 +75,10 @@ function formatOutlitToolLabel(toolName) {
|
|
|
72
75
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
73
76
|
}
|
|
74
77
|
function resolveToolNames(toolNames) {
|
|
75
|
-
const names = toolNames ?? import_tools.
|
|
78
|
+
const names = toolNames ?? import_tools.defaultToolNames;
|
|
76
79
|
return [...new Set(names)].map((name) => {
|
|
77
|
-
if (!(0, import_tools.
|
|
78
|
-
throw new Error(`Unknown Outlit
|
|
80
|
+
if (!(0, import_tools.isPublicToolName)(name)) {
|
|
81
|
+
throw new Error(`Unknown Outlit public tool: ${name}`);
|
|
79
82
|
}
|
|
80
83
|
return name;
|
|
81
84
|
});
|
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
|
|
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 PublicToolName,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PublicToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PublicToolName\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: PublicToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${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: PublicToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PublicToolName[] | undefined): PublicToolName[] {\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: PublicToolName,\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 { PublicToolName } from \"@outlit/tools\"\nexport {\n allPublicToolNames,\n analyticalToolNames,\n defaultToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAQO;AAqJP,IAAAA,gBAKO;AAvJA,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAkB3B,SAAS,wBAAwB,UAAoC,CAAC,GAAG;AAC9E,SAAO,SAAS,kBAAkB,IAAsB;AACtD,eAAW,QAAQ,oBAAoB,OAAO,GAAG;AAC/C,SAAG,aAAa,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAEO,SAAS,oBACd,UAAoC,CAAC,GACX;AAC1B,SAAO,iBAAiB,QAAQ,SAAS,EAAE;AAAA,IAAI,CAAC,aAC9C,mBAAmB,UAAU,OAAO;AAAA,EACtC;AACF;AAEO,SAAS,mBACd,UACA,UAAoC,CAAC,GACb;AACxB,MAAI,KAAC,+BAAiB,QAAQ,GAAG;AAC/B,UAAM,IAAI,MAAM,+BAA+B,QAAQ,EAAE;AAAA,EAC3D;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,MAA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AgB,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;AAUA,IAAO,cAAQ,wBAAwB;;;ADnKvC,IAAO,oBAAQ,wBAAwB;","names":["import_tools"]}
|
package/dist/extension.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createOutlitClient,
|
|
4
4
|
DEFAULT_OUTLIT_API_URL,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
defaultToolNames,
|
|
6
|
+
getPublicToolContract,
|
|
7
|
+
isPublicToolName
|
|
8
8
|
} from "@outlit/tools";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
defaultAgentToolNames as defaultAgentToolNames2,
|
|
10
|
+
allPublicToolNames,
|
|
11
|
+
analyticalToolNames,
|
|
12
|
+
defaultToolNames as defaultToolNames2,
|
|
14
13
|
sqlToolNames
|
|
15
14
|
} from "@outlit/tools";
|
|
16
15
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
@@ -28,7 +27,10 @@ function createOutlitPiTools(options = {}) {
|
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
29
|
function createOutlitPiTool(toolName, options = {}) {
|
|
31
|
-
|
|
30
|
+
if (!isPublicToolName(toolName)) {
|
|
31
|
+
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
32
|
+
}
|
|
33
|
+
const contract = getPublicToolContract(toolName);
|
|
32
34
|
const label = formatOutlitToolLabel(toolName);
|
|
33
35
|
return {
|
|
34
36
|
name: toolName,
|
|
@@ -58,10 +60,10 @@ function formatOutlitToolLabel(toolName) {
|
|
|
58
60
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
59
61
|
}
|
|
60
62
|
function resolveToolNames(toolNames) {
|
|
61
|
-
const names = toolNames ??
|
|
63
|
+
const names = toolNames ?? defaultToolNames;
|
|
62
64
|
return [...new Set(names)].map((name) => {
|
|
63
|
-
if (!
|
|
64
|
-
throw new Error(`Unknown Outlit
|
|
65
|
+
if (!isPublicToolName(name)) {
|
|
66
|
+
throw new Error(`Unknown Outlit public tool: ${name}`);
|
|
65
67
|
}
|
|
66
68
|
return name;
|
|
67
69
|
});
|
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
|
|
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 PublicToolName,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PublicToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PublicToolName\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: PublicToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${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: PublicToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PublicToolName[] | undefined): PublicToolName[] {\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: PublicToolName,\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 { PublicToolName } from \"@outlit/tools\"\nexport {\n allPublicToolNames,\n analyticalToolNames,\n defaultToolNames,\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,OAGK;AAqJP;AAAA,EACE;AA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AA,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;AAUA,IAAO,cAAQ,wBAAwB;;;ACnKvC,IAAO,oBAAQ,wBAAwB;","names":["defaultToolNames"]}
|
package/dist/index.cjs
CHANGED
|
@@ -22,14 +22,13 @@ 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
|
-
|
|
26
|
-
|
|
27
|
-
analyticalAgentToolNames: () => import_tools2.analyticalAgentToolNames,
|
|
25
|
+
allPublicToolNames: () => import_tools2.allPublicToolNames,
|
|
26
|
+
analyticalToolNames: () => import_tools2.analyticalToolNames,
|
|
28
27
|
createOutlitPiExtension: () => createOutlitPiExtension,
|
|
29
28
|
createOutlitPiTool: () => createOutlitPiTool,
|
|
30
29
|
createOutlitPiTools: () => createOutlitPiTools,
|
|
31
30
|
default: () => src_default,
|
|
32
|
-
|
|
31
|
+
defaultToolNames: () => import_tools2.defaultToolNames,
|
|
33
32
|
formatOutlitToolLabel: () => formatOutlitToolLabel,
|
|
34
33
|
sqlToolNames: () => import_tools2.sqlToolNames
|
|
35
34
|
});
|
|
@@ -51,7 +50,10 @@ function createOutlitPiTools(options = {}) {
|
|
|
51
50
|
);
|
|
52
51
|
}
|
|
53
52
|
function createOutlitPiTool(toolName, options = {}) {
|
|
54
|
-
|
|
53
|
+
if (!(0, import_tools.isPublicToolName)(toolName)) {
|
|
54
|
+
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
55
|
+
}
|
|
56
|
+
const contract = (0, import_tools.getPublicToolContract)(toolName);
|
|
55
57
|
const label = formatOutlitToolLabel(toolName);
|
|
56
58
|
return {
|
|
57
59
|
name: toolName,
|
|
@@ -81,10 +83,10 @@ function formatOutlitToolLabel(toolName) {
|
|
|
81
83
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
82
84
|
}
|
|
83
85
|
function resolveToolNames(toolNames) {
|
|
84
|
-
const names = toolNames ?? import_tools.
|
|
86
|
+
const names = toolNames ?? import_tools.defaultToolNames;
|
|
85
87
|
return [...new Set(names)].map((name) => {
|
|
86
|
-
if (!(0, import_tools.
|
|
87
|
-
throw new Error(`Unknown Outlit
|
|
88
|
+
if (!(0, import_tools.isPublicToolName)(name)) {
|
|
89
|
+
throw new Error(`Unknown Outlit public tool: ${name}`);
|
|
88
90
|
}
|
|
89
91
|
return name;
|
|
90
92
|
});
|
|
@@ -129,13 +131,12 @@ var src_default = createOutlitPiExtension();
|
|
|
129
131
|
0 && (module.exports = {
|
|
130
132
|
OUTLIT_API_KEY_ENV,
|
|
131
133
|
OUTLIT_API_URL_ENV,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
analyticalAgentToolNames,
|
|
134
|
+
allPublicToolNames,
|
|
135
|
+
analyticalToolNames,
|
|
135
136
|
createOutlitPiExtension,
|
|
136
137
|
createOutlitPiTool,
|
|
137
138
|
createOutlitPiTools,
|
|
138
|
-
|
|
139
|
+
defaultToolNames,
|
|
139
140
|
formatOutlitToolLabel,
|
|
140
141
|
sqlToolNames
|
|
141
142
|
});
|
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
|
|
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 PublicToolName,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PublicToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PublicToolName\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: PublicToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${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: PublicToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PublicToolName[] | undefined): PublicToolName[] {\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: PublicToolName,\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 { PublicToolName } from \"@outlit/tools\"\nexport {\n allPublicToolNames,\n analyticalToolNames,\n defaultToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";;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,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;AAUA,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, PublicToolName } from '@outlit/tools';
|
|
3
|
+
export { PublicToolName, allPublicToolNames, analyticalToolNames, defaultToolNames, 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,18 +9,18 @@ type OutlitPiExtensionOptions = {
|
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
fetch?: OutlitToolsFetch;
|
|
12
|
-
toolNames?: readonly
|
|
12
|
+
toolNames?: readonly PublicToolName[];
|
|
13
13
|
};
|
|
14
14
|
type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
|
|
15
15
|
type OutlitPiToolDetails = {
|
|
16
|
-
toolName:
|
|
16
|
+
toolName: PublicToolName;
|
|
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: PublicToolName, options?: OutlitPiExtensionOptions): OutlitPiToolDefinition;
|
|
23
|
+
declare function formatOutlitToolLabel(toolName: PublicToolName): string;
|
|
24
24
|
|
|
25
25
|
declare const _default: (pi: OutlitPiRegistry) => void;
|
|
26
26
|
|
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, PublicToolName } from '@outlit/tools';
|
|
3
|
+
export { PublicToolName, allPublicToolNames, analyticalToolNames, defaultToolNames, 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,18 +9,18 @@ type OutlitPiExtensionOptions = {
|
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
fetch?: OutlitToolsFetch;
|
|
12
|
-
toolNames?: readonly
|
|
12
|
+
toolNames?: readonly PublicToolName[];
|
|
13
13
|
};
|
|
14
14
|
type OutlitPiRegistry = Pick<ExtensionAPI, "registerTool">;
|
|
15
15
|
type OutlitPiToolDetails = {
|
|
16
|
-
toolName:
|
|
16
|
+
toolName: PublicToolName;
|
|
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: PublicToolName, options?: OutlitPiExtensionOptions): OutlitPiToolDefinition;
|
|
23
|
+
declare function formatOutlitToolLabel(toolName: PublicToolName): string;
|
|
24
24
|
|
|
25
25
|
declare const _default: (pi: OutlitPiRegistry) => void;
|
|
26
26
|
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createOutlitClient,
|
|
4
4
|
DEFAULT_OUTLIT_API_URL,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
defaultToolNames,
|
|
6
|
+
getPublicToolContract,
|
|
7
|
+
isPublicToolName
|
|
8
8
|
} from "@outlit/tools";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
defaultAgentToolNames as defaultAgentToolNames2,
|
|
10
|
+
allPublicToolNames,
|
|
11
|
+
analyticalToolNames,
|
|
12
|
+
defaultToolNames as defaultToolNames2,
|
|
14
13
|
sqlToolNames
|
|
15
14
|
} from "@outlit/tools";
|
|
16
15
|
var OUTLIT_API_KEY_ENV = "OUTLIT_API_KEY";
|
|
@@ -28,7 +27,10 @@ function createOutlitPiTools(options = {}) {
|
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
29
|
function createOutlitPiTool(toolName, options = {}) {
|
|
31
|
-
|
|
30
|
+
if (!isPublicToolName(toolName)) {
|
|
31
|
+
throw new Error(`Unknown Outlit public tool: ${toolName}`);
|
|
32
|
+
}
|
|
33
|
+
const contract = getPublicToolContract(toolName);
|
|
32
34
|
const label = formatOutlitToolLabel(toolName);
|
|
33
35
|
return {
|
|
34
36
|
name: toolName,
|
|
@@ -58,10 +60,10 @@ function formatOutlitToolLabel(toolName) {
|
|
|
58
60
|
return toolName.split("_").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
59
61
|
}
|
|
60
62
|
function resolveToolNames(toolNames) {
|
|
61
|
-
const names = toolNames ??
|
|
63
|
+
const names = toolNames ?? defaultToolNames;
|
|
62
64
|
return [...new Set(names)].map((name) => {
|
|
63
|
-
if (!
|
|
64
|
-
throw new Error(`Unknown Outlit
|
|
65
|
+
if (!isPublicToolName(name)) {
|
|
66
|
+
throw new Error(`Unknown Outlit public tool: ${name}`);
|
|
65
67
|
}
|
|
66
68
|
return name;
|
|
67
69
|
});
|
|
@@ -105,14 +107,13 @@ var src_default = createOutlitPiExtension();
|
|
|
105
107
|
export {
|
|
106
108
|
OUTLIT_API_KEY_ENV,
|
|
107
109
|
OUTLIT_API_URL_ENV,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
analyticalAgentToolNames,
|
|
110
|
+
allPublicToolNames,
|
|
111
|
+
analyticalToolNames,
|
|
111
112
|
createOutlitPiExtension,
|
|
112
113
|
createOutlitPiTool,
|
|
113
114
|
createOutlitPiTools,
|
|
114
115
|
src_default as default,
|
|
115
|
-
|
|
116
|
+
defaultToolNames2 as defaultToolNames,
|
|
116
117
|
formatOutlitToolLabel,
|
|
117
118
|
sqlToolNames
|
|
118
119
|
};
|
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
|
|
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 PublicToolName,\n} from \"@outlit/tools\"\nimport type { TSchema } from \"@sinclair/typebox\"\n\nexport const OUTLIT_API_KEY_ENV = \"OUTLIT_API_KEY\"\nexport const OUTLIT_API_URL_ENV = \"OUTLIT_API_URL\"\n\nexport type OutlitPiExtensionOptions = {\n apiKey?: string\n baseUrl?: string\n fetch?: OutlitToolsFetch\n toolNames?: readonly PublicToolName[]\n}\n\nexport type OutlitPiRegistry = Pick<ExtensionAPI, \"registerTool\">\n\nexport type OutlitPiToolDetails = {\n toolName: PublicToolName\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: PublicToolName,\n options: OutlitPiExtensionOptions = {},\n): OutlitPiToolDefinition {\n if (!isPublicToolName(toolName)) {\n throw new Error(`Unknown Outlit public tool: ${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: PublicToolName): string {\n return toolName\n .split(\"_\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\" \")\n}\n\nfunction resolveToolNames(toolNames: readonly PublicToolName[] | undefined): PublicToolName[] {\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: PublicToolName,\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 { PublicToolName } from \"@outlit/tools\"\nexport {\n allPublicToolNames,\n analyticalToolNames,\n defaultToolNames,\n sqlToolNames,\n} from \"@outlit/tools\"\n\nexport default createOutlitPiExtension()\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAqJP;AAAA,EACE;AAAA,EACA;AAAA,EACA,oBAAAA;AAAA,EACA;AAAA,OACK;AAvJA,IAAM,qBAAqB;AAC3B,IAA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OAAuB;AACxC,SAAO,MAAM,MAAM,MAAM,CAAC,EAAE,CAAC,KAAK;AACpC;AAUA,IAAO,cAAQ,wBAAwB;","names":["defaultToolNames"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outlit/pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.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": "^0.
|
|
69
|
+
"@outlit/tools": "^1.0.0"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@mariozechner/pi-coding-agent": "*",
|
package/skills/outlit/SKILL.md
CHANGED
|
@@ -20,6 +20,7 @@ Do not invent customer state when Outlit can answer it. Call out sparse or messy
|
|
|
20
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
21
|
- Use `outlit_get_fact` when you already have a fact id and need the canonical fact payload.
|
|
22
22
|
- 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.
|
|
23
24
|
- Use `outlit_get_source` when a fact or search result needs stronger evidence from the underlying source artifact.
|
|
24
25
|
|
|
25
26
|
Use customer lookups before SQL. SQL is for aggregates, joins, cohorts, time-series analysis, and custom reporting.
|