@treeseed/sdk 0.13.0-rc.47 → 0.13.0-rc.49

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,44 @@
1
+ import { treeAiControlPlaneOperation } from "./catalog.js";
2
+ import { TREEAI_UPSTREAM_OPERATIONS } from "./generated/upstream.js";
3
+ class TreeSeedTreeAiClient {
4
+ constructor(direct, controlPlane, nodeId) {
5
+ this.direct = direct;
6
+ this.controlPlane = controlPlane;
7
+ this.nodeId = nodeId;
8
+ }
9
+ direct;
10
+ controlPlane;
11
+ nodeId;
12
+ operations = TREEAI_UPSTREAM_OPERATIONS;
13
+ static direct(options) {
14
+ return new TreeSeedTreeAiClient(options, null, null);
15
+ }
16
+ static controlPlane(client, nodeId) {
17
+ return new TreeSeedTreeAiClient(null, client, nodeId);
18
+ }
19
+ async invoke(operationId, input = {}, options = {}) {
20
+ const operation = TREEAI_UPSTREAM_OPERATIONS.find((item) => item.operationId === operationId);
21
+ if (!operation) throw new Error(`Unknown TreeAI operation ${operationId}.`);
22
+ if (this.controlPlane) {
23
+ const binding = treeAiControlPlaneOperation(operationId);
24
+ return this.controlPlane.invoke(binding, { path: { nodeId: this.nodeId, ...input.path ?? {} }, query: input.query ?? {}, body: operation.kind === "read" ? void 0 : input.body ?? {} }, options);
25
+ }
26
+ if (!this.direct) throw new Error("TreeAI transport is not configured.");
27
+ let path = operation.path;
28
+ for (const [name, value] of Object.entries(input.path ?? {})) path = path.replace(`{${name}}`, encodeURIComponent(String(value)));
29
+ if (/\{[^}]+\}/u.test(path)) throw new Error(`TreeAI operation ${operationId} is missing path parameters.`);
30
+ const url = new URL(path, `${this.direct.endpoints[operation.service].replace(/\/$/u, "")}/`);
31
+ for (const [name, value] of Object.entries(input.query ?? {})) if (value !== void 0) url.searchParams.set(name, String(value));
32
+ const token = typeof this.direct.token === "function" ? await this.direct.token() : this.direct.token;
33
+ const headers = new Headers(input.headers);
34
+ if (token) headers.set("authorization", `Bearer ${token}`);
35
+ if (input.body !== void 0) headers.set("content-type", "application/json");
36
+ const response = await (this.direct.fetch ?? fetch)(url, { method: operation.method, headers, body: input.body === void 0 ? void 0 : JSON.stringify(input.body) });
37
+ const payload = (response.headers.get("content-type") ?? "").includes("json") ? await response.json() : await response.text();
38
+ if (!response.ok) throw Object.assign(new Error(`TreeAI ${operationId} returned ${response.status}.`), { status: response.status, payload });
39
+ return payload;
40
+ }
41
+ }
42
+ export {
43
+ TreeSeedTreeAiClient
44
+ };
@@ -0,0 +1,42 @@
1
+ export declare const TREESEED_TREEAI_SERVICE_CONTRACT_SCHEMA: "treeseed.treeai-service-contract/v1";
2
+ export declare const TREEAI_ADOPTION: {
3
+ readonly release: "0.11.0-rc2";
4
+ readonly sourceCommit: "9770c99ba3a2f91ce916b48efafa45b0e971bbf0";
5
+ readonly packageArtifactDigest: "sha256:90d695d499088f2788da36863128efe57079915d3999cc876888ceb091cb95f2";
6
+ readonly operationInventoryDigest: "sha256:dc60eb514e11a4b867b3353830d886205df6254c7c4ecfab9a06b1b4dcb4e1fc";
7
+ };
8
+ export declare function validateTreeAiOperationMapping(): string[];
9
+ export declare function createTreeAiServiceContractReceipt(): Promise<{
10
+ readonly openapiVersion: "3.1.1";
11
+ readonly openapiDigests: {
12
+ readonly inference: "sha256:3a00f1d91635d87d0aad2c6d329f495ff210f393bc9851570aa3e3ad1f5c1db4";
13
+ readonly training: "sha256:89dc70cecc85079853e4f177827d681e66f4b24b93ef17713051b99f07c2fe00";
14
+ readonly lab: "sha256:bccafa27b00a63b9fb22b132b850f9af6e77d44047dbc8966344088266d65898";
15
+ readonly qualification: "sha256:3f68b78845ec19c5de389663f1cb677ab4df0683ecd113c4f5780885a89370b7";
16
+ };
17
+ readonly controlPlaneCatalogDigest: `sha256:${string}`;
18
+ readonly operationMapping: {
19
+ treeseedOperationId: `${string}.${string}`;
20
+ treeaiOperationId: string;
21
+ contractVersion: string;
22
+ contractDigest: `sha256:${string}`;
23
+ capability: string;
24
+ authentication: import("../operator-contracts/control-plane-operation.js").ControlPlaneAuthenticationKind;
25
+ oauthScopes: ("treeseed:read" | "treeseed:knowledge:write" | "treeseed:governance:write" | "treeseed:projects:write" | "treeseed:execution" | "treeseed:admin")[];
26
+ riskClass: import("../operator-contracts/control-plane-operation.js").ControlPlaneRiskClass;
27
+ idempotency: import("../operator-contracts/control-plane-operation.js").ControlPlaneIdempotencyContract;
28
+ concurrency: import("../operator-contracts/control-plane-operation.js").ControlPlaneConcurrencyContract;
29
+ surfaces: import("../operator-contracts/control-plane-operation.js").ControlPlaneOperationSurface[];
30
+ redactedPaths: string[];
31
+ }[];
32
+ readonly operationMappingDigest: `sha256:${string}`;
33
+ readonly compatibility: {
34
+ readonly direct: true;
35
+ readonly controlPlane: true;
36
+ };
37
+ readonly release: "0.11.0-rc2";
38
+ readonly sourceCommit: "9770c99ba3a2f91ce916b48efafa45b0e971bbf0";
39
+ readonly packageArtifactDigest: "sha256:90d695d499088f2788da36863128efe57079915d3999cc876888ceb091cb95f2";
40
+ readonly operationInventoryDigest: "sha256:dc60eb514e11a4b867b3353830d886205df6254c7c4ecfab9a06b1b4dcb4e1fc";
41
+ readonly schema: "treeseed.treeai-service-contract/v1";
42
+ }>;
@@ -0,0 +1,51 @@
1
+ import { CONTROL_PLANE_CATALOG } from "../operator-contracts/control-plane-operations.js";
2
+ import { standardsSha256 } from "../standards/canonicalize.js";
3
+ import { TREEAI_CONTROL_PLANE_OPERATION_LIST, TREEAI_OPENAPI_DIGESTS } from "./catalog.js";
4
+ import { TREEAI_UPSTREAM_OPERATIONS } from "./generated/upstream.js";
5
+ const TREESEED_TREEAI_SERVICE_CONTRACT_SCHEMA = "treeseed.treeai-service-contract/v1";
6
+ const TREEAI_ADOPTION = {
7
+ release: "0.11.0-rc2",
8
+ sourceCommit: "9770c99ba3a2f91ce916b48efafa45b0e971bbf0",
9
+ packageArtifactDigest: "sha256:90d695d499088f2788da36863128efe57079915d3999cc876888ceb091cb95f2",
10
+ operationInventoryDigest: "sha256:dc60eb514e11a4b867b3353830d886205df6254c7c4ecfab9a06b1b4dcb4e1fc"
11
+ };
12
+ function validateTreeAiOperationMapping() {
13
+ const authoritative = new Set(TREEAI_UPSTREAM_OPERATIONS.map(({ operationId }) => operationId));
14
+ const mapped = TREEAI_CONTROL_PLANE_OPERATION_LIST.map(({ descriptor }) => descriptor.upstream?.operationId).filter(Boolean);
15
+ return [
16
+ ...mapped.filter((id) => !authoritative.has(id)).map((id) => `unknown_upstream_operation:${id}`),
17
+ ...TREEAI_UPSTREAM_OPERATIONS.filter(({ operationId }) => !mapped.includes(operationId)).map(({ operationId }) => `unmapped_upstream_operation:${operationId}`)
18
+ ].sort();
19
+ }
20
+ async function createTreeAiServiceContractReceipt() {
21
+ const mapping = TREEAI_CONTROL_PLANE_OPERATION_LIST.map(({ descriptor }) => ({
22
+ treeseedOperationId: descriptor.operationId,
23
+ treeaiOperationId: descriptor.upstream.operationId,
24
+ contractVersion: descriptor.upstream.contractVersion,
25
+ contractDigest: descriptor.upstream.contractDigest,
26
+ capability: descriptor.capability,
27
+ authentication: descriptor.authentication,
28
+ oauthScopes: descriptor.oauthScopes,
29
+ riskClass: descriptor.riskClass,
30
+ idempotency: descriptor.idempotency,
31
+ concurrency: descriptor.concurrency,
32
+ surfaces: descriptor.surfaces,
33
+ redactedPaths: descriptor.redactedPaths
34
+ })).sort((left, right) => left.treeseedOperationId.localeCompare(right.treeseedOperationId));
35
+ return {
36
+ schema: TREESEED_TREEAI_SERVICE_CONTRACT_SCHEMA,
37
+ ...TREEAI_ADOPTION,
38
+ openapiVersion: "3.1.1",
39
+ openapiDigests: TREEAI_OPENAPI_DIGESTS,
40
+ controlPlaneCatalogDigest: await standardsSha256(CONTROL_PLANE_CATALOG),
41
+ operationMapping: mapping,
42
+ operationMappingDigest: await standardsSha256(mapping),
43
+ compatibility: { direct: true, controlPlane: true }
44
+ };
45
+ }
46
+ export {
47
+ TREEAI_ADOPTION,
48
+ TREESEED_TREEAI_SERVICE_CONTRACT_SCHEMA,
49
+ createTreeAiServiceContractReceipt,
50
+ validateTreeAiOperationMapping
51
+ };