@letsping/sdk 0.1.2 → 0.1.5

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.
@@ -0,0 +1,68 @@
1
+ export type Priority = "low" | "medium" | "high" | "critical";
2
+ /**
3
+ * Options for configuring a LetsPing approval request.
4
+ */
5
+ export interface RequestOptions {
6
+ /** Name of the agent or service (e.g., "billing-agent") */
7
+ service: string;
8
+ /** Specific action being requested (e.g., "refund_user") */
9
+ action: string;
10
+ /** The data payload to be reviewed by the human */
11
+ payload: Record<string, any>;
12
+ /** Urgency level affecting notification routing (default: "medium") */
13
+ priority?: Priority;
14
+ /** JSON Schema (Draft 7) for rendering a structured form in the dashboard */
15
+ schema?: Record<string, any>;
16
+ /** Maximum time to wait for approval in milliseconds (default: 24h) */
17
+ timeoutMs?: number;
18
+ /** (Enterprise) Specific role required for approval (e.g., "finance") */
19
+ role?: string;
20
+ }
21
+ /**
22
+ * The result of a human approval decision.
23
+ */
24
+ export interface Decision {
25
+ status: "APPROVED" | "REJECTED" | "APPROVED_WITH_MODIFICATIONS";
26
+ /** The original payload submitted */
27
+ payload: any;
28
+ /** The modified payload if the human edited values during approval */
29
+ patched_payload?: any;
30
+ /** Structural diff of the modifications */
31
+ diff_summary?: any;
32
+ metadata?: {
33
+ resolved_at: string;
34
+ actor_id: string;
35
+ method?: string;
36
+ };
37
+ }
38
+ export declare class LetsPingError extends Error {
39
+ status?: number | undefined;
40
+ constructor(message: string, status?: number | undefined);
41
+ }
42
+ export declare function computeDiff(original: any, patched: any): any;
43
+ export declare class LetsPing {
44
+ private readonly apiKey;
45
+ private readonly baseUrl;
46
+ private readonly encryptionKey;
47
+ /**
48
+ * @param apiKey Your LetsPing API key (or set LETSPING_API_KEY env var).
49
+ * @param options.encryptionKey
50
+ * Optional base64-encoded AES-256 key for payload encryption.
51
+ * If not provided here, the SDK reads LETSPING_ENCRYPTION_KEY from process.env.
52
+ * Generate once from the dashboard (Settings → Encryption).
53
+ * When set, all payloads are encrypted before leaving this process.
54
+ * LetsPing's backend never sees plaintext values.
55
+ */
56
+ constructor(apiKey?: string, options?: {
57
+ baseUrl?: string;
58
+ encryptionKey?: string;
59
+ });
60
+ private _encrypt;
61
+ private _decrypt;
62
+ ask(options: RequestOptions): Promise<Decision>;
63
+ defer(options: RequestOptions): Promise<{
64
+ id: string;
65
+ }>;
66
+ private request;
67
+ tool(service: string, action: string, priority?: Priority): (context: string | Record<string, any>) => Promise<string>;
68
+ }
package/package.json CHANGED
@@ -1,29 +1,38 @@
1
- {
2
- "name": "@letsping/sdk",
3
- "version": "0.1.2",
4
- "description": "The Human-in-the-Loop SDK for Autonomous Agents",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs"
13
- }
14
- },
15
- "scripts": {
16
- "build": "tsup",
17
- "dev": "tsup --watch",
18
- "clean": "rm -rf dist .turbo"
19
- },
20
- "dependencies": {},
21
- "devDependencies": {
22
- "tsup": "^8.0.0",
23
- "typescript": "^5.7.2",
24
- "@types/node": "^22.0.0"
25
- },
26
- "publishConfig": {
27
- "access": "public"
28
- }
1
+ {
2
+ "name": "@letsping/sdk",
3
+ "version": "0.1.5",
4
+ "description": "Behavioral Firewall and Cryo-Sleep State Parking for Autonomous Agents",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup && tsc --emitDeclarationOnly --outDir dist",
17
+ "dev": "tsup --watch",
18
+ "clean": "rm -rf dist .turbo"
19
+ },
20
+ "dependencies": {},
21
+ "peerDependencies": {
22
+ "@opentelemetry/api": "^1.0.0"
23
+ },
24
+ "peerDependenciesMeta": {
25
+ "@opentelemetry/api": {
26
+ "optional": true
27
+ }
28
+ },
29
+ "devDependencies": {
30
+ "tsup": "^8.0.0",
31
+ "typescript": "^5.7.2",
32
+ "@types/node": "^22.0.0",
33
+ "@opentelemetry/api": "^1.9.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
29
38
  }