pika-shared 1.0.2 → 1.2.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/types/chatbot/chatbot-types.d.mts +815 -35
- package/dist/types/chatbot/chatbot-types.d.ts +815 -35
- package/dist/types/chatbot/chatbot-types.js +44 -4
- package/dist/types/chatbot/chatbot-types.js.map +1 -1
- package/dist/types/chatbot/chatbot-types.mjs +38 -5
- package/dist/types/chatbot/chatbot-types.mjs.map +1 -1
- package/dist/util/instruction-assistance-utils.d.mts +49 -0
- package/dist/util/instruction-assistance-utils.d.ts +49 -0
- package/dist/util/instruction-assistance-utils.js +133 -0
- package/dist/util/instruction-assistance-utils.js.map +1 -0
- package/dist/util/instruction-assistance-utils.mjs +129 -0
- package/dist/util/instruction-assistance-utils.mjs.map +1 -0
- package/dist/util/server-client-utils.d.mts +17 -1
- package/dist/util/server-client-utils.d.ts +17 -1
- package/dist/util/server-client-utils.js +63 -0
- package/dist/util/server-client-utils.js.map +1 -1
- package/dist/util/server-client-utils.mjs +62 -1
- package/dist/util/server-client-utils.mjs.map +1 -1
- package/package.json +8 -1
- package/readme.md +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/server-client-utils.ts"],"names":[],"mappings":";AAUA,SAAS,UAAA,CAAW,MAAW,kBAA4C,EAAA;AACvE,EAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAU,EAAA;AACnC,IAAO,OAAA,IAAA;AAAA;AAGX,EAAA,MAAM,aAAa,KAAM,CAAA,OAAA,CAAQ,kBAAkB,CAAI,GAAA,kBAAA,GAAqB,CAAC,kBAAkB,CAAA;AAC/F,EAAM,MAAA,QAAA,GAAW,EAAE,GAAG,IAAK,EAAA;AAE3B,EAAA,KAAA,MAAW,QAAQ,UAAY,EAAA;AAC3B,IAAA,IAAI,QAAQ,QAAU,EAAA;AAClB,MAAA,QAAA,CAAS,IAAI,CAAA,GAAI,WAAY,CAAA,QAAA,CAAS,IAAI,CAAC,CAAA;AAAA;AAC/C;AAGJ,EAAO,OAAA,QAAA;AACX;AAOA,SAAS,YAAY,KAAiB,EAAA;AAClC,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC3B,IAAO,OAAA,YAAA;AAAA,GACA,MAAA,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AAC7B,IAAA,OAAO,MAAM,GAAI,CAAA,CAAC,IAAS,KAAA,WAAA,CAAY,IAAI,CAAC,CAAA;AAAA,GACrC,MAAA,IAAA,KAAA,IAAS,OAAO,KAAA,KAAU,QAAU,EAAA;AAC3C,IAAA,MAAM,cAAmB,EAAC;AAC1B,IAAA,KAAA,MAAW,OAAO,KAAO,EAAA;AACrB,MAAI,IAAA,KAAA,CAAM,cAAe,CAAA,GAAG,CAAG,EAAA;AAC3B,QAAA,WAAA,CAAY,GAAG,CAAA,GAAI,WAAY,CAAA,KAAA,CAAM,GAAG,CAAC,CAAA;AAAA;AAC7C;AAEJ,IAAO,OAAA,WAAA;AAAA;AAEX,EAAO,OAAA,KAAA;AACX","file":"server-client-utils.mjs","sourcesContent":["/*\n * These are utils that are safe to use both on the server and the client.\n */\n\n/**\n * Helper function to redact sensitive data from specified attributes\n * @param data - The object containing data to redact\n * @param attributesToRedact - Single attribute name or array of attribute names to redact\n * @returns A new object with specified attributes redacted\n */\nfunction redactData(data: any, attributesToRedact: string | string[]): any {\n if (!data || typeof data !== 'object') {\n return data;\n }\n\n const attributes = Array.isArray(attributesToRedact) ? attributesToRedact : [attributesToRedact];\n const redacted = { ...data };\n\n for (const attr of attributes) {\n if (attr in redacted) {\n redacted[attr] = redactValue(redacted[attr]);\n }\n }\n\n return redacted;\n}\n\n/**\n * Recursively redacts a value based on its type\n * @param value - The value to redact\n * @returns The redacted value\n */\nfunction redactValue(value: any): any {\n if (typeof value === 'string') {\n return '[REDACTED]';\n } else if (Array.isArray(value)) {\n return value.map((item) => redactValue(item));\n } else if (value && typeof value === 'object') {\n const redactedObj: any = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n redactedObj[key] = redactValue(value[key]);\n }\n }\n return redactedObj;\n }\n return value; // Return as-is for other types (numbers, booleans, null, etc.)\n}\n\n// Export both functions\nexport { redactData, redactValue };\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/server-client-utils.ts"],"names":[],"mappings":";AAUA,SAAS,UAAA,CAAW,MAAW,kBAA4C,EAAA;AACvE,EAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAU,EAAA;AACnC,IAAO,OAAA,IAAA;AAAA;AAGX,EAAA,MAAM,aAAa,KAAM,CAAA,OAAA,CAAQ,kBAAkB,CAAI,GAAA,kBAAA,GAAqB,CAAC,kBAAkB,CAAA;AAC/F,EAAM,MAAA,QAAA,GAAW,EAAE,GAAG,IAAK,EAAA;AAE3B,EAAA,KAAA,MAAW,QAAQ,UAAY,EAAA;AAC3B,IAAA,IAAI,QAAQ,QAAU,EAAA;AAClB,MAAA,QAAA,CAAS,IAAI,CAAA,GAAI,WAAY,CAAA,QAAA,CAAS,IAAI,CAAC,CAAA;AAAA;AAC/C;AAGJ,EAAO,OAAA,QAAA;AACX;AAOA,SAAS,YAAY,KAAiB,EAAA;AAClC,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC3B,IAAO,OAAA,YAAA;AAAA,GACA,MAAA,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AAC7B,IAAA,OAAO,MAAM,GAAI,CAAA,CAAC,IAAS,KAAA,WAAA,CAAY,IAAI,CAAC,CAAA;AAAA,GACrC,MAAA,IAAA,KAAA,IAAS,OAAO,KAAA,KAAU,QAAU,EAAA;AAC3C,IAAA,MAAM,cAAmB,EAAC;AAC1B,IAAA,KAAA,MAAW,OAAO,KAAO,EAAA;AACrB,MAAI,IAAA,KAAA,CAAM,cAAe,CAAA,GAAG,CAAG,EAAA;AAC3B,QAAA,WA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S,CAAA,YAAY,IAAI,YAAe,GAAA,UAAA;AAEnF,IAAO,OAAA;AAAA,MACH,SAAW,EAAA,SAAA;AAAA,MACX;AAAA,KACJ;AAAA;AAGJ,EAAA,MAAM,IAAI,KAAA,CAAM,CAA6B,0BAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AACxD","file":"server-client-utils.mjs","sourcesContent":["/*\n * These are utils that are safe to use both on the server and the client.\n */\n\n/**\n * Helper function to redact sensitive data from specified attributes\n * @param data - The object containing data to redact\n * @param attributesToRedact - Single attribute name or array of attribute names to redact\n * @returns A new object with specified attributes redacted\n */\nfunction redactData(data: any, attributesToRedact: string | string[]): any {\n if (!data || typeof data !== 'object') {\n return data;\n }\n\n const attributes = Array.isArray(attributesToRedact) ? attributesToRedact : [attributesToRedact];\n const redacted = { ...data };\n\n for (const attr of attributes) {\n if (attr in redacted) {\n redacted[attr] = redactValue(redacted[attr]);\n }\n }\n\n return redacted;\n}\n\n/**\n * Recursively redacts a value based on its type\n * @param value - The value to redact\n * @returns The redacted value\n */\nfunction redactValue(value: any): any {\n if (typeof value === 'string') {\n return '[REDACTED]';\n } else if (Array.isArray(value)) {\n return value.map((item) => redactValue(item));\n } else if (value && typeof value === 'object') {\n const redactedObj: any = {};\n for (const key in value) {\n if (value.hasOwnProperty(key)) {\n redactedObj[key] = redactValue(value[key]);\n }\n }\n return redactedObj;\n }\n return value; // Return as-is for other types (numbers, booleans, null, etc.)\n}\n\n/**\n * Validates that a scope value doesn't contain the '#' character which is reserved for scope construction\n */\nfunction validateScopeValue(scopeValue: string | number | Record<string, string | number>, scopeType: string): void {\n if (typeof scopeValue === 'string' && scopeValue.includes('#')) {\n throw new Error(`Scope value cannot contain '#' character. Found in ${scopeType} scope value: ${scopeValue}`);\n }\n if (typeof scopeValue === 'object' && scopeValue !== null) {\n for (const [key, value] of Object.entries(scopeValue)) {\n if (typeof value === 'string' && value.includes('#')) {\n throw new Error(`Scope value cannot contain '#' character. Found in ${scopeType}.${key}: ${value}`);\n }\n }\n }\n}\n\n/**\n * Constructs a scope string from scopeType and scopeValue\n * @param scopeType - The type of scope (chatapp, agent, tool, entity, agent-entity)\n * @param scopeValue - The value(s) for the scope\n * @returns The constructed scope string\n */\nfunction constructScope(scopeType: string, scopeValue: string | number | Record<string, string | number>): string {\n // Validate scope value doesn't contain '#'\n validateScopeValue(scopeValue, scopeType);\n\n switch (scopeType) {\n case 'chatapp':\n case 'agent':\n case 'tool':\n case 'entity':\n return `${scopeType}#${scopeValue}`;\n case 'agent-entity':\n if (typeof scopeValue !== 'object' || scopeValue === null) {\n throw new Error('agent-entity scopeType requires an object with agent and entity properties');\n }\n\n const agentEntityValue = scopeValue as Record<string, string | number>;\n if (!('agent' in agentEntityValue) || !('entity' in agentEntityValue)) {\n throw new Error('agent-entity scopeType requires an object with both agent and entity properties');\n }\n\n return `agent#${agentEntityValue.agent}#entity#${agentEntityValue.entity}`;\n\n default:\n throw new Error(`Unsupported scopeType: ${scopeType}`);\n }\n}\n\n/**\n * Parses a scope string back into scopeType and scopeValue\n * @param scope - The scope string to parse\n * @returns Object containing scopeType and scopeValue\n */\nfunction parseScope(scope: string): { scopeType: string; scopeValue: string | number | Record<string, string | number> } {\n if (!scope || typeof scope !== 'string') {\n throw new Error('Invalid scope: must be a non-empty string');\n }\n\n const parts = scope.split('#');\n if (parts.length < 2) {\n throw new Error(`Invalid scope format: ${scope}. Expected format: scopeType#scopeValue`);\n }\n\n const [firstType, firstValue, ...remaining] = parts;\n\n // Handle compound scopes (agent-entity)\n if (remaining.length >= 2 && firstType === 'agent' && remaining[0] === 'entity') {\n return {\n scopeType: 'agent-entity',\n scopeValue: {\n agent: firstValue,\n entity: remaining[1]\n }\n };\n }\n\n // Handle simple scopes\n if (remaining.length === 0) {\n // For simple scopes, try to convert to number if it's numeric\n const numericValue = Number(firstValue);\n const scopeValue = !isNaN(numericValue) && isFinite(numericValue) ? numericValue : firstValue;\n\n return {\n scopeType: firstType,\n scopeValue: scopeValue\n };\n }\n\n throw new Error(`Unsupported scope format: ${scope}`);\n}\n\n// Export both functions\nexport { redactData, redactValue, constructScope, parseScope };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pika-shared",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,6 +32,13 @@
|
|
|
32
32
|
"typescript": "^5.9.2",
|
|
33
33
|
"@pika/typescript-config": "0.0.0"
|
|
34
34
|
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"pika",
|
|
37
|
+
"chatbot",
|
|
38
|
+
"agent",
|
|
39
|
+
"ai",
|
|
40
|
+
"chatapp"
|
|
41
|
+
],
|
|
35
42
|
"files": [
|
|
36
43
|
"dist/**"
|
|
37
44
|
],
|
package/readme.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
# Shared libraries go in here
|
|
2
2
|
|
|
3
3
|
This is mostly for shared types and utilities.
|
|
4
|
+
|
|
5
|
+
## Dev Instructions
|
|
6
|
+
|
|
7
|
+
To publish...
|
|
8
|
+
|
|
9
|
+
1. `pnpm run version:major` or `pnpm run version:minor` or `pnpm run version:patch`
|
|
10
|
+
2. commit and push changes
|
|
11
|
+
3. pnpm publish
|