@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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graceful degradation contract.
|
|
3
|
+
*
|
|
4
|
+
* When things go wrong — lease expires mid-task, spend cap hits, platform
|
|
5
|
+
* degrades, task times out — the agent needs a predictable, user-declared
|
|
6
|
+
* policy for how to react. The {@link DegradationContract} describes those
|
|
7
|
+
* choices; {@link DegradationEnforcer} applies them against a running
|
|
8
|
+
* lease manager / task scheduler.
|
|
9
|
+
*
|
|
10
|
+
* This module does not poll the server or send requests on its own. It
|
|
11
|
+
* wires together the state signals the rest of the SDK already produces
|
|
12
|
+
* (lease events from {@link LeaseManager}, timers, platform-status probes
|
|
13
|
+
* from {@link DiagnosticsClient}) and calls back into the host app.
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
/** Default contract — conservative, pause-and-retry oriented. */
|
|
18
|
+
export const DEFAULT_DEGRADATION = Object.freeze({
|
|
19
|
+
leaseExpiry: "pause_and_retry",
|
|
20
|
+
spendCapHit: "pause_new_claims",
|
|
21
|
+
platformDegraded: "retry_with_backoff",
|
|
22
|
+
taskTimeoutMs: 5 * 60_000,
|
|
23
|
+
taskTimeoutAction: "release_claim"
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Applies a {@link DegradationContract} to the lifecycle signals emitted by
|
|
27
|
+
* the rest of the SDK. Each signal maps to exactly one handler invocation
|
|
28
|
+
* so the host app can reliably react.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const enforcer = new DegradationEnforcer({
|
|
33
|
+
* contract: { ...DEFAULT_DEGRADATION, spendCapHit: "shutdown" },
|
|
34
|
+
* handlers: {
|
|
35
|
+
* pauseClaims: () => scheduler.pause(),
|
|
36
|
+
* resumeClaims: () => scheduler.resume(),
|
|
37
|
+
* requestLeaseExtension: () => leaseClient.request(...),
|
|
38
|
+
* shutdown: () => process.exit(0)
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* lease.onBudgetThreshold(100, () => enforcer.onSpendCapHit(lease.status()));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export class DegradationEnforcer {
|
|
46
|
+
contract;
|
|
47
|
+
handlers;
|
|
48
|
+
inFlight = new Map();
|
|
49
|
+
paused = false;
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.contract = options.contract ?? DEFAULT_DEGRADATION;
|
|
52
|
+
this.handlers = options.handlers;
|
|
53
|
+
}
|
|
54
|
+
/** Mark a task as in-flight so timeout detection can watch it. */
|
|
55
|
+
trackClaim(taskId) {
|
|
56
|
+
const existing = this.inFlight.get(taskId);
|
|
57
|
+
if (existing?.timer)
|
|
58
|
+
clearTimeout(existing.timer);
|
|
59
|
+
const record = { taskId, claimedAt: Date.now() };
|
|
60
|
+
record.timer = setTimeout(() => void this.onTaskTimeout(taskId), this.contract.taskTimeoutMs);
|
|
61
|
+
this.inFlight.set(taskId, record);
|
|
62
|
+
}
|
|
63
|
+
/** Clear a task (because it completed). */
|
|
64
|
+
completeClaim(taskId) {
|
|
65
|
+
const record = this.inFlight.get(taskId);
|
|
66
|
+
if (record?.timer)
|
|
67
|
+
clearTimeout(record.timer);
|
|
68
|
+
this.inFlight.delete(taskId);
|
|
69
|
+
}
|
|
70
|
+
/** Wire this into {@link LeaseManager.enableAutoRenew}'s `onFailed` or to a `lease_expiring` handler. */
|
|
71
|
+
async onLeaseExpiring(snapshot) {
|
|
72
|
+
const ctx = {
|
|
73
|
+
reason: "lease_expiring",
|
|
74
|
+
strategy: this.contract.leaseExpiry,
|
|
75
|
+
details: snapshot
|
|
76
|
+
};
|
|
77
|
+
switch (this.contract.leaseExpiry) {
|
|
78
|
+
case "pause_and_retry":
|
|
79
|
+
await this.pause(ctx);
|
|
80
|
+
break;
|
|
81
|
+
case "abort_gracefully":
|
|
82
|
+
await this.pause(ctx);
|
|
83
|
+
await this.handlers.shutdown?.({ ...ctx, reason: "lease_expiring" });
|
|
84
|
+
break;
|
|
85
|
+
case "request_extension":
|
|
86
|
+
await this.pause(ctx);
|
|
87
|
+
await this.handlers.requestLeaseExtension?.(ctx);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Call after a successful lease renewal so claim flow resumes. */
|
|
92
|
+
async onLeaseRenewed(snapshot) {
|
|
93
|
+
if (!this.paused)
|
|
94
|
+
return;
|
|
95
|
+
await this.resume({
|
|
96
|
+
reason: "lease_expiring",
|
|
97
|
+
strategy: this.contract.leaseExpiry,
|
|
98
|
+
details: snapshot
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Wire to {@link LeaseManager.onBudgetThreshold}(100). */
|
|
102
|
+
async onSpendCapHit(snapshot) {
|
|
103
|
+
const ctx = {
|
|
104
|
+
reason: "spend_cap_hit",
|
|
105
|
+
strategy: this.contract.spendCapHit,
|
|
106
|
+
details: snapshot
|
|
107
|
+
};
|
|
108
|
+
switch (this.contract.spendCapHit) {
|
|
109
|
+
case "pause_new_claims":
|
|
110
|
+
await this.pause(ctx);
|
|
111
|
+
break;
|
|
112
|
+
case "complete_current_only":
|
|
113
|
+
await this.pause(ctx);
|
|
114
|
+
if (this.inFlight.size === 0) {
|
|
115
|
+
await this.handlers.shutdown?.(ctx);
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case "shutdown":
|
|
119
|
+
await this.pause(ctx);
|
|
120
|
+
await this.handlers.shutdown?.(ctx);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Wire to {@link DiagnosticsClient.platformStatus} when `ok: false`. */
|
|
125
|
+
async onPlatformDegraded(details) {
|
|
126
|
+
const ctx = {
|
|
127
|
+
reason: "platform_degraded",
|
|
128
|
+
strategy: this.contract.platformDegraded,
|
|
129
|
+
...(details ? { details } : {})
|
|
130
|
+
};
|
|
131
|
+
switch (this.contract.platformDegraded) {
|
|
132
|
+
case "retry_with_backoff":
|
|
133
|
+
await this.pause(ctx);
|
|
134
|
+
break;
|
|
135
|
+
case "switch_workspace":
|
|
136
|
+
await this.pause(ctx);
|
|
137
|
+
await this.handlers.switchWorkspace?.(ctx);
|
|
138
|
+
break;
|
|
139
|
+
case "hibernate":
|
|
140
|
+
await this.pause(ctx);
|
|
141
|
+
await this.handlers.hibernate?.(ctx);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Host calls this when the platform recovers (next successful heartbeat). */
|
|
146
|
+
async onPlatformRecovered() {
|
|
147
|
+
if (!this.paused)
|
|
148
|
+
return;
|
|
149
|
+
await this.resume({
|
|
150
|
+
reason: "platform_recovered",
|
|
151
|
+
strategy: this.contract.platformDegraded
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async onTaskTimeout(taskId) {
|
|
155
|
+
const record = this.inFlight.get(taskId);
|
|
156
|
+
if (!record)
|
|
157
|
+
return;
|
|
158
|
+
this.inFlight.delete(taskId);
|
|
159
|
+
const ctx = {
|
|
160
|
+
reason: "task_timeout",
|
|
161
|
+
strategy: this.contract.taskTimeoutAction,
|
|
162
|
+
details: { taskId, claimedAt: record.claimedAt }
|
|
163
|
+
};
|
|
164
|
+
switch (this.contract.taskTimeoutAction) {
|
|
165
|
+
case "release_claim":
|
|
166
|
+
await this.handlers.releaseTaskClaim?.(taskId, ctx);
|
|
167
|
+
break;
|
|
168
|
+
case "mark_failed":
|
|
169
|
+
await this.handlers.markTaskFailed?.(taskId, ctx);
|
|
170
|
+
break;
|
|
171
|
+
case "request_extension":
|
|
172
|
+
await this.handlers.requestLeaseExtension?.(ctx);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async pause(ctx) {
|
|
177
|
+
if (this.paused)
|
|
178
|
+
return;
|
|
179
|
+
this.paused = true;
|
|
180
|
+
await this.handlers.pauseClaims?.(ctx);
|
|
181
|
+
}
|
|
182
|
+
async resume(ctx) {
|
|
183
|
+
if (!this.paused)
|
|
184
|
+
return;
|
|
185
|
+
this.paused = false;
|
|
186
|
+
await this.handlers.resumeClaims?.(ctx);
|
|
187
|
+
}
|
|
188
|
+
/** Currently accepting new claims? */
|
|
189
|
+
isAcceptingClaims() {
|
|
190
|
+
return !this.paused;
|
|
191
|
+
}
|
|
192
|
+
/** How many tasks are tracked as in-flight right now. */
|
|
193
|
+
inFlightCount() {
|
|
194
|
+
return this.inFlight.size;
|
|
195
|
+
}
|
|
196
|
+
/** Clear all timers — call on shutdown. */
|
|
197
|
+
dispose() {
|
|
198
|
+
for (const record of this.inFlight.values()) {
|
|
199
|
+
if (record.timer)
|
|
200
|
+
clearTimeout(record.timer);
|
|
201
|
+
}
|
|
202
|
+
this.inFlight.clear();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=degradation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"degradation.js","sourceRoot":"","sources":["../../src/modules/degradation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAmCH,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAwB,MAAM,CAAC,MAAM,CAAC;IACpE,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,kBAAkB;IAC/B,gBAAgB,EAAE,oBAAoB;IACtC,aAAa,EAAE,CAAC,GAAG,MAAM;IACzB,iBAAiB,EAAE,eAAe;CACnC,CAAC,CAAC;AAmDH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,mBAAmB;IACrB,QAAQ,CAAsB;IACtB,QAAQ,CAAsB;IAC9B,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IACpD,MAAM,GAAG,KAAK,CAAC;IAEvB,YAA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CAAC,CAAC;IAC1C,CAAC;IAED,sCAAsC;IACtC,iBAAiB;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IACtB,CAAC;IAED,yDAAyD;IACzD,aAAa;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,2CAA2C;IAC3C,OAAO;QACL,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5C,IAAI,MAAM,CAAC,KAAK;gBAAE,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure preflight checks + remediation helpers for {@link DiagnosticsClient}.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `diagnostics.ts` to keep each SDK module file under the
|
|
5
|
+
* 400-line ceiling (CLAUDE.md §"Agent DX Rules"). These are the synchronous,
|
|
6
|
+
* `this`-free portions of the preflight battery — the lease / billing /
|
|
7
|
+
* capabilities / sandbox checks and the auto-fix suggestion logic. The async,
|
|
8
|
+
* network-touching checks (`checkAuth`, `checkConnectivity`, `checkPlatform`)
|
|
9
|
+
* stay on the client where they have access to the HTTP context.
|
|
10
|
+
*
|
|
11
|
+
* Behavior is unchanged: `diagnostics.ts` calls these functions in place of
|
|
12
|
+
* the former private methods, so {@link DiagnosticsClient.preflight} produces
|
|
13
|
+
* the identical report.
|
|
14
|
+
*
|
|
15
|
+
* @internal These helpers are not part of the SDK's published API surface —
|
|
16
|
+
* they are re-used by `diagnostics.ts` only. Consume {@link DiagnosticsClient}
|
|
17
|
+
* (exported from the package root and `@shardlink/agent-sdk/diagnostics`).
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
import type { AutoFix, CheckResult, PreflightCheckName, PreflightInput } from "./diagnostics-types.js";
|
|
22
|
+
/** Lease-state check — `warn` when no snapshot is supplied. */
|
|
23
|
+
export declare function checkLease(input: PreflightInput): CheckResult;
|
|
24
|
+
/** Billing-envelope check — `warn` when no envelope is supplied. */
|
|
25
|
+
export declare function checkBilling(input: PreflightInput): CheckResult;
|
|
26
|
+
/** Declared-capability sanity check — `warn` when essentials are missing. */
|
|
27
|
+
export declare function checkCapabilities(input: PreflightInput): CheckResult;
|
|
28
|
+
/** Trust-tier policy check — `warn` when no policy/snapshot is supplied. */
|
|
29
|
+
export declare function checkSandbox(input: PreflightInput): CheckResult;
|
|
30
|
+
/** Map a failed check to a programmatic remediation hint, when one exists. */
|
|
31
|
+
export declare function suggestAutoFix(check: PreflightCheckName, result: CheckResult): AutoFix | null;
|
|
32
|
+
//# sourceMappingURL=diagnostics-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-checks.d.ts","sourceRoot":"","sources":["../../src/modules/diagnostics-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CA6B7D;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CA8B/D;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CAcpE;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CAuE/D;AAoED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,GAAG,IAAI,CAQ7F"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure preflight checks + remediation helpers for {@link DiagnosticsClient}.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `diagnostics.ts` to keep each SDK module file under the
|
|
5
|
+
* 400-line ceiling (CLAUDE.md §"Agent DX Rules"). These are the synchronous,
|
|
6
|
+
* `this`-free portions of the preflight battery — the lease / billing /
|
|
7
|
+
* capabilities / sandbox checks and the auto-fix suggestion logic. The async,
|
|
8
|
+
* network-touching checks (`checkAuth`, `checkConnectivity`, `checkPlatform`)
|
|
9
|
+
* stay on the client where they have access to the HTTP context.
|
|
10
|
+
*
|
|
11
|
+
* Behavior is unchanged: `diagnostics.ts` calls these functions in place of
|
|
12
|
+
* the former private methods, so {@link DiagnosticsClient.preflight} produces
|
|
13
|
+
* the identical report.
|
|
14
|
+
*
|
|
15
|
+
* @internal These helpers are not part of the SDK's published API surface —
|
|
16
|
+
* they are re-used by `diagnostics.ts` only. Consume {@link DiagnosticsClient}
|
|
17
|
+
* (exported from the package root and `@shardlink/agent-sdk/diagnostics`).
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
import { SandboxPolicy } from "./sandbox.js";
|
|
22
|
+
/** Lease-state check — `warn` when no snapshot is supplied. */
|
|
23
|
+
export function checkLease(input) {
|
|
24
|
+
if (!input.lease) {
|
|
25
|
+
return { status: "warn", message: "lease snapshot not provided" };
|
|
26
|
+
}
|
|
27
|
+
if (input.lease.status === "revoked") {
|
|
28
|
+
return {
|
|
29
|
+
status: "fail",
|
|
30
|
+
message: "lease is revoked",
|
|
31
|
+
details: input.lease
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (input.lease.status === "expired") {
|
|
35
|
+
return { status: "fail", message: "lease has expired", details: input.lease };
|
|
36
|
+
}
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
if (input.lease.expiresAt !== undefined) {
|
|
39
|
+
const expiresAt = typeof input.lease.expiresAt === "number"
|
|
40
|
+
? input.lease.expiresAt
|
|
41
|
+
: Date.parse(input.lease.expiresAt);
|
|
42
|
+
if (!Number.isNaN(expiresAt) && expiresAt - now < 60_000) {
|
|
43
|
+
return {
|
|
44
|
+
status: "warn",
|
|
45
|
+
message: `lease expires in ${Math.max(0, expiresAt - now)}ms`,
|
|
46
|
+
details: input.lease
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { status: "pass", details: input.lease };
|
|
51
|
+
}
|
|
52
|
+
/** Billing-envelope check — `warn` when no envelope is supplied. */
|
|
53
|
+
export function checkBilling(input) {
|
|
54
|
+
if (!input.billing) {
|
|
55
|
+
return { status: "warn", message: "billing envelope not provided" };
|
|
56
|
+
}
|
|
57
|
+
if (input.billing.status && input.billing.status !== "active") {
|
|
58
|
+
return {
|
|
59
|
+
status: "fail",
|
|
60
|
+
message: `envelope ${input.billing.status}`,
|
|
61
|
+
details: input.billing
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const authorized = input.billing.authorizedAmountUsdCents ?? 0;
|
|
65
|
+
const consumed = input.billing.consumedAmountUsdCents ?? 0;
|
|
66
|
+
const headroom = authorized - consumed;
|
|
67
|
+
const minHeadroom = input.minBudgetHeadroomUsdCents ?? 100;
|
|
68
|
+
if (headroom <= 0) {
|
|
69
|
+
return {
|
|
70
|
+
status: "fail",
|
|
71
|
+
message: "spend envelope depleted",
|
|
72
|
+
details: input.billing
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (headroom < minHeadroom) {
|
|
76
|
+
return {
|
|
77
|
+
status: "warn",
|
|
78
|
+
message: `low spend headroom (${headroom}¢ < ${minHeadroom}¢ min)`,
|
|
79
|
+
details: input.billing
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { status: "pass", details: input.billing };
|
|
83
|
+
}
|
|
84
|
+
/** Declared-capability sanity check — `warn` when essentials are missing. */
|
|
85
|
+
export function checkCapabilities(input) {
|
|
86
|
+
if (!input.supportedActions || input.supportedActions.length === 0) {
|
|
87
|
+
return { status: "warn", message: "supportedActions not declared" };
|
|
88
|
+
}
|
|
89
|
+
const essentials = ["claim_task", "complete_task"];
|
|
90
|
+
const missing = essentials.filter((action) => !input.supportedActions?.includes(action));
|
|
91
|
+
if (missing.length > 0) {
|
|
92
|
+
return {
|
|
93
|
+
status: "warn",
|
|
94
|
+
message: `missing actions: ${missing.join(", ")}`,
|
|
95
|
+
details: input.supportedActions
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return { status: "pass", details: input.supportedActions };
|
|
99
|
+
}
|
|
100
|
+
/** Trust-tier policy check — `warn` when no policy/snapshot is supplied. */
|
|
101
|
+
export function checkSandbox(input) {
|
|
102
|
+
if (!input.sandbox) {
|
|
103
|
+
return { status: "warn", message: "sandbox policy not provided" };
|
|
104
|
+
}
|
|
105
|
+
const policy = input.sandbox instanceof SandboxPolicy ? input.sandbox : new SandboxPolicy(input.sandbox);
|
|
106
|
+
const snap = policy.getSnapshot();
|
|
107
|
+
const tier = policy.effectivePolicy().tier;
|
|
108
|
+
const progression = policy.progressReport();
|
|
109
|
+
if (snap.qualification.blockedReasons.length > 0) {
|
|
110
|
+
return {
|
|
111
|
+
status: "fail",
|
|
112
|
+
message: `blocked qualifications: ${snap.qualification.blockedReasons.join(", ")}`,
|
|
113
|
+
details: { tier, blockedReasons: snap.qualification.blockedReasons, progression }
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (input.workspaceEntry) {
|
|
117
|
+
const eligibility = policy.canJoinWorkspace(input.workspaceEntry);
|
|
118
|
+
if (!eligibility.eligible) {
|
|
119
|
+
return {
|
|
120
|
+
status: "fail",
|
|
121
|
+
message: eligibility.message ?? `workspace ineligible (${eligibility.reason})`,
|
|
122
|
+
details: { tier, eligibility, progression }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (eligibility.reason === "suspended_capability") {
|
|
126
|
+
return {
|
|
127
|
+
status: "warn",
|
|
128
|
+
message: eligibility.message ?? "workspace has suspended capabilities",
|
|
129
|
+
details: { tier, eligibility }
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (typeof input.prospectiveSpendUsdCents === "number") {
|
|
134
|
+
const alreadySpent = input.spentTodayUsdCents ?? 0;
|
|
135
|
+
if (!policy.canSpend(input.prospectiveSpendUsdCents, alreadySpent)) {
|
|
136
|
+
const cap = policy.effectivePolicy().dailySpendCapUsdCents;
|
|
137
|
+
return {
|
|
138
|
+
status: "fail",
|
|
139
|
+
message: `daily spend cap exceeded (${alreadySpent + input.prospectiveSpendUsdCents}¢ > ${cap}¢)`,
|
|
140
|
+
details: {
|
|
141
|
+
tier,
|
|
142
|
+
cap,
|
|
143
|
+
spentTodayUsdCents: alreadySpent,
|
|
144
|
+
prospectiveSpendUsdCents: input.prospectiveSpendUsdCents,
|
|
145
|
+
progression
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (typeof input.claimsInLastHour === "number") {
|
|
151
|
+
if (!policy.withinClaimRate(input.claimsInLastHour)) {
|
|
152
|
+
const limit = policy.effectivePolicy().perHourTaskClaims;
|
|
153
|
+
return {
|
|
154
|
+
status: "warn",
|
|
155
|
+
message: `per-hour claim rate reached (${input.claimsInLastHour} >= ${limit})`,
|
|
156
|
+
details: {
|
|
157
|
+
tier,
|
|
158
|
+
limit,
|
|
159
|
+
observed: input.claimsInLastHour,
|
|
160
|
+
progression
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { status: "pass", details: { tier, progression } };
|
|
166
|
+
}
|
|
167
|
+
const AUTO_FIX_TEMPLATES = {
|
|
168
|
+
auth: {
|
|
169
|
+
action: "refresh_session",
|
|
170
|
+
description: "Refresh wallet session via auth.repeatWalletAccess() or re-sign challenge."
|
|
171
|
+
},
|
|
172
|
+
lease: {
|
|
173
|
+
action: "request_lease",
|
|
174
|
+
description: "Call leases.request() or LeaseManager.enableAutoRenew() to request a new lease."
|
|
175
|
+
},
|
|
176
|
+
billing: {
|
|
177
|
+
action: "top_up_envelope",
|
|
178
|
+
description: "Fund a new spend envelope via billing.createEnvelope() or request a delegated grant."
|
|
179
|
+
},
|
|
180
|
+
connectivity: {
|
|
181
|
+
action: "retry_with_backoff",
|
|
182
|
+
description: (r) => `Network unreachable: ${r.message ?? ""}. Retry with exponential backoff.`
|
|
183
|
+
},
|
|
184
|
+
platform: {
|
|
185
|
+
action: "wait_for_platform",
|
|
186
|
+
description: "Platform not ready; back off and retry heartbeat until /health/ready returns ok."
|
|
187
|
+
},
|
|
188
|
+
capabilities: null,
|
|
189
|
+
sandbox: {
|
|
190
|
+
action: "upgrade_trust_tier",
|
|
191
|
+
description: (r) => describeSandboxRemediation(r)
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
function describeSandboxRemediation(result) {
|
|
195
|
+
const details = result.details;
|
|
196
|
+
const progression = details?.progression;
|
|
197
|
+
if (details?.eligibility?.reason === "requires_higher_proof") {
|
|
198
|
+
return "Complete wallet verification (EIP-4361 sign-in) to raise proof level to P2.";
|
|
199
|
+
}
|
|
200
|
+
if (details?.eligibility?.reason === "invite_only") {
|
|
201
|
+
return "Workspace is invite-only; request an invite from its governor.";
|
|
202
|
+
}
|
|
203
|
+
if (details?.blockedReasons && details.blockedReasons.length > 0) {
|
|
204
|
+
return `Resolve passport-level blockers: ${details.blockedReasons.join(", ")}.`;
|
|
205
|
+
}
|
|
206
|
+
if (!progression) {
|
|
207
|
+
return "Trust tier restricts this action; review SandboxPolicy.progressReport() for criteria.";
|
|
208
|
+
}
|
|
209
|
+
if (progression.to === null) {
|
|
210
|
+
return "Agent is at the highest trust tier; no further upgrade path.";
|
|
211
|
+
}
|
|
212
|
+
const unmet = progression.criteria.filter((c) => !c.met);
|
|
213
|
+
if (unmet.length === 0) {
|
|
214
|
+
return `All criteria met to promote from ${progression.from} → ${progression.to}; refresh passport to sync server-side tier.`;
|
|
215
|
+
}
|
|
216
|
+
const pct = Math.round(progression.progress * 100);
|
|
217
|
+
return `Progress ${pct}% from ${progression.from} → ${progression.to}; remaining: ${unmet
|
|
218
|
+
.map((c) => c.label)
|
|
219
|
+
.join("; ")}.`;
|
|
220
|
+
}
|
|
221
|
+
/** Map a failed check to a programmatic remediation hint, when one exists. */
|
|
222
|
+
export function suggestAutoFix(check, result) {
|
|
223
|
+
const template = AUTO_FIX_TEMPLATES[check];
|
|
224
|
+
if (!template)
|
|
225
|
+
return null;
|
|
226
|
+
const description = typeof template.description === "function"
|
|
227
|
+
? template.description(result)
|
|
228
|
+
: template.description;
|
|
229
|
+
return { check, action: template.action, description };
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=diagnostics-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-checks.js","sourceRoot":"","sources":["../../src/modules/diagnostics-checks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAwB,MAAM,cAAc,CAAC;AAQnE,+DAA+D;AAC/D,MAAM,UAAU,UAAU,CAAC,KAAqB;IAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC;IACpE,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO;YACL,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,kBAAkB;YAC3B,OAAO,EAAE,KAAK,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAA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AQ,CAAC,WAAW,CAAC,MAAM,CAAC;QAC9B,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the diagnostics + preflight client.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `diagnostics.ts` so both the client (`diagnostics.ts`) and
|
|
5
|
+
* the pure check helpers (`diagnostics-checks.ts`) can reference them without
|
|
6
|
+
* a circular import, and so each file stays under the 400-line SDK module
|
|
7
|
+
* ceiling (CLAUDE.md §"Agent DX Rules").
|
|
8
|
+
*
|
|
9
|
+
* The public API is unchanged: `diagnostics.ts` re-exports every type below,
|
|
10
|
+
* so they remain importable from `@shardlink/agent-sdk` and
|
|
11
|
+
* `@shardlink/agent-sdk/diagnostics` exactly as before.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import type { HttpContext } from "../utils.js";
|
|
16
|
+
import type { DiscoveryClient } from "./discovery.js";
|
|
17
|
+
import type { LeaseSnapshot } from "./lease-manager.js";
|
|
18
|
+
import type { SandboxPolicy, AgentSnapshot } from "./sandbox.js";
|
|
19
|
+
import type { WorkspaceDirectoryEntry } from "../types.js";
|
|
20
|
+
/** Status of an individual preflight check. */
|
|
21
|
+
export type CheckStatus = "pass" | "warn" | "fail";
|
|
22
|
+
/** A single preflight check result. */
|
|
23
|
+
export interface CheckResult {
|
|
24
|
+
status: CheckStatus;
|
|
25
|
+
message?: string;
|
|
26
|
+
details?: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** Full preflight report. */
|
|
29
|
+
export interface PreflightResult {
|
|
30
|
+
ready: boolean;
|
|
31
|
+
checks: {
|
|
32
|
+
auth: CheckResult;
|
|
33
|
+
lease: CheckResult;
|
|
34
|
+
billing: CheckResult;
|
|
35
|
+
connectivity: CheckResult;
|
|
36
|
+
capabilities: CheckResult;
|
|
37
|
+
platform: CheckResult;
|
|
38
|
+
sandbox: CheckResult;
|
|
39
|
+
};
|
|
40
|
+
/** Human-readable issue strings (empty when `ready: true`). */
|
|
41
|
+
issues: string[];
|
|
42
|
+
/** Programmatic remediation hints. */
|
|
43
|
+
autoFixable: AutoFix[];
|
|
44
|
+
}
|
|
45
|
+
/** Name of an individual preflight check (a key of {@link PreflightResult.checks}). */
|
|
46
|
+
export type PreflightCheckName = keyof PreflightResult["checks"];
|
|
47
|
+
/** Machine-readable remediation hint. */
|
|
48
|
+
export interface AutoFix {
|
|
49
|
+
check: PreflightCheckName;
|
|
50
|
+
action: string;
|
|
51
|
+
description: string;
|
|
52
|
+
}
|
|
53
|
+
/** Platform health projection. */
|
|
54
|
+
export interface PlatformHealth {
|
|
55
|
+
ok: boolean;
|
|
56
|
+
depth: "shallow" | "deep";
|
|
57
|
+
details: Record<string, {
|
|
58
|
+
ok: boolean;
|
|
59
|
+
message?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/** Input accepted by `DiagnosticsClient.preflight`. */
|
|
63
|
+
export interface PreflightInput {
|
|
64
|
+
/** Current lease snapshot. Omit to skip the lease check (status: warn). */
|
|
65
|
+
lease?: LeaseSnapshot;
|
|
66
|
+
/** Declared supported actions so capabilities can be sanity-checked. */
|
|
67
|
+
supportedActions?: string[];
|
|
68
|
+
/** Billing-side envelope snapshot so spend headroom is visible. */
|
|
69
|
+
billing?: {
|
|
70
|
+
envelopeId?: string;
|
|
71
|
+
authorizedAmountUsdCents?: number;
|
|
72
|
+
consumedAmountUsdCents?: number;
|
|
73
|
+
status?: "active" | "exhausted" | "revoked" | "expired";
|
|
74
|
+
};
|
|
75
|
+
/** How much budget headroom (in authorized USD cents) is considered healthy. */
|
|
76
|
+
minBudgetHeadroomUsdCents?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Trust-tier policy evaluator. Pass a pre-built {@link SandboxPolicy} or
|
|
79
|
+
* an {@link AgentSnapshot} — the latter will be wrapped in a default
|
|
80
|
+
* policy. Omit to skip the sandbox check (status: warn).
|
|
81
|
+
*/
|
|
82
|
+
sandbox?: SandboxPolicy | AgentSnapshot;
|
|
83
|
+
/**
|
|
84
|
+
* Optional workspace directory entry — if present, the sandbox check
|
|
85
|
+
* calls `canJoinWorkspace` and reports ineligibility as fail.
|
|
86
|
+
*/
|
|
87
|
+
workspaceEntry?: WorkspaceDirectoryEntry;
|
|
88
|
+
/**
|
|
89
|
+
* Prospective USD-cent spend the agent is about to authorize. The
|
|
90
|
+
* sandbox check calls `SandboxPolicy.canSpend` with this +
|
|
91
|
+
* `spentTodayUsdCents` against the tier's daily cap.
|
|
92
|
+
*/
|
|
93
|
+
prospectiveSpendUsdCents?: number;
|
|
94
|
+
/** USD cents already consumed today — defaults to `0`. */
|
|
95
|
+
spentTodayUsdCents?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Observed task-claim count in the last rolling hour. If present and
|
|
98
|
+
* over the tier's per-hour cap, the sandbox check returns `warn`.
|
|
99
|
+
*/
|
|
100
|
+
claimsInLastHour?: number;
|
|
101
|
+
}
|
|
102
|
+
/** Log level for `DiagnosticsClient.log`. */
|
|
103
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
104
|
+
/** Destination that receives structured diagnostic logs. */
|
|
105
|
+
export type LogSink = (entry: {
|
|
106
|
+
level: LogLevel;
|
|
107
|
+
message: string;
|
|
108
|
+
meta?: Record<string, unknown>;
|
|
109
|
+
at: number;
|
|
110
|
+
}) => void;
|
|
111
|
+
/** Options for the diagnostics client. */
|
|
112
|
+
export interface DiagnosticsClientOptions {
|
|
113
|
+
http: HttpContext;
|
|
114
|
+
discovery: DiscoveryClient;
|
|
115
|
+
/** Optional explicit sink — defaults to `console.log` JSON line. */
|
|
116
|
+
logSink?: LogSink;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=diagnostics-types.d.ts.map
|
|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OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC;CACZ,KAAK,IAAI,CAAC;AAEX,0CAA0C;AAC1C,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,eAAe,CAAC;IAC3B,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the diagnostics + preflight client.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `diagnostics.ts` so both the client (`diagnostics.ts`) and
|
|
5
|
+
* the pure check helpers (`diagnostics-checks.ts`) can reference them without
|
|
6
|
+
* a circular import, and so each file stays under the 400-line SDK module
|
|
7
|
+
* ceiling (CLAUDE.md §"Agent DX Rules").
|
|
8
|
+
*
|
|
9
|
+
* The public API is unchanged: `diagnostics.ts` re-exports every type below,
|
|
10
|
+
* so they remain importable from `@shardlink/agent-sdk` and
|
|
11
|
+
* `@shardlink/agent-sdk/diagnostics` exactly as before.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=diagnostics-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-types.js","sourceRoot":"","sources":["../../src/modules/diagnostics-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|