@nookplot/runtime 0.5.148 → 0.5.150
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/__tests__/apiMarketplace.test.js +2 -189
- package/dist/__tests__/apiMarketplace.test.js.map +1 -1
- package/dist/__tests__/autonomous.dedup.test.js +0 -11
- package/dist/__tests__/autonomous.dedup.test.js.map +1 -1
- package/dist/__tests__/autonomous.getAvailableActions.test.js +1 -13
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
- package/dist/__tests__/autonomous.openSignals.test.d.ts +13 -0
- package/dist/__tests__/autonomous.openSignals.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.openSignals.test.js +69 -0
- package/dist/__tests__/autonomous.openSignals.test.js.map +1 -0
- package/dist/__tests__/autonomous.v11OpenSignals.test.js +3 -0
- package/dist/__tests__/autonomous.v11OpenSignals.test.js.map +1 -1
- package/dist/__tests__/bdAgentPack.test.js +1 -1
- package/dist/__tests__/bdAgentPack.test.js.map +1 -1
- package/dist/__tests__/bounties.test.js +0 -12
- package/dist/__tests__/bounties.test.js.map +1 -1
- package/dist/__tests__/codegen-drift.test.js +1 -3
- package/dist/__tests__/codegen-drift.test.js.map +1 -1
- package/dist/__tests__/conversation/modelThresholdsParity.test.js +14 -19
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
- package/dist/__tests__/economy.frontierInference.test.d.ts +2 -0
- package/dist/__tests__/economy.frontierInference.test.d.ts.map +1 -0
- package/dist/__tests__/economy.frontierInference.test.js +61 -0
- package/dist/__tests__/economy.frontierInference.test.js.map +1 -0
- package/dist/__tests__/economy.surplusBranch.test.js +0 -64
- package/dist/__tests__/economy.surplusBranch.test.js.map +1 -1
- package/dist/__tests__/pack.test.js +14 -14
- package/dist/__tests__/packLoader.test.js +4 -4
- package/dist/__tests__/presetLoader.test.js +42 -42
- package/dist/__tests__/sandbox.test.js +24 -24
- package/dist/actionCatalog.d.ts.map +1 -1
- package/dist/actionCatalog.generated.d.ts +1 -1
- package/dist/actionCatalog.generated.d.ts.map +1 -1
- package/dist/actionCatalog.generated.js +31 -141
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/actionCatalog.js +10 -0
- package/dist/actionCatalog.js.map +1 -1
- package/dist/api-marketplace.d.ts +0 -146
- package/dist/api-marketplace.d.ts.map +1 -1
- package/dist/api-marketplace.js +0 -218
- package/dist/api-marketplace.js.map +1 -1
- package/dist/autonomous.d.ts +9 -16
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +59 -276
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.d.ts +0 -8
- package/dist/bounties.d.ts.map +1 -1
- package/dist/bounties.js +0 -2
- package/dist/bounties.js.map +1 -1
- package/dist/chat/terminals/httpChatTerminal.d.ts +43 -0
- package/dist/chat/terminals/httpChatTerminal.d.ts.map +1 -0
- package/dist/chat/terminals/httpChatTerminal.js +186 -0
- package/dist/chat/terminals/httpChatTerminal.js.map +1 -0
- package/dist/contentSafety.d.ts +1 -1
- package/dist/contentSafety.d.ts.map +1 -1
- package/dist/contentSafety.js +2 -6
- package/dist/contentSafety.js.map +1 -1
- package/dist/conversation/modelLimits.js +17 -17
- package/dist/discovery.js +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/economy.d.ts +15 -10
- package/dist/economy.d.ts.map +1 -1
- package/dist/economy.js +29 -16
- package/dist/economy.js.map +1 -1
- package/dist/frontierPass.d.ts +30 -0
- package/dist/frontierPass.d.ts.map +1 -0
- package/dist/frontierPass.js +42 -0
- package/dist/frontierPass.js.map +1 -0
- package/dist/goal/goalPrompts.js +27 -27
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +6 -15
- package/dist/signalActionMap.js.map +1 -1
- package/dist/swarms.d.ts +0 -13
- package/dist/swarms.d.ts.map +1 -1
- package/dist/swarms.js +0 -4
- package/dist/swarms.js.map +1 -1
- package/dist/tools.js +1 -1
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +4 -20
- package/dist/types.d.ts.map +1 -1
- package/package.json +75 -75
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts +0 -2
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts.map +0 -1
- package/dist/__tests__/autonomous.goalBootstrap.test.js +0 -148
- package/dist/__tests__/autonomous.goalBootstrap.test.js.map +0 -1
- package/dist/__tests__/autonomous.miningTrack.test.d.ts +0 -2
- package/dist/__tests__/autonomous.miningTrack.test.d.ts.map +0 -1
- package/dist/__tests__/autonomous.miningTrack.test.js +0 -38
- package/dist/__tests__/autonomous.miningTrack.test.js.map +0 -1
- package/dist/__tests__/autonomous.payApi.test.d.ts +0 -2
- package/dist/__tests__/autonomous.payApi.test.d.ts.map +0 -1
- package/dist/__tests__/autonomous.payApi.test.js +0 -73
- package/dist/__tests__/autonomous.payApi.test.js.map +0 -1
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts +0 -2
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts.map +0 -1
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js +0 -212
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js.map +0 -1
- package/dist/__tests__/mining.test.d.ts +0 -2
- package/dist/__tests__/mining.test.d.ts.map +0 -1
- package/dist/__tests__/mining.test.js +0 -306
- package/dist/__tests__/mining.test.js.map +0 -1
- package/dist/__tests__/signalActionMap.test.d.ts +0 -17
- package/dist/__tests__/signalActionMap.test.d.ts.map +0 -1
- package/dist/__tests__/signalActionMap.test.js +0 -165
- package/dist/__tests__/signalActionMap.test.js.map +0 -1
|
@@ -36,15 +36,6 @@ export interface ApiRegisterEndpointInput {
|
|
|
36
36
|
rateLimitRpm?: number;
|
|
37
37
|
allowedMethods?: string[];
|
|
38
38
|
maxPayloadBytes?: number;
|
|
39
|
-
/** Optional per-listing streaming wall-time, [1, 600] seconds. */
|
|
40
|
-
maxStreamSeconds?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Full upstream Authorization header value (e.g. "Bearer sk-..." or
|
|
43
|
-
* "Basic base64(user:pass)"). Encrypted at rest by the gateway with
|
|
44
|
-
* SECRET_ENCRYPTION_KEY. Pass `null` to clear an existing value; omit
|
|
45
|
-
* to leave it untouched on re-registration.
|
|
46
|
-
*/
|
|
47
|
-
upstreamAuth?: string | null;
|
|
48
39
|
}
|
|
49
40
|
/** Input for sending a provider heartbeat. */
|
|
50
41
|
export interface ApiHeartbeatInput {
|
|
@@ -52,44 +43,6 @@ export interface ApiHeartbeatInput {
|
|
|
52
43
|
latencyMs?: number;
|
|
53
44
|
activeAgreements?: number;
|
|
54
45
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Sampler for per-tick numeric fields on the heartbeat loop. Either a
|
|
57
|
-
* static value, a sync function, or an async function. Returning
|
|
58
|
-
* `undefined` (or throwing) omits the field from that tick's payload.
|
|
59
|
-
*/
|
|
60
|
-
export type ApiHeartbeatSampler = number | (() => number | undefined | Promise<number | undefined>);
|
|
61
|
-
/** Input for the long-running heartbeat helper {@link ApiMarketplaceManager.startHeartbeat}. */
|
|
62
|
-
export interface ApiStartHeartbeatInput {
|
|
63
|
-
listingId: number;
|
|
64
|
-
/**
|
|
65
|
-
* Interval between heartbeats in milliseconds. The gateway flips a
|
|
66
|
-
* listing to `degraded` after 5 min without one and `offline` after
|
|
67
|
-
* 15 min — choose well under 5 min (default in the CLI flag is 240000 = 4 min).
|
|
68
|
-
*/
|
|
69
|
-
intervalMs: number;
|
|
70
|
-
/** Optional p95 latency to attach to each heartbeat. Re-sampled per tick. */
|
|
71
|
-
latencyMs?: ApiHeartbeatSampler;
|
|
72
|
-
/** Optional active-agreement count. Re-sampled per tick. */
|
|
73
|
-
activeAgreements?: ApiHeartbeatSampler;
|
|
74
|
-
/**
|
|
75
|
-
* When `true`, wait one `intervalMs` before the first heartbeat instead
|
|
76
|
-
* of firing immediately. Defaults to `false` so the listing flips to
|
|
77
|
-
* `online` as soon as the loop starts.
|
|
78
|
-
*/
|
|
79
|
-
skipImmediate?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Called when a heartbeat throws. Receives the raw error. Defaults to
|
|
82
|
-
* `console.warn`. Return value is ignored; the loop always continues.
|
|
83
|
-
*/
|
|
84
|
-
onError?: (err: unknown) => void;
|
|
85
|
-
/** Called after each successful heartbeat with the gateway response. */
|
|
86
|
-
onSuccess?: (response: unknown) => void;
|
|
87
|
-
}
|
|
88
|
-
/** Handle returned by {@link ApiMarketplaceManager.startHeartbeat}. */
|
|
89
|
-
export interface ApiStartHeartbeatHandle {
|
|
90
|
-
/** Stop the loop. Idempotent. In-flight requests are NOT aborted but their result is discarded. */
|
|
91
|
-
stop: () => void;
|
|
92
|
-
}
|
|
93
46
|
/** Input for making a proxied API request. */
|
|
94
47
|
export interface ApiProxyRequestInput {
|
|
95
48
|
agreementId: number;
|
|
@@ -98,35 +51,13 @@ export interface ApiProxyRequestInput {
|
|
|
98
51
|
body?: unknown;
|
|
99
52
|
headers?: Record<string, string>;
|
|
100
53
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Quota snapshot parsed from `X-Nookplot-Quota-*` response headers
|
|
103
|
-
* (Phase 14.4). Present on every 2xx/4xx api-category proxy response;
|
|
104
|
-
* absent on 5xx responses and non-api agreements.
|
|
105
|
-
*/
|
|
106
|
-
export interface ApiProxyQuotaSnapshot {
|
|
107
|
-
/** Pricing model declared on the agreement's listing. */
|
|
108
|
-
model: string;
|
|
109
|
-
/** Total requests allowed for the bundle, or null for uncountable models. */
|
|
110
|
-
cap: number | null;
|
|
111
|
-
/** Requests remaining after this call, or null for uncountable models. */
|
|
112
|
-
remaining: number | null;
|
|
113
|
-
/** ISO 8601 reset timestamp, set on `per-month` pricing only. */
|
|
114
|
-
resetAt: string | null;
|
|
115
|
-
}
|
|
116
54
|
/** Result from a proxied API request. */
|
|
117
55
|
export interface ApiProxyResult {
|
|
118
56
|
status: number;
|
|
119
57
|
headers: Record<string, string>;
|
|
120
58
|
body: unknown;
|
|
121
59
|
requestId: string;
|
|
122
|
-
/** Parsed quota snapshot, when present. See `ApiProxyQuotaSnapshot`. */
|
|
123
|
-
quota: ApiProxyQuotaSnapshot | null;
|
|
124
60
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Parse `X-Nookplot-Quota-*` headers into a structured snapshot.
|
|
127
|
-
* Returns null when none of the expected headers are present.
|
|
128
|
-
*/
|
|
129
|
-
export declare function parseQuotaHeaders(headers: Record<string, string>): ApiProxyQuotaSnapshot | null;
|
|
130
61
|
export declare class ApiMarketplaceManager {
|
|
131
62
|
private readonly connection;
|
|
132
63
|
constructor(connection: ConnectionManager);
|
|
@@ -146,54 +77,10 @@ export declare class ApiMarketplaceManager {
|
|
|
146
77
|
* Register or update a proxy endpoint for an API listing.
|
|
147
78
|
*/
|
|
148
79
|
registerEndpoint(input: ApiRegisterEndpointInput): Promise<unknown>;
|
|
149
|
-
/**
|
|
150
|
-
* Unregister a proxy endpoint (Phase 11.1).
|
|
151
|
-
*
|
|
152
|
-
* Stops serving traffic on this listing immediately:
|
|
153
|
-
* - `api_proxy_config` row is deleted
|
|
154
|
-
* - `api_availability.status` is flipped to `offline`
|
|
155
|
-
* - subsequent proxy calls return 502 `provider has unregistered`
|
|
156
|
-
*
|
|
157
|
-
* Active agreements are NOT cancelled — the provider remains liable
|
|
158
|
-
* for any pre-paid escrow and must settle/cancel/let-expire each one
|
|
159
|
-
* on-chain. The returned `activeAgreements` count + `warning` string
|
|
160
|
-
* surface that liability to the caller.
|
|
161
|
-
*/
|
|
162
|
-
unregisterEndpoint(listingId: number): Promise<{
|
|
163
|
-
ok: true;
|
|
164
|
-
activeAgreements: number;
|
|
165
|
-
warning: string;
|
|
166
|
-
}>;
|
|
167
80
|
/**
|
|
168
81
|
* Send a heartbeat to indicate API is available.
|
|
169
82
|
*/
|
|
170
83
|
heartbeat(input: ApiHeartbeatInput): Promise<unknown>;
|
|
171
|
-
/**
|
|
172
|
-
* Long-running heartbeat loop for providers running on traditional
|
|
173
|
-
* (non-serverless) hosts. Fires {@link heartbeat} immediately, then
|
|
174
|
-
* every `intervalMs`. Returns a `stop()` callable.
|
|
175
|
-
*
|
|
176
|
-
* Errors are swallowed (logged via `onError` or `console.warn`) so a
|
|
177
|
-
* transient network blip never tears down the loop. The timer is
|
|
178
|
-
* `unref()`'d on Node so the process can still exit if nothing else
|
|
179
|
-
* is keeping it alive.
|
|
180
|
-
*
|
|
181
|
-
* Serverless agents (GH Actions, Vercel cron, k8s CronJob, AWS Lambda
|
|
182
|
-
* scheduled invokes) should keep calling the single-shot
|
|
183
|
-
* {@link heartbeat} from their own scheduler instead — the loop only
|
|
184
|
-
* makes sense for long-running processes.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```ts
|
|
188
|
-
* const { stop } = runtime.apiMarketplace.startHeartbeat({
|
|
189
|
-
* listingId: 42,
|
|
190
|
-
* intervalMs: 4 * 60 * 1000, // 4 min, under the 5-min degraded threshold
|
|
191
|
-
* latencyMs: () => latencyTracker.p95(),
|
|
192
|
-
* });
|
|
193
|
-
* process.on("SIGINT", () => { stop(); process.exit(0); });
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
startHeartbeat(input: ApiStartHeartbeatInput): ApiStartHeartbeatHandle;
|
|
197
84
|
/**
|
|
198
85
|
* Make a proxied API request through the gateway.
|
|
199
86
|
*
|
|
@@ -201,14 +88,6 @@ export declare class ApiMarketplaceManager {
|
|
|
201
88
|
* The gateway validates the signature, checks the agreement,
|
|
202
89
|
* meters usage, and forwards to the provider.
|
|
203
90
|
*
|
|
204
|
-
* **Idempotency (status-only).** If the same (signature, request_id) pair
|
|
205
|
-
* is submitted twice within the freshness window, the gateway returns
|
|
206
|
-
* `{ idempotent: true, status_code, request_id }` for the second call —
|
|
207
|
-
* the original response body is NOT replayed. Quota and billing increment
|
|
208
|
-
* exactly once. Pass a fresh `requestId` per logical request, or rely on
|
|
209
|
-
* the gateway to mint one. Body-level idempotency is the caller's
|
|
210
|
-
* responsibility (persist the first response and re-use it client-side).
|
|
211
|
-
*
|
|
212
91
|
* @param input - The proxy request parameters
|
|
213
92
|
* @param privateKey - The buyer's private key for signing
|
|
214
93
|
* @returns The proxied API response
|
|
@@ -227,31 +106,6 @@ export declare class ApiMarketplaceManager {
|
|
|
227
106
|
requestHash: string;
|
|
228
107
|
};
|
|
229
108
|
};
|
|
230
|
-
/**
|
|
231
|
-
* Phase 17.1 — open a streaming proxy request and yield decoded chunks
|
|
232
|
-
* as they arrive. The agent stays in control of when to stop reading;
|
|
233
|
-
* the underlying `fetch` Response is exposed via the optional `onResponse`
|
|
234
|
-
* callback so the caller can read trailer headers (request id, quota
|
|
235
|
-
* headers, etc.) once the stream completes.
|
|
236
|
-
*
|
|
237
|
-
* The gateway aborts streams that exceed the provider's declared
|
|
238
|
-
* `maxStreamSeconds` (capped at 600s); callers can also abort early by
|
|
239
|
-
* passing an `AbortSignal`.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* for await (const chunk of client.proxyRequestStream({
|
|
244
|
-
* agreementId: 1, path: "v1/chat/completions",
|
|
245
|
-
* body: { messages: [...], stream: true },
|
|
246
|
-
* }, privateKey)) {
|
|
247
|
-
* process.stdout.write(chunk);
|
|
248
|
-
* }
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
proxyRequestStream(input: ApiProxyRequestInput & {
|
|
252
|
-
signal?: AbortSignal;
|
|
253
|
-
onResponse?: (r: Response) => void;
|
|
254
|
-
}, privateKey: string): AsyncGenerator<string, void, void>;
|
|
255
109
|
}
|
|
256
110
|
export {};
|
|
257
111
|
//# sourceMappingURL=api-marketplace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-marketplace.d.ts","sourceRoot":"","sources":["../src/api-marketplace.ts"],"names":[],"mappings":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
|
|
11
11
|
*/
|
|
12
12
|
import { ethers } from "ethers";
|
|
13
13
|
// ── EIP-712 constants for proxy request signing ─────────────
|
|
14
|
-
//
|
|
15
|
-
// `verifyingContract` is intentionally omitted. The signature is verified
|
|
16
|
-
// off-chain at the gateway (see gateway/src/routes/api-marketplace.ts),
|
|
17
|
-
// not by any deployed contract, so EIP-712's optional verifyingContract
|
|
18
|
-
// field has no value to point at. The domain shape here must stay byte-
|
|
19
|
-
// identical to the gateway and Python runtime — any added field changes
|
|
20
|
-
// the typed-data digest and breaks signature verification.
|
|
21
14
|
const API_PROXY_DOMAIN = {
|
|
22
15
|
name: "NookplotApiProxy",
|
|
23
16
|
version: "1",
|
|
@@ -30,28 +23,6 @@ const API_REQUEST_TYPES = {
|
|
|
30
23
|
{ name: "requestHash", type: "bytes32" },
|
|
31
24
|
],
|
|
32
25
|
};
|
|
33
|
-
/**
|
|
34
|
-
* Parse `X-Nookplot-Quota-*` headers into a structured snapshot.
|
|
35
|
-
* Returns null when none of the expected headers are present.
|
|
36
|
-
*/
|
|
37
|
-
export function parseQuotaHeaders(headers) {
|
|
38
|
-
const model = headers["x-nookplot-quota-model"];
|
|
39
|
-
if (!model)
|
|
40
|
-
return null;
|
|
41
|
-
const resetAt = headers["x-nookplot-quota-reset-at"] ?? null;
|
|
42
|
-
const parseIntOrNull = (raw) => {
|
|
43
|
-
if (raw === undefined || raw === "")
|
|
44
|
-
return null;
|
|
45
|
-
const n = Number(raw);
|
|
46
|
-
return Number.isFinite(n) ? n : null;
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
49
|
-
model,
|
|
50
|
-
cap: parseIntOrNull(headers["x-nookplot-quota-cap"]),
|
|
51
|
-
remaining: parseIntOrNull(headers["x-nookplot-quota-remaining"]),
|
|
52
|
-
resetAt,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
26
|
// ── Manager ─────────────────────────────────────────────────
|
|
56
27
|
export class ApiMarketplaceManager {
|
|
57
28
|
connection;
|
|
@@ -98,124 +69,12 @@ export class ApiMarketplaceManager {
|
|
|
98
69
|
async registerEndpoint(input) {
|
|
99
70
|
return this.connection.request("POST", "/v1/api/register-endpoint", input);
|
|
100
71
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Unregister a proxy endpoint (Phase 11.1).
|
|
103
|
-
*
|
|
104
|
-
* Stops serving traffic on this listing immediately:
|
|
105
|
-
* - `api_proxy_config` row is deleted
|
|
106
|
-
* - `api_availability.status` is flipped to `offline`
|
|
107
|
-
* - subsequent proxy calls return 502 `provider has unregistered`
|
|
108
|
-
*
|
|
109
|
-
* Active agreements are NOT cancelled — the provider remains liable
|
|
110
|
-
* for any pre-paid escrow and must settle/cancel/let-expire each one
|
|
111
|
-
* on-chain. The returned `activeAgreements` count + `warning` string
|
|
112
|
-
* surface that liability to the caller.
|
|
113
|
-
*/
|
|
114
|
-
async unregisterEndpoint(listingId) {
|
|
115
|
-
return this.connection.request("DELETE", `/v1/api/register-endpoint/${listingId}`);
|
|
116
|
-
}
|
|
117
72
|
/**
|
|
118
73
|
* Send a heartbeat to indicate API is available.
|
|
119
74
|
*/
|
|
120
75
|
async heartbeat(input) {
|
|
121
76
|
return this.connection.request("POST", "/v1/api/heartbeat", input);
|
|
122
77
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Long-running heartbeat loop for providers running on traditional
|
|
125
|
-
* (non-serverless) hosts. Fires {@link heartbeat} immediately, then
|
|
126
|
-
* every `intervalMs`. Returns a `stop()` callable.
|
|
127
|
-
*
|
|
128
|
-
* Errors are swallowed (logged via `onError` or `console.warn`) so a
|
|
129
|
-
* transient network blip never tears down the loop. The timer is
|
|
130
|
-
* `unref()`'d on Node so the process can still exit if nothing else
|
|
131
|
-
* is keeping it alive.
|
|
132
|
-
*
|
|
133
|
-
* Serverless agents (GH Actions, Vercel cron, k8s CronJob, AWS Lambda
|
|
134
|
-
* scheduled invokes) should keep calling the single-shot
|
|
135
|
-
* {@link heartbeat} from their own scheduler instead — the loop only
|
|
136
|
-
* makes sense for long-running processes.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* const { stop } = runtime.apiMarketplace.startHeartbeat({
|
|
141
|
-
* listingId: 42,
|
|
142
|
-
* intervalMs: 4 * 60 * 1000, // 4 min, under the 5-min degraded threshold
|
|
143
|
-
* latencyMs: () => latencyTracker.p95(),
|
|
144
|
-
* });
|
|
145
|
-
* process.on("SIGINT", () => { stop(); process.exit(0); });
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
startHeartbeat(input) {
|
|
149
|
-
if (!Number.isFinite(input.intervalMs) || input.intervalMs <= 0) {
|
|
150
|
-
throw new Error(`startHeartbeat: intervalMs must be a positive finite number (got ${input.intervalMs})`);
|
|
151
|
-
}
|
|
152
|
-
if (!Number.isFinite(input.listingId) || input.listingId < 0) {
|
|
153
|
-
throw new Error(`startHeartbeat: listingId must be a non-negative number (got ${input.listingId})`);
|
|
154
|
-
}
|
|
155
|
-
let stopped = false;
|
|
156
|
-
let timer = null;
|
|
157
|
-
const resolveSample = async (s) => {
|
|
158
|
-
if (s === undefined)
|
|
159
|
-
return undefined;
|
|
160
|
-
if (typeof s === "number")
|
|
161
|
-
return s;
|
|
162
|
-
try {
|
|
163
|
-
const v = await s();
|
|
164
|
-
return typeof v === "number" && Number.isFinite(v) ? v : undefined;
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const schedule = (delayMs) => {
|
|
171
|
-
timer = setTimeout(tick, delayMs);
|
|
172
|
-
// Node-only: don't keep the event loop alive just for the heartbeat.
|
|
173
|
-
const t = timer;
|
|
174
|
-
if (typeof t.unref === "function")
|
|
175
|
-
t.unref();
|
|
176
|
-
};
|
|
177
|
-
const tick = async () => {
|
|
178
|
-
if (stopped)
|
|
179
|
-
return;
|
|
180
|
-
try {
|
|
181
|
-
const beat = { listingId: input.listingId };
|
|
182
|
-
const latencyMs = await resolveSample(input.latencyMs);
|
|
183
|
-
if (latencyMs !== undefined)
|
|
184
|
-
beat.latencyMs = latencyMs;
|
|
185
|
-
const activeAgreements = await resolveSample(input.activeAgreements);
|
|
186
|
-
if (activeAgreements !== undefined)
|
|
187
|
-
beat.activeAgreements = activeAgreements;
|
|
188
|
-
const response = await this.heartbeat(beat);
|
|
189
|
-
if (!stopped)
|
|
190
|
-
input.onSuccess?.(response);
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
if (stopped)
|
|
194
|
-
return;
|
|
195
|
-
if (input.onError) {
|
|
196
|
-
input.onError(err);
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
200
|
-
console.warn(`[nookplot] heartbeat failed for listing ${input.listingId}: ${msg}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
finally {
|
|
204
|
-
if (!stopped)
|
|
205
|
-
schedule(input.intervalMs);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
schedule(input.skipImmediate ? input.intervalMs : 0);
|
|
209
|
-
return {
|
|
210
|
-
stop: () => {
|
|
211
|
-
stopped = true;
|
|
212
|
-
if (timer !== null) {
|
|
213
|
-
clearTimeout(timer);
|
|
214
|
-
timer = null;
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
78
|
// ============================================================
|
|
220
79
|
// Proxy Request (Buyer)
|
|
221
80
|
// ============================================================
|
|
@@ -226,14 +85,6 @@ export class ApiMarketplaceManager {
|
|
|
226
85
|
* The gateway validates the signature, checks the agreement,
|
|
227
86
|
* meters usage, and forwards to the provider.
|
|
228
87
|
*
|
|
229
|
-
* **Idempotency (status-only).** If the same (signature, request_id) pair
|
|
230
|
-
* is submitted twice within the freshness window, the gateway returns
|
|
231
|
-
* `{ idempotent: true, status_code, request_id }` for the second call —
|
|
232
|
-
* the original response body is NOT replayed. Quota and billing increment
|
|
233
|
-
* exactly once. Pass a fresh `requestId` per logical request, or rely on
|
|
234
|
-
* the gateway to mint one. Body-level idempotency is the caller's
|
|
235
|
-
* responsibility (persist the first response and re-use it client-side).
|
|
236
|
-
*
|
|
237
88
|
* @param input - The proxy request parameters
|
|
238
89
|
* @param privateKey - The buyer's private key for signing
|
|
239
90
|
* @returns The proxied API response
|
|
@@ -280,7 +131,6 @@ export class ApiMarketplaceManager {
|
|
|
280
131
|
headers: responseHeaders,
|
|
281
132
|
body: responseBody,
|
|
282
133
|
requestId: responseHeaders["x-nookplot-request-id"] ?? "",
|
|
283
|
-
quota: parseQuotaHeaders(responseHeaders),
|
|
284
134
|
};
|
|
285
135
|
}
|
|
286
136
|
/**
|
|
@@ -300,73 +150,5 @@ export class ApiMarketplaceManager {
|
|
|
300
150
|
},
|
|
301
151
|
};
|
|
302
152
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Phase 17.1 — open a streaming proxy request and yield decoded chunks
|
|
305
|
-
* as they arrive. The agent stays in control of when to stop reading;
|
|
306
|
-
* the underlying `fetch` Response is exposed via the optional `onResponse`
|
|
307
|
-
* callback so the caller can read trailer headers (request id, quota
|
|
308
|
-
* headers, etc.) once the stream completes.
|
|
309
|
-
*
|
|
310
|
-
* The gateway aborts streams that exceed the provider's declared
|
|
311
|
-
* `maxStreamSeconds` (capped at 600s); callers can also abort early by
|
|
312
|
-
* passing an `AbortSignal`.
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* ```ts
|
|
316
|
-
* for await (const chunk of client.proxyRequestStream({
|
|
317
|
-
* agreementId: 1, path: "v1/chat/completions",
|
|
318
|
-
* body: { messages: [...], stream: true },
|
|
319
|
-
* }, privateKey)) {
|
|
320
|
-
* process.stdout.write(chunk);
|
|
321
|
-
* }
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
async *proxyRequestStream(input, privateKey) {
|
|
325
|
-
const method = input.method ?? "POST";
|
|
326
|
-
const bodyStr = input.body ? JSON.stringify(input.body) : "";
|
|
327
|
-
const timestamp = Math.floor(Date.now() / 1000);
|
|
328
|
-
const requestHash = ethers.keccak256(ethers.toUtf8Bytes(`${method}:${input.path}:${bodyStr}`));
|
|
329
|
-
const wallet = new ethers.Wallet(privateKey);
|
|
330
|
-
const signature = await wallet.signTypedData(API_PROXY_DOMAIN, API_REQUEST_TYPES, {
|
|
331
|
-
agreementId: BigInt(input.agreementId),
|
|
332
|
-
timestamp: BigInt(timestamp),
|
|
333
|
-
requestHash,
|
|
334
|
-
});
|
|
335
|
-
const url = `${this.connection.gatewayUrl}/v1/api-proxy/${input.agreementId}/${input.path}`;
|
|
336
|
-
const headers = {
|
|
337
|
-
"Authorization": `Bearer ${this.connection.apiKey}`,
|
|
338
|
-
"Content-Type": "application/json",
|
|
339
|
-
"X-Nookplot-Signature": signature,
|
|
340
|
-
"X-Nookplot-Timestamp": String(timestamp),
|
|
341
|
-
"Accept": "text/event-stream",
|
|
342
|
-
...input.headers,
|
|
343
|
-
};
|
|
344
|
-
const init = { method, headers, signal: input.signal };
|
|
345
|
-
if (bodyStr && !["GET", "HEAD"].includes(method)) {
|
|
346
|
-
init.body = bodyStr;
|
|
347
|
-
}
|
|
348
|
-
const response = await fetch(url, init);
|
|
349
|
-
input.onResponse?.(response);
|
|
350
|
-
if (!response.body)
|
|
351
|
-
return;
|
|
352
|
-
const decoder = new TextDecoder();
|
|
353
|
-
const reader = response.body.getReader();
|
|
354
|
-
try {
|
|
355
|
-
// eslint-disable-next-line no-constant-condition
|
|
356
|
-
while (true) {
|
|
357
|
-
const { done, value } = await reader.read();
|
|
358
|
-
if (done)
|
|
359
|
-
break;
|
|
360
|
-
if (value)
|
|
361
|
-
yield decoder.decode(value, { stream: true });
|
|
362
|
-
}
|
|
363
|
-
const tail = decoder.decode();
|
|
364
|
-
if (tail)
|
|
365
|
-
yield tail;
|
|
366
|
-
}
|
|
367
|
-
finally {
|
|
368
|
-
reader.releaseLock();
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
153
|
}
|
|
372
154
|
//# sourceMappingURL=api-marketplace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-marketplace.js","sourceRoot":"","sources":["../src/api-marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+DAA+D;
|
|
1
|
+
{"version":3,"file":"api-marketplace.js","sourceRoot":"","sources":["../src/api-marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+DAA+D;AAE/D,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;CACd,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE;QACV,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;QACxC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;QACtC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;KACzC;CACF,CAAC;AA8CF,+DAA+D;AAE/D,MAAM,OAAO,qBAAqB;IACf,UAAU,CAAoB;IAE/C,YAAY,UAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,+DAA+D;IAC/D,mBAAmB;IACnB,+DAA+D;IAE/D;;OAEG;IACH,KAAK,CAAC,eAAe,CAAC,IAAuB;QAC3C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,IAAI,EAAE,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,IAAI,EAAE,SAAS,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,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AC,CACtD,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,gBAAgB;YACxB,KAAK,EAAE,iBAAiB;YACxB,KAAK,EAAE;gBACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;gBAChC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;gBAC5B,WAAW;aACZ;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/autonomous.d.ts
CHANGED
|
@@ -191,21 +191,6 @@ export declare class AutonomousAgent {
|
|
|
191
191
|
start(): void;
|
|
192
192
|
/** Stop the autonomous agent. */
|
|
193
193
|
stop(): void;
|
|
194
|
-
/**
|
|
195
|
-
* Check whether this agent has an initial_goal + pending status, and
|
|
196
|
-
* if so, spin up a GoalLoop in the background. Non-blocking — start()
|
|
197
|
-
* returns immediately so WebSocket signal subscriptions are live even
|
|
198
|
-
* while the goal loop is running its first step.
|
|
199
|
-
*/
|
|
200
|
-
private maybeBootstrapGoal;
|
|
201
|
-
/**
|
|
202
|
-
* Dispatch on the terminal state of a GoalLoop run:
|
|
203
|
-
* - complete → store artifact in private KG, pause agent
|
|
204
|
-
* - blocked_budget → create pending task (budget_exhausted), pause
|
|
205
|
-
* - blocked_stuck → create pending task (stuck_3x), pause
|
|
206
|
-
* - blocked_capability → create pending task (needs_capability), pause
|
|
207
|
-
*/
|
|
208
|
-
private handleGoalResult;
|
|
209
194
|
/**
|
|
210
195
|
* Build a stable dedup key from a signal so we can detect duplicates.
|
|
211
196
|
* DMs dedup on sender, followers dedup on address, channels dedup on channel+sender.
|
|
@@ -221,7 +206,6 @@ export declare class AutonomousAgent {
|
|
|
221
206
|
private handleAttestationOpportunity;
|
|
222
207
|
private handleBounty;
|
|
223
208
|
private handleGuildOpportunity;
|
|
224
|
-
private handleWorkspaceOpportunity;
|
|
225
209
|
private handleMiningOpportunity;
|
|
226
210
|
private handleSubmissionVerified;
|
|
227
211
|
private handleLearningCommentReceived;
|
|
@@ -251,6 +235,7 @@ export declare class AutonomousAgent {
|
|
|
251
235
|
private handleOnboardingSuggestion;
|
|
252
236
|
private handleSpecializationPath;
|
|
253
237
|
private handleCommunityGap;
|
|
238
|
+
private handleDirective;
|
|
254
239
|
private handleFilesCommitted;
|
|
255
240
|
private handleReviewSubmitted;
|
|
256
241
|
private handleCollaboratorAdded;
|
|
@@ -282,6 +267,14 @@ export declare class AutonomousAgent {
|
|
|
282
267
|
* the agent collaborates on have no reviews yet.
|
|
283
268
|
*/
|
|
284
269
|
private handlePendingReview;
|
|
270
|
+
/**
|
|
271
|
+
* Execute a `use_frontier_model` action — delegates to the shared
|
|
272
|
+
* {@link runFrontierPass} so the runtime + CLI dispatch paths can't drift on
|
|
273
|
+
* this money path. Consumes an owner-reserved pass, runs a one-shot Surplus
|
|
274
|
+
* completion paid by the agent's OWN x402 key, finalizes (or reverts on
|
|
275
|
+
* failure). Returns the frontier answer, or an `{ error }` tool result.
|
|
276
|
+
*/
|
|
277
|
+
private executeFrontierPass;
|
|
285
278
|
private handleActionRequest;
|
|
286
279
|
private handleTeachingProposed;
|
|
287
280
|
private handleTeachingAccepted;
|
package/dist/autonomous.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autonomous.d.ts","sourceRoot":"","sources":["../src/autonomous.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"autonomous.d.ts","sourceRoot":"","sources":["../src/autonomous.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,OAAO,EAAsB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