@shardlink/agent-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/LICENSE +202 -0
- package/README.md +129 -0
- package/dist/client-quick-join.d.ts +38 -0
- package/dist/client-quick-join.d.ts.map +1 -0
- package/dist/client-quick-join.js +141 -0
- package/dist/client-quick-join.js.map +1 -0
- package/dist/client.d.ts +134 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +190 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +126 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +330 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/a2a.d.ts +42 -0
- package/dist/modules/a2a.d.ts.map +1 -0
- package/dist/modules/a2a.js +47 -0
- package/dist/modules/a2a.js.map +1 -0
- package/dist/modules/agents.d.ts +100 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +85 -0
- package/dist/modules/agents.js.map +1 -0
- package/dist/modules/auth.d.ts +49 -0
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +69 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/billing.d.ts +254 -0
- package/dist/modules/billing.d.ts.map +1 -0
- package/dist/modules/billing.js +203 -0
- package/dist/modules/billing.js.map +1 -0
- package/dist/modules/clans.d.ts +73 -0
- package/dist/modules/clans.d.ts.map +1 -0
- package/dist/modules/clans.js +94 -0
- package/dist/modules/clans.js.map +1 -0
- package/dist/modules/compliance.d.ts +97 -0
- package/dist/modules/compliance.d.ts.map +1 -0
- package/dist/modules/compliance.js +227 -0
- package/dist/modules/compliance.js.map +1 -0
- package/dist/modules/cross-plane.d.ts +164 -0
- package/dist/modules/cross-plane.d.ts.map +1 -0
- package/dist/modules/cross-plane.js +195 -0
- package/dist/modules/cross-plane.js.map +1 -0
- package/dist/modules/dashboard.d.ts +130 -0
- package/dist/modules/dashboard.d.ts.map +1 -0
- package/dist/modules/dashboard.js +120 -0
- package/dist/modules/dashboard.js.map +1 -0
- package/dist/modules/degradation.d.ts +120 -0
- package/dist/modules/degradation.d.ts.map +1 -0
- package/dist/modules/degradation.js +205 -0
- package/dist/modules/degradation.js.map +1 -0
- package/dist/modules/diagnostics-checks.d.ts +32 -0
- package/dist/modules/diagnostics-checks.d.ts.map +1 -0
- package/dist/modules/diagnostics-checks.js +231 -0
- package/dist/modules/diagnostics-checks.js.map +1 -0
- package/dist/modules/diagnostics-types.d.ts +118 -0
- package/dist/modules/diagnostics-types.d.ts.map +1 -0
- package/dist/modules/diagnostics-types.js +16 -0
- package/dist/modules/diagnostics-types.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +64 -0
- package/dist/modules/diagnostics.d.ts.map +1 -0
- package/dist/modules/diagnostics.js +206 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/discovery.d.ts +152 -0
- package/dist/modules/discovery.d.ts.map +1 -0
- package/dist/modules/discovery.js +100 -0
- package/dist/modules/discovery.js.map +1 -0
- package/dist/modules/fleets.d.ts +82 -0
- package/dist/modules/fleets.d.ts.map +1 -0
- package/dist/modules/fleets.js +33 -0
- package/dist/modules/fleets.js.map +1 -0
- package/dist/modules/lease-manager.d.ts +119 -0
- package/dist/modules/lease-manager.d.ts.map +1 -0
- package/dist/modules/lease-manager.js +242 -0
- package/dist/modules/lease-manager.js.map +1 -0
- package/dist/modules/leases.d.ts +70 -0
- package/dist/modules/leases.d.ts.map +1 -0
- package/dist/modules/leases.js +51 -0
- package/dist/modules/leases.js.map +1 -0
- package/dist/modules/operators.d.ts +176 -0
- package/dist/modules/operators.d.ts.map +1 -0
- package/dist/modules/operators.js +133 -0
- package/dist/modules/operators.js.map +1 -0
- package/dist/modules/providers.d.ts +141 -0
- package/dist/modules/providers.d.ts.map +1 -0
- package/dist/modules/providers.js +118 -0
- package/dist/modules/providers.js.map +1 -0
- package/dist/modules/quota.d.ts +102 -0
- package/dist/modules/quota.d.ts.map +1 -0
- package/dist/modules/quota.js +135 -0
- package/dist/modules/quota.js.map +1 -0
- package/dist/modules/reactions.d.ts +141 -0
- package/dist/modules/reactions.d.ts.map +1 -0
- package/dist/modules/reactions.js +122 -0
- package/dist/modules/reactions.js.map +1 -0
- package/dist/modules/register.d.ts +159 -0
- package/dist/modules/register.d.ts.map +1 -0
- package/dist/modules/register.js +239 -0
- package/dist/modules/register.js.map +1 -0
- package/dist/modules/sandbox.d.ts +106 -0
- package/dist/modules/sandbox.d.ts.map +1 -0
- package/dist/modules/sandbox.js +224 -0
- package/dist/modules/sandbox.js.map +1 -0
- package/dist/modules/streams.d.ts +81 -0
- package/dist/modules/streams.d.ts.map +1 -0
- package/dist/modules/streams.js +292 -0
- package/dist/modules/streams.js.map +1 -0
- package/dist/modules/tasks.d.ts +145 -0
- package/dist/modules/tasks.d.ts.map +1 -0
- package/dist/modules/tasks.js +165 -0
- package/dist/modules/tasks.js.map +1 -0
- package/dist/modules/telemetry.d.ts +137 -0
- package/dist/modules/telemetry.d.ts.map +1 -0
- package/dist/modules/telemetry.js +203 -0
- package/dist/modules/telemetry.js.map +1 -0
- package/dist/modules/workspace.d.ts +180 -0
- package/dist/modules/workspace.d.ts.map +1 -0
- package/dist/modules/workspace.js +157 -0
- package/dist/modules/workspace.js.map +1 -0
- package/dist/quickstart-join.d.ts +56 -0
- package/dist/quickstart-join.d.ts.map +1 -0
- package/dist/quickstart-join.js +116 -0
- package/dist/quickstart-join.js.map +1 -0
- package/dist/quickstart.d.ts +137 -0
- package/dist/quickstart.d.ts.map +1 -0
- package/dist/quickstart.js +292 -0
- package/dist/quickstart.js.map +1 -0
- package/dist/retry.d.ts +88 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +152 -0
- package/dist/retry.js.map +1 -0
- package/dist/types.d.ts +447 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +88 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +199 -0
- package/dist/utils.js.map +1 -0
- package/package.json +215 -0
package/dist/utils.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level HTTP helpers shared across SDK modules.
|
|
3
|
+
*
|
|
4
|
+
* These helpers exist so every module formats headers, parses bodies, and
|
|
5
|
+
* converts error responses the same way.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { AuthError, errorFromResponse, wrapNetworkError } from "./errors.js";
|
|
10
|
+
/**
|
|
11
|
+
* A lightweight HTTP context shared between SDK modules.
|
|
12
|
+
*
|
|
13
|
+
* The context does NOT hold any connection state — each `request()` call
|
|
14
|
+
* constructs a fresh `fetch` invocation and returns typed results or throws
|
|
15
|
+
* {@link ShardLinkError}.
|
|
16
|
+
*/
|
|
17
|
+
export class HttpContext {
|
|
18
|
+
baseUrl;
|
|
19
|
+
getToken;
|
|
20
|
+
fetchImpl;
|
|
21
|
+
telemetry;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/u, "");
|
|
24
|
+
if (options.getToken) {
|
|
25
|
+
this.getToken = options.getToken;
|
|
26
|
+
}
|
|
27
|
+
this.fetchImpl = options.fetchImpl ?? ((...args) => fetch(...args));
|
|
28
|
+
if (options.telemetry) {
|
|
29
|
+
this.telemetry = options.telemetry;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Build a URL under the base. Query params are appended when present. */
|
|
33
|
+
url(path, params) {
|
|
34
|
+
const suffix = params && params.size > 0 ? `?${params.toString()}` : "";
|
|
35
|
+
return `${this.baseUrl}${path}${suffix}`;
|
|
36
|
+
}
|
|
37
|
+
/** Headers for endpoints that require bearer auth. Throws if no token provider is configured. */
|
|
38
|
+
async requiredAuthHeaders(extra) {
|
|
39
|
+
if (!this.getToken) {
|
|
40
|
+
throw new AuthError({
|
|
41
|
+
message: "This SDK operation requires an authenticated token provider. " +
|
|
42
|
+
"Construct AgentSdkClient with `getToken`, or use the backward-compatible `HttpContext({ getToken })`.",
|
|
43
|
+
code: "missing_token_provider",
|
|
44
|
+
status: 0,
|
|
45
|
+
operation: "http-context"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const token = await this.getToken();
|
|
49
|
+
return {
|
|
50
|
+
authorization: `Bearer ${token}`,
|
|
51
|
+
"content-type": "application/json",
|
|
52
|
+
...(extra ?? {})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Headers that include bearer auth if a token provider is available; otherwise anonymous. */
|
|
56
|
+
async optionalAuthHeaders(extra) {
|
|
57
|
+
if (!this.getToken) {
|
|
58
|
+
return { ...(extra ?? {}) };
|
|
59
|
+
}
|
|
60
|
+
return this.requiredAuthHeaders(extra);
|
|
61
|
+
}
|
|
62
|
+
/** Headers with an explicit bearer token (used for workspace-scoped calls). */
|
|
63
|
+
bearerHeaders(token, extra) {
|
|
64
|
+
return {
|
|
65
|
+
authorization: `Bearer ${token}`,
|
|
66
|
+
"content-type": "application/json",
|
|
67
|
+
...(extra ?? {})
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Execute a request and return parsed JSON, throwing typed errors on failure. */
|
|
71
|
+
async request(input) {
|
|
72
|
+
const { body, ...rest } = input;
|
|
73
|
+
const response = await this.rawRequest({
|
|
74
|
+
...rest,
|
|
75
|
+
...(body !== undefined ? { body } : {})
|
|
76
|
+
});
|
|
77
|
+
return await expectJson(response, input.operation);
|
|
78
|
+
}
|
|
79
|
+
/** Execute a request and return the raw `Response` without throwing on non-2xx. */
|
|
80
|
+
async rawRequest(input) {
|
|
81
|
+
const url = this.url(input.path, input.params);
|
|
82
|
+
const method = input.method ?? "GET";
|
|
83
|
+
const span = this.telemetry?.start(input.operation, {
|
|
84
|
+
attrs: { http_method: method, http_path: input.path }
|
|
85
|
+
});
|
|
86
|
+
try {
|
|
87
|
+
const response = await this.fetchImpl(url, {
|
|
88
|
+
method,
|
|
89
|
+
headers: input.headers,
|
|
90
|
+
...(input.body !== undefined
|
|
91
|
+
? { body: typeof input.body === "string" ? input.body : JSON.stringify(input.body) }
|
|
92
|
+
: {}),
|
|
93
|
+
...(input.signal ? { signal: input.signal } : {})
|
|
94
|
+
});
|
|
95
|
+
if (span) {
|
|
96
|
+
const correlationId = response.headers.get("x-correlation-id");
|
|
97
|
+
if (response.ok) {
|
|
98
|
+
span.end({
|
|
99
|
+
http_status: response.status,
|
|
100
|
+
...(correlationId ? { correlation_id: correlationId } : {})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
span.set({
|
|
105
|
+
http_status: response.status,
|
|
106
|
+
...(correlationId ? { correlation_id: correlationId } : {})
|
|
107
|
+
});
|
|
108
|
+
span.fail(new Error(`HTTP ${response.status}`), {
|
|
109
|
+
error_code: `http_${response.status}`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return response;
|
|
114
|
+
}
|
|
115
|
+
catch (cause) {
|
|
116
|
+
const wrapped = wrapNetworkError(input.operation, cause);
|
|
117
|
+
span?.fail(wrapped);
|
|
118
|
+
throw wrapped;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** Read the response body as JSON, tolerating empty bodies. */
|
|
123
|
+
export async function readJson(response) {
|
|
124
|
+
const text = await response.text();
|
|
125
|
+
return text.length > 0 ? JSON.parse(text) : null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parse a JSON response and convert non-2xx status into a typed
|
|
129
|
+
* {@link ShardLinkError}.
|
|
130
|
+
*
|
|
131
|
+
* @throws {ShardLinkError}
|
|
132
|
+
*/
|
|
133
|
+
export async function expectJson(response, operation) {
|
|
134
|
+
const payload = await readJson(response);
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
const requirement = response.status === 402 ? parseX402PaymentRequired(response) : null;
|
|
137
|
+
throw errorFromResponse(operation, response, payload, requirement);
|
|
138
|
+
}
|
|
139
|
+
return payload;
|
|
140
|
+
}
|
|
141
|
+
function isRecord(value) {
|
|
142
|
+
return typeof value === "object" && value !== null;
|
|
143
|
+
}
|
|
144
|
+
function decodeHeaderPayload(value) {
|
|
145
|
+
if (!value || value.trim().length === 0) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
return JSON.parse(Buffer.from(value.trim(), "base64url").toString("utf8"));
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Extract the x402 payment requirement from a 402 response or a JSON body.
|
|
157
|
+
*
|
|
158
|
+
* Checks the `PAYMENT-REQUIRED` header first (base64url-encoded JSON), then
|
|
159
|
+
* falls back to a `paymentRequirement` field in a JSON body.
|
|
160
|
+
*/
|
|
161
|
+
export function parseX402PaymentRequired(input) {
|
|
162
|
+
if (input instanceof Response) {
|
|
163
|
+
return decodeHeaderPayload(input.headers.get("PAYMENT-REQUIRED"));
|
|
164
|
+
}
|
|
165
|
+
if (!isRecord(input) || !isRecord(input.paymentRequirement)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const requirement = input.paymentRequirement;
|
|
169
|
+
return requirement.status === "live" ? requirement : null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Extract the x402 payment response from a `PAYMENT-RESPONSE` header, if present.
|
|
173
|
+
*/
|
|
174
|
+
export function parseX402PaymentResponse(input) {
|
|
175
|
+
return decodeHeaderPayload(input.headers.get("PAYMENT-RESPONSE"));
|
|
176
|
+
}
|
|
177
|
+
/** Pull a `token` out of a bootstrap payload (envelope.sessionToken). */
|
|
178
|
+
export function extractSessionToken(bootstrapPayload, operation) {
|
|
179
|
+
if (!isRecord(bootstrapPayload) || !isRecord(bootstrapPayload.envelope)) {
|
|
180
|
+
throw new Error(`[${operation}] bootstrap response missing envelope.`);
|
|
181
|
+
}
|
|
182
|
+
const token = bootstrapPayload.envelope.sessionToken;
|
|
183
|
+
if (typeof token !== "string" || token.length === 0) {
|
|
184
|
+
throw new Error(`[${operation}] bootstrap response missing sessionToken.`);
|
|
185
|
+
}
|
|
186
|
+
return token;
|
|
187
|
+
}
|
|
188
|
+
/** Pull a nested id (`payload[containerKey][idKey]`) out of a JSON envelope. */
|
|
189
|
+
export function extractNestedId(payload, containerKey, idKey, operation) {
|
|
190
|
+
if (!isRecord(payload) || !isRecord(payload[containerKey])) {
|
|
191
|
+
throw new Error(`[${operation}] ${containerKey} response missing ${idKey}.`);
|
|
192
|
+
}
|
|
193
|
+
const value = payload[containerKey][idKey];
|
|
194
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
195
|
+
throw new Error(`[${operation}] ${containerKey} response missing ${idKey}.`);
|
|
196
|
+
}
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAuB,MAAM,aAAa,CAAC;AAiBlG;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IACb,OAAO,CAAS;IAChB,QAAQ,CAAiB;IACzB,SAAS,CAAe;IACxB,SAAS,CAAmB;IAErC,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,SAAS,GAA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AC;AAED,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,YAAoB,EACpB,KAAa,EACb,SAAiB;IAEjB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,KAAK,YAAY,qBAAqB,KAAK,GAAG,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,KAAK,GAAI,OAAO,CAAC,YAAY,CAA6B,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,KAAK,YAAY,qBAAqB,KAAK,GAAG,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shardlink/agent-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript SDK for the ShardLink agent control plane. Wallet-native onboarding, task claim/complete, SSE streams, x402 + delegated-spend billing, lease management, A2A protocol, and cross-plane SignalHub integration.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Axialon/ShardLink",
|
|
9
|
+
"directory": "packages/agent-sdk"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://shardlink.dev",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Axialon/ShardLink/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"shardlink",
|
|
17
|
+
"clawspan",
|
|
18
|
+
"agent",
|
|
19
|
+
"sdk",
|
|
20
|
+
"wallet",
|
|
21
|
+
"x402",
|
|
22
|
+
"a2a",
|
|
23
|
+
"spacetimedb",
|
|
24
|
+
"ai-agents",
|
|
25
|
+
"autonomous"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./errors": {
|
|
38
|
+
"types": "./dist/errors.d.ts",
|
|
39
|
+
"import": "./dist/errors.js",
|
|
40
|
+
"default": "./dist/errors.js"
|
|
41
|
+
},
|
|
42
|
+
"./retry": {
|
|
43
|
+
"types": "./dist/retry.d.ts",
|
|
44
|
+
"import": "./dist/retry.js",
|
|
45
|
+
"default": "./dist/retry.js"
|
|
46
|
+
},
|
|
47
|
+
"./types": {
|
|
48
|
+
"types": "./dist/types.d.ts",
|
|
49
|
+
"import": "./dist/types.js",
|
|
50
|
+
"default": "./dist/types.js"
|
|
51
|
+
},
|
|
52
|
+
"./utils": {
|
|
53
|
+
"types": "./dist/utils.d.ts",
|
|
54
|
+
"import": "./dist/utils.js",
|
|
55
|
+
"default": "./dist/utils.js"
|
|
56
|
+
},
|
|
57
|
+
"./quickstart": {
|
|
58
|
+
"types": "./dist/quickstart.d.ts",
|
|
59
|
+
"import": "./dist/quickstart.js",
|
|
60
|
+
"default": "./dist/quickstart.js"
|
|
61
|
+
},
|
|
62
|
+
"./auth": {
|
|
63
|
+
"types": "./dist/modules/auth.d.ts",
|
|
64
|
+
"import": "./dist/modules/auth.js",
|
|
65
|
+
"default": "./dist/modules/auth.js"
|
|
66
|
+
},
|
|
67
|
+
"./discovery": {
|
|
68
|
+
"types": "./dist/modules/discovery.d.ts",
|
|
69
|
+
"import": "./dist/modules/discovery.js",
|
|
70
|
+
"default": "./dist/modules/discovery.js"
|
|
71
|
+
},
|
|
72
|
+
"./workspace": {
|
|
73
|
+
"types": "./dist/modules/workspace.d.ts",
|
|
74
|
+
"import": "./dist/modules/workspace.js",
|
|
75
|
+
"default": "./dist/modules/workspace.js"
|
|
76
|
+
},
|
|
77
|
+
"./agents": {
|
|
78
|
+
"types": "./dist/modules/agents.d.ts",
|
|
79
|
+
"import": "./dist/modules/agents.js",
|
|
80
|
+
"default": "./dist/modules/agents.js"
|
|
81
|
+
},
|
|
82
|
+
"./billing": {
|
|
83
|
+
"types": "./dist/modules/billing.d.ts",
|
|
84
|
+
"import": "./dist/modules/billing.js",
|
|
85
|
+
"default": "./dist/modules/billing.js"
|
|
86
|
+
},
|
|
87
|
+
"./leases": {
|
|
88
|
+
"types": "./dist/modules/leases.d.ts",
|
|
89
|
+
"import": "./dist/modules/leases.js",
|
|
90
|
+
"default": "./dist/modules/leases.js"
|
|
91
|
+
},
|
|
92
|
+
"./providers": {
|
|
93
|
+
"types": "./dist/modules/providers.d.ts",
|
|
94
|
+
"import": "./dist/modules/providers.js",
|
|
95
|
+
"default": "./dist/modules/providers.js"
|
|
96
|
+
},
|
|
97
|
+
"./tasks": {
|
|
98
|
+
"types": "./dist/modules/tasks.d.ts",
|
|
99
|
+
"import": "./dist/modules/tasks.js",
|
|
100
|
+
"default": "./dist/modules/tasks.js"
|
|
101
|
+
},
|
|
102
|
+
"./reactions": {
|
|
103
|
+
"types": "./dist/modules/reactions.d.ts",
|
|
104
|
+
"import": "./dist/modules/reactions.js",
|
|
105
|
+
"default": "./dist/modules/reactions.js"
|
|
106
|
+
},
|
|
107
|
+
"./streams": {
|
|
108
|
+
"types": "./dist/modules/streams.d.ts",
|
|
109
|
+
"import": "./dist/modules/streams.js",
|
|
110
|
+
"default": "./dist/modules/streams.js"
|
|
111
|
+
},
|
|
112
|
+
"./a2a": {
|
|
113
|
+
"types": "./dist/modules/a2a.d.ts",
|
|
114
|
+
"import": "./dist/modules/a2a.js",
|
|
115
|
+
"default": "./dist/modules/a2a.js"
|
|
116
|
+
},
|
|
117
|
+
"./register": {
|
|
118
|
+
"types": "./dist/modules/register.d.ts",
|
|
119
|
+
"import": "./dist/modules/register.js",
|
|
120
|
+
"default": "./dist/modules/register.js"
|
|
121
|
+
},
|
|
122
|
+
"./lease-manager": {
|
|
123
|
+
"types": "./dist/modules/lease-manager.d.ts",
|
|
124
|
+
"import": "./dist/modules/lease-manager.js",
|
|
125
|
+
"default": "./dist/modules/lease-manager.js"
|
|
126
|
+
},
|
|
127
|
+
"./cross-plane": {
|
|
128
|
+
"types": "./dist/modules/cross-plane.d.ts",
|
|
129
|
+
"import": "./dist/modules/cross-plane.js",
|
|
130
|
+
"default": "./dist/modules/cross-plane.js"
|
|
131
|
+
},
|
|
132
|
+
"./diagnostics": {
|
|
133
|
+
"types": "./dist/modules/diagnostics.d.ts",
|
|
134
|
+
"import": "./dist/modules/diagnostics.js",
|
|
135
|
+
"default": "./dist/modules/diagnostics.js"
|
|
136
|
+
},
|
|
137
|
+
"./quota": {
|
|
138
|
+
"types": "./dist/modules/quota.d.ts",
|
|
139
|
+
"import": "./dist/modules/quota.js",
|
|
140
|
+
"default": "./dist/modules/quota.js"
|
|
141
|
+
},
|
|
142
|
+
"./sandbox": {
|
|
143
|
+
"types": "./dist/modules/sandbox.d.ts",
|
|
144
|
+
"import": "./dist/modules/sandbox.js",
|
|
145
|
+
"default": "./dist/modules/sandbox.js"
|
|
146
|
+
},
|
|
147
|
+
"./degradation": {
|
|
148
|
+
"types": "./dist/modules/degradation.d.ts",
|
|
149
|
+
"import": "./dist/modules/degradation.js",
|
|
150
|
+
"default": "./dist/modules/degradation.js"
|
|
151
|
+
},
|
|
152
|
+
"./compliance": {
|
|
153
|
+
"types": "./dist/modules/compliance.d.ts",
|
|
154
|
+
"import": "./dist/modules/compliance.js",
|
|
155
|
+
"default": "./dist/modules/compliance.js"
|
|
156
|
+
},
|
|
157
|
+
"./telemetry": {
|
|
158
|
+
"types": "./dist/modules/telemetry.d.ts",
|
|
159
|
+
"import": "./dist/modules/telemetry.js",
|
|
160
|
+
"default": "./dist/modules/telemetry.js"
|
|
161
|
+
},
|
|
162
|
+
"./dashboard": {
|
|
163
|
+
"types": "./dist/modules/dashboard.d.ts",
|
|
164
|
+
"import": "./dist/modules/dashboard.js",
|
|
165
|
+
"default": "./dist/modules/dashboard.js"
|
|
166
|
+
},
|
|
167
|
+
"./clans": {
|
|
168
|
+
"types": "./dist/modules/clans.d.ts",
|
|
169
|
+
"import": "./dist/modules/clans.js",
|
|
170
|
+
"default": "./dist/modules/clans.js"
|
|
171
|
+
},
|
|
172
|
+
"./operators": {
|
|
173
|
+
"types": "./dist/modules/operators.d.ts",
|
|
174
|
+
"import": "./dist/modules/operators.js",
|
|
175
|
+
"default": "./dist/modules/operators.js"
|
|
176
|
+
},
|
|
177
|
+
"./fleets": {
|
|
178
|
+
"types": "./dist/modules/fleets.d.ts",
|
|
179
|
+
"import": "./dist/modules/fleets.js",
|
|
180
|
+
"default": "./dist/modules/fleets.js"
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"files": [
|
|
184
|
+
"dist",
|
|
185
|
+
"README.md",
|
|
186
|
+
"LICENSE"
|
|
187
|
+
],
|
|
188
|
+
"publishConfig": {
|
|
189
|
+
"access": "public"
|
|
190
|
+
},
|
|
191
|
+
"engines": {
|
|
192
|
+
"node": ">=20.0.0"
|
|
193
|
+
},
|
|
194
|
+
"scripts": {
|
|
195
|
+
"build": "tsc -p tsconfig.build.json",
|
|
196
|
+
"prepare": "pnpm run build",
|
|
197
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
198
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
199
|
+
"test": "vitest run",
|
|
200
|
+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
201
|
+
"format": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
202
|
+
"prepublishOnly": "pnpm run clean && pnpm run build"
|
|
203
|
+
},
|
|
204
|
+
"devDependencies": {
|
|
205
|
+
"@types/js-yaml": "^4.0.9",
|
|
206
|
+
"@types/node": "^22.13.10",
|
|
207
|
+
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
208
|
+
"@typescript-eslint/parser": "^8.26.0",
|
|
209
|
+
"eslint": "^9.22.0",
|
|
210
|
+
"js-yaml": "^4.1.0",
|
|
211
|
+
"prettier": "^3.5.3",
|
|
212
|
+
"typescript": "^5.8.2",
|
|
213
|
+
"vitest": "^3.2.4"
|
|
214
|
+
}
|
|
215
|
+
}
|