@punktechnologies/sdk 0.1.0 → 0.1.1
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/LICENSE +75 -81
- package/README.md +216 -94
- package/SECURITY.md +11 -0
- package/dist/index.js +14 -4
- package/package.json +35 -19
- package/src/index.ts +1559 -0
- package/src/types.ts +512 -0
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var PUNK_CHORUS_MODEL = "punk/chorus";
|
|
|
3
3
|
var PUNK_MODEL = PUNK_CHORUS_MODEL;
|
|
4
4
|
var DEFAULT_BASE_URL = "http://localhost:4100";
|
|
5
5
|
var MAX_TOOL_CACHE_TTL_SECONDS = 24 * 60 * 60;
|
|
6
|
+
var MAX_TOOL_CACHE_DIMENSION_CHARS = 120;
|
|
6
7
|
function stringifyToolArguments(value) {
|
|
7
8
|
if (typeof value === "string")
|
|
8
9
|
return value;
|
|
@@ -613,9 +614,15 @@ function classifySdkToolSideEffect(toolName, declared) {
|
|
|
613
614
|
return inferred.matched ? Math.max(validDeclared, inferred.level) : validDeclared;
|
|
614
615
|
}
|
|
615
616
|
function normalizeTtlSeconds(value) {
|
|
616
|
-
if (
|
|
617
|
+
if (value === undefined)
|
|
617
618
|
return;
|
|
618
|
-
|
|
619
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
620
|
+
throw new Error("Punk traceTool requires 'ttlSeconds' to be a positive integer when provided");
|
|
621
|
+
}
|
|
622
|
+
if (value > MAX_TOOL_CACHE_TTL_SECONDS) {
|
|
623
|
+
throw new Error(`Punk traceTool requires 'ttlSeconds' to be ${MAX_TOOL_CACHE_TTL_SECONDS} or fewer`);
|
|
624
|
+
}
|
|
625
|
+
return value;
|
|
619
626
|
}
|
|
620
627
|
function cleanIdentityValue(value) {
|
|
621
628
|
if (typeof value !== "string")
|
|
@@ -627,8 +634,8 @@ function cleanOptionalCacheDimension(label, value) {
|
|
|
627
634
|
if (typeof value !== "string")
|
|
628
635
|
return;
|
|
629
636
|
const trimmed = value.trim();
|
|
630
|
-
if (trimmed.length === 0 || trimmed !== value || trimmed.length >
|
|
631
|
-
throw new Error(`Punk traceTool requires '${label}' to be a non-empty trimmed string
|
|
637
|
+
if (trimmed.length === 0 || trimmed !== value || trimmed.length > MAX_TOOL_CACHE_DIMENSION_CHARS) {
|
|
638
|
+
throw new Error(`Punk traceTool requires '${label}' to be a non-empty trimmed string ${MAX_TOOL_CACHE_DIMENSION_CHARS} characters or fewer`);
|
|
632
639
|
}
|
|
633
640
|
return trimmed;
|
|
634
641
|
}
|
|
@@ -640,6 +647,9 @@ function requireCleanToolName(value) {
|
|
|
640
647
|
if (!trimmed) {
|
|
641
648
|
throw new Error("Punk traceTool requires a non-empty tool name");
|
|
642
649
|
}
|
|
650
|
+
if (trimmed.length > MAX_TOOL_CACHE_DIMENSION_CHARS) {
|
|
651
|
+
throw new Error(`Punk traceTool requires a tool name ${MAX_TOOL_CACHE_DIMENSION_CHARS} characters or fewer`);
|
|
652
|
+
}
|
|
643
653
|
return trimmed;
|
|
644
654
|
}
|
|
645
655
|
function toolErrorPayload(err) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@punktechnologies/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "OpenAI-compatible AI gateway SDK for agent tracing, tool caching, governance, observability, and cost optimization.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"packageManager": "bun@1.3.5",
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"README.md",
|
|
20
|
-
"LICENSE"
|
|
21
|
-
],
|
|
22
17
|
"sideEffects": false,
|
|
23
18
|
"engines": {
|
|
24
19
|
"node": ">=18"
|
|
25
20
|
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"SECURITY.md"
|
|
27
|
+
],
|
|
26
28
|
"scripts": {
|
|
27
29
|
"build": "bun build src/index.ts --outdir dist --target node --format esm && tsc -p tsconfig.build.json",
|
|
28
30
|
"test": "bun test",
|
|
@@ -31,34 +33,48 @@
|
|
|
31
33
|
"prepack": "bun run build",
|
|
32
34
|
"prepublishOnly": "bun run build && bun run test && bun run typecheck"
|
|
33
35
|
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
36
|
-
},
|
|
37
36
|
"repository": {
|
|
38
37
|
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/PunkTechnologies/punk
|
|
38
|
+
"url": "git+https://github.com/PunkTechnologies/punk.git",
|
|
39
|
+
"directory": "packages/sdk"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
|
-
"url": "https://github.com/PunkTechnologies/punk
|
|
42
|
+
"url": "https://github.com/PunkTechnologies/punk/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://punktechnologies.com/docs/sdk",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"provenance": true
|
|
43
48
|
},
|
|
44
|
-
"homepage": "https://punktechnologies.com",
|
|
45
49
|
"keywords": [
|
|
46
50
|
"ai",
|
|
51
|
+
"ai-gateway",
|
|
47
52
|
"agents",
|
|
53
|
+
"agent-observability",
|
|
54
|
+
"agent-runtime",
|
|
48
55
|
"llm",
|
|
56
|
+
"llm-gateway",
|
|
57
|
+
"llm-router",
|
|
58
|
+
"model-router",
|
|
49
59
|
"gateway",
|
|
60
|
+
"openai",
|
|
50
61
|
"openai-compatible",
|
|
51
62
|
"anthropic",
|
|
63
|
+
"claude",
|
|
64
|
+
"vercel-ai-sdk",
|
|
65
|
+
"langchain",
|
|
66
|
+
"mcp",
|
|
52
67
|
"caching",
|
|
68
|
+
"semantic-cache",
|
|
69
|
+
"tool-calling",
|
|
70
|
+
"tool-caching",
|
|
53
71
|
"tracing",
|
|
54
72
|
"observability",
|
|
55
73
|
"governance",
|
|
74
|
+
"guardrails",
|
|
75
|
+
"policy",
|
|
76
|
+
"cost-optimization",
|
|
56
77
|
"side-effects",
|
|
57
78
|
"punk"
|
|
58
|
-
]
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@types/bun": "^1.2.0",
|
|
61
|
-
"@types/node": "^25.9.2",
|
|
62
|
-
"typescript": "^5.7.0"
|
|
63
|
-
}
|
|
79
|
+
]
|
|
64
80
|
}
|