@treeship/sdk 0.1.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/attest.d.ts +7 -0
- package/dist/attest.js +49 -0
- package/dist/dock.d.ts +10 -0
- package/dist/dock.js +26 -0
- package/dist/exec.d.ts +1 -0
- package/dist/exec.js +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -0
- package/dist/ship.d.ts +8 -0
- package/dist/ship.js +8 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.js +8 -0
- package/dist/verify.d.ts +4 -0
- package/dist/verify.js +11 -0
- package/package.json +34 -0
package/dist/attest.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ActionParams, ApprovalParams, HandoffParams, DecisionParams, ActionResult, ApprovalResult } from "./types.js";
|
|
2
|
+
export declare class AttestModule {
|
|
3
|
+
action(params: ActionParams): Promise<ActionResult>;
|
|
4
|
+
approval(params: ApprovalParams): Promise<ApprovalResult>;
|
|
5
|
+
handoff(params: HandoffParams): Promise<ActionResult>;
|
|
6
|
+
decision(params: DecisionParams): Promise<ActionResult>;
|
|
7
|
+
}
|
package/dist/attest.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { runTreeship } from "./exec.js";
|
|
2
|
+
export class AttestModule {
|
|
3
|
+
async action(params) {
|
|
4
|
+
const args = ["attest", "action", "--actor", params.actor, "--action", params.action, "--format", "json"];
|
|
5
|
+
if (params.parentId)
|
|
6
|
+
args.push("--parent", params.parentId);
|
|
7
|
+
if (params.approvalNonce)
|
|
8
|
+
args.push("--approval-nonce", params.approvalNonce);
|
|
9
|
+
if (params.meta)
|
|
10
|
+
args.push("--meta", JSON.stringify(params.meta));
|
|
11
|
+
const result = await runTreeship(args);
|
|
12
|
+
return { artifactId: (result.id || result.artifact_id) };
|
|
13
|
+
}
|
|
14
|
+
async approval(params) {
|
|
15
|
+
const args = ["attest", "approval", "--approver", params.approver, "--description", params.description, "--format", "json"];
|
|
16
|
+
if (params.expiresIn)
|
|
17
|
+
args.push("--expires", params.expiresIn);
|
|
18
|
+
const result = await runTreeship(args);
|
|
19
|
+
return { artifactId: (result.id || result.artifact_id), nonce: result.nonce };
|
|
20
|
+
}
|
|
21
|
+
async handoff(params) {
|
|
22
|
+
const args = ["attest", "handoff", "--from", params.from, "--to", params.to, "--artifacts", params.artifacts.join(","), "--format", "json"];
|
|
23
|
+
if (params.approvals?.length)
|
|
24
|
+
args.push("--approvals", params.approvals.join(","));
|
|
25
|
+
if (params.obligations?.length)
|
|
26
|
+
args.push("--obligations", params.obligations.join(","));
|
|
27
|
+
const result = await runTreeship(args);
|
|
28
|
+
return { artifactId: (result.id || result.artifact_id) };
|
|
29
|
+
}
|
|
30
|
+
async decision(params) {
|
|
31
|
+
const args = ["attest", "decision", "--actor", params.actor, "--format", "json"];
|
|
32
|
+
if (params.model)
|
|
33
|
+
args.push("--model", params.model);
|
|
34
|
+
if (params.tokensIn)
|
|
35
|
+
args.push("--tokens-in", String(params.tokensIn));
|
|
36
|
+
if (params.tokensOut)
|
|
37
|
+
args.push("--tokens-out", String(params.tokensOut));
|
|
38
|
+
if (params.promptDigest)
|
|
39
|
+
args.push("--prompt-digest", params.promptDigest);
|
|
40
|
+
if (params.summary)
|
|
41
|
+
args.push("--summary", params.summary);
|
|
42
|
+
if (params.confidence)
|
|
43
|
+
args.push("--confidence", String(params.confidence));
|
|
44
|
+
if (params.parentId)
|
|
45
|
+
args.push("--parent", params.parentId);
|
|
46
|
+
const result = await runTreeship(args);
|
|
47
|
+
return { artifactId: (result.id || result.artifact_id) };
|
|
48
|
+
}
|
|
49
|
+
}
|
package/dist/dock.d.ts
ADDED
package/dist/dock.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { runTreeship } from "./exec.js";
|
|
2
|
+
export class DockModule {
|
|
3
|
+
async push(id) {
|
|
4
|
+
const result = await runTreeship(["dock", "push", id, "--format", "json"]);
|
|
5
|
+
return {
|
|
6
|
+
hubUrl: (result.hub_url || result.url || ""),
|
|
7
|
+
rekorIndex: result.rekor_index,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
async pull(id) {
|
|
11
|
+
await runTreeship(["dock", "pull", id]);
|
|
12
|
+
}
|
|
13
|
+
async status() {
|
|
14
|
+
try {
|
|
15
|
+
const result = await runTreeship(["dock", "status", "--format", "json"]);
|
|
16
|
+
return {
|
|
17
|
+
docked: result.status === "docked",
|
|
18
|
+
endpoint: result.endpoint,
|
|
19
|
+
dockId: result.dock_id,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { docked: false };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTreeship(args: string[]): Promise<Record<string, unknown>>;
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { TreeshipError } from "./types.js";
|
|
4
|
+
const exec = promisify(execFile);
|
|
5
|
+
export async function runTreeship(args) {
|
|
6
|
+
try {
|
|
7
|
+
const { stdout } = await exec("treeship", args, {
|
|
8
|
+
timeout: 10_000,
|
|
9
|
+
env: { ...process.env },
|
|
10
|
+
});
|
|
11
|
+
return JSON.parse(stdout);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
15
|
+
throw new TreeshipError(`treeship ${args.slice(0, 2).join(" ")} failed: ${msg}`, args);
|
|
16
|
+
}
|
|
17
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ship } from "./ship.js";
|
|
2
|
+
export declare function ship(): Ship;
|
|
3
|
+
export { Ship } from "./ship.js";
|
|
4
|
+
export { AttestModule } from "./attest.js";
|
|
5
|
+
export { VerifyModule } from "./verify.js";
|
|
6
|
+
export { DockModule } from "./dock.js";
|
|
7
|
+
export * from "./types.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ship } from "./ship.js";
|
|
2
|
+
export function ship() {
|
|
3
|
+
return new Ship();
|
|
4
|
+
}
|
|
5
|
+
export { Ship } from "./ship.js";
|
|
6
|
+
export { AttestModule } from "./attest.js";
|
|
7
|
+
export { VerifyModule } from "./verify.js";
|
|
8
|
+
export { DockModule } from "./dock.js";
|
|
9
|
+
export * from "./types.js";
|
package/dist/ship.d.ts
ADDED
package/dist/ship.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface ActionParams {
|
|
2
|
+
actor: string;
|
|
3
|
+
action: string;
|
|
4
|
+
parentId?: string;
|
|
5
|
+
approvalNonce?: string;
|
|
6
|
+
meta?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ApprovalParams {
|
|
9
|
+
approver: string;
|
|
10
|
+
description: string;
|
|
11
|
+
expiresIn?: string;
|
|
12
|
+
scope?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface HandoffParams {
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
artifacts: string[];
|
|
18
|
+
approvals?: string[];
|
|
19
|
+
obligations?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface DecisionParams {
|
|
22
|
+
actor: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
modelVersion?: string;
|
|
25
|
+
tokensIn?: number;
|
|
26
|
+
tokensOut?: number;
|
|
27
|
+
promptDigest?: string;
|
|
28
|
+
summary?: string;
|
|
29
|
+
confidence?: number;
|
|
30
|
+
parentId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ActionResult {
|
|
33
|
+
artifactId: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ApprovalResult {
|
|
36
|
+
artifactId: string;
|
|
37
|
+
nonce: string;
|
|
38
|
+
}
|
|
39
|
+
export interface VerifyResult {
|
|
40
|
+
outcome: "pass" | "fail" | "error";
|
|
41
|
+
chain: number;
|
|
42
|
+
target: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PushResult {
|
|
45
|
+
hubUrl: string;
|
|
46
|
+
rekorIndex?: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class TreeshipError extends Error {
|
|
49
|
+
readonly args: string[];
|
|
50
|
+
constructor(message: string, args: string[]);
|
|
51
|
+
}
|
package/dist/types.js
ADDED
package/dist/verify.d.ts
ADDED
package/dist/verify.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { runTreeship } from "./exec.js";
|
|
2
|
+
export class VerifyModule {
|
|
3
|
+
async verify(id) {
|
|
4
|
+
const result = await runTreeship(["verify", id, "--format", "json"]);
|
|
5
|
+
return {
|
|
6
|
+
outcome: result.outcome === "pass" ? "pass" : result.outcome === "error" ? "error" : "fail",
|
|
7
|
+
chain: (result.total || result.chain || 1),
|
|
8
|
+
target: id,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@treeship/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for Treeship - portable trust receipts for agent workflows",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/zerkerlabs/treeship",
|
|
9
|
+
"directory": "packages/sdk-ts"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://treeship.dev",
|
|
12
|
+
"keywords": ["treeship", "attestation", "trust", "agents", "verification", "receipts"],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"test": "vitest run"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^25.5.0",
|
|
31
|
+
"typescript": "^5.7.0",
|
|
32
|
+
"vitest": "^3.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|