@nookplot/runtime 0.5.144 → 0.5.145
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 +189 -2
- package/dist/__tests__/apiMarketplace.test.js.map +1 -1
- package/dist/__tests__/autonomous.dedup.test.js +11 -0
- package/dist/__tests__/autonomous.dedup.test.js.map +1 -1
- package/dist/__tests__/autonomous.getAvailableActions.test.js +13 -1
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -1
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts +2 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js +148 -0
- package/dist/__tests__/autonomous.goalBootstrap.test.js.map +1 -0
- package/dist/__tests__/autonomous.miningTrack.test.d.ts +2 -0
- package/dist/__tests__/autonomous.miningTrack.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.miningTrack.test.js +38 -0
- package/dist/__tests__/autonomous.miningTrack.test.js.map +1 -0
- package/dist/__tests__/autonomous.payApi.test.d.ts +2 -0
- package/dist/__tests__/autonomous.payApi.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.payApi.test.js +73 -0
- package/dist/__tests__/autonomous.payApi.test.js.map +1 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts +2 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js +212 -0
- package/dist/__tests__/autonomous.workspaceOpportunity.test.js.map +1 -0
- package/dist/__tests__/bdAgentPack.test.js +1 -1
- package/dist/__tests__/bdAgentPack.test.js.map +1 -1
- package/dist/__tests__/bounties.test.d.ts +11 -0
- package/dist/__tests__/bounties.test.d.ts.map +1 -0
- package/dist/__tests__/bounties.test.js +78 -0
- package/dist/__tests__/bounties.test.js.map +1 -0
- package/dist/__tests__/codegen-drift.test.js +3 -1
- package/dist/__tests__/codegen-drift.test.js.map +1 -1
- package/dist/__tests__/conversation/modelThresholdsParity.test.js +19 -14
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
- package/dist/__tests__/economy.surplusBranch.test.js +64 -0
- package/dist/__tests__/economy.surplusBranch.test.js.map +1 -1
- package/dist/__tests__/goalLoop.test.d.ts +2 -0
- package/dist/__tests__/goalLoop.test.d.ts.map +1 -0
- package/dist/__tests__/goalLoop.test.js +358 -0
- package/dist/__tests__/goalLoop.test.js.map +1 -0
- package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -1
- package/dist/__tests__/helpers/mockRuntime.js +7 -0
- package/dist/__tests__/helpers/mockRuntime.js.map +1 -1
- package/dist/__tests__/loadProfile.test.d.ts +8 -0
- package/dist/__tests__/loadProfile.test.d.ts.map +1 -0
- package/dist/__tests__/loadProfile.test.js +134 -0
- package/dist/__tests__/loadProfile.test.js.map +1 -0
- package/dist/__tests__/mining.test.d.ts +2 -0
- package/dist/__tests__/mining.test.d.ts.map +1 -0
- package/dist/__tests__/mining.test.js +306 -0
- package/dist/__tests__/mining.test.js.map +1 -0
- 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__/runtimeConstructor.test.d.ts +18 -0
- package/dist/__tests__/runtimeConstructor.test.d.ts.map +1 -0
- package/dist/__tests__/runtimeConstructor.test.js +57 -0
- package/dist/__tests__/runtimeConstructor.test.js.map +1 -0
- package/dist/__tests__/sandbox.test.js +24 -24
- package/dist/__tests__/signalActionMap.test.d.ts +17 -0
- package/dist/__tests__/signalActionMap.test.d.ts.map +1 -0
- package/dist/__tests__/signalActionMap.test.js +165 -0
- package/dist/__tests__/signalActionMap.test.js.map +1 -0
- package/dist/__tests__/usdcBudget.test.d.ts +2 -0
- package/dist/__tests__/usdcBudget.test.d.ts.map +1 -0
- package/dist/__tests__/usdcBudget.test.js +128 -0
- package/dist/__tests__/usdcBudget.test.js.map +1 -0
- package/dist/__tests__/x402.test.d.ts +2 -0
- package/dist/__tests__/x402.test.d.ts.map +1 -0
- package/dist/__tests__/x402.test.js +117 -0
- package/dist/__tests__/x402.test.js.map +1 -0
- 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 +154 -29
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/actionCatalog.js +0 -10
- package/dist/actionCatalog.js.map +1 -1
- package/dist/api-marketplace.d.ts +146 -0
- package/dist/api-marketplace.d.ts.map +1 -1
- package/dist/api-marketplace.js +218 -0
- package/dist/api-marketplace.js.map +1 -1
- package/dist/autonomous.d.ts +16 -9
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +278 -59
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.d.ts +21 -1
- package/dist/bounties.d.ts.map +1 -1
- package/dist/bounties.js +5 -1
- package/dist/bounties.js.map +1 -1
- package/dist/contentSafety.d.ts +1 -1
- package/dist/contentSafety.d.ts.map +1 -1
- package/dist/contentSafety.js +6 -2
- 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 +10 -15
- package/dist/economy.d.ts.map +1 -1
- package/dist/economy.js +16 -29
- package/dist/economy.js.map +1 -1
- package/dist/goal/goalLoop.d.ts +78 -0
- package/dist/goal/goalLoop.d.ts.map +1 -0
- package/dist/goal/goalLoop.js +388 -0
- package/dist/goal/goalLoop.js.map +1 -0
- package/dist/goal/goalPrompts.d.ts +20 -0
- package/dist/goal/goalPrompts.d.ts.map +1 -0
- package/dist/goal/goalPrompts.js +54 -0
- package/dist/goal/goalPrompts.js.map +1 -0
- package/dist/goal/types.d.ts +102 -0
- package/dist/goal/types.d.ts.map +1 -0
- package/dist/goal/types.js +7 -0
- package/dist/goal/types.js.map +1 -0
- package/dist/identity.d.ts +51 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +50 -0
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/dist/loadProfile.d.ts +100 -0
- package/dist/loadProfile.d.ts.map +1 -0
- package/dist/loadProfile.js +221 -0
- package/dist/loadProfile.js.map +1 -0
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +16 -5
- package/dist/signalActionMap.js.map +1 -1
- package/dist/swarms.d.ts +13 -0
- package/dist/swarms.d.ts.map +1 -1
- package/dist/swarms.js +4 -0
- 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 +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/usdcBudget.d.ts +90 -0
- package/dist/usdcBudget.d.ts.map +1 -0
- package/dist/usdcBudget.js +155 -0
- package/dist/usdcBudget.js.map +1 -0
- package/dist/x402.d.ts +69 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +139 -0
- package/dist/x402.js.map +1 -0
- package/package.json +1 -1
- package/dist/__tests__/economy.frontierInference.test.d.ts +0 -2
- package/dist/__tests__/economy.frontierInference.test.d.ts.map +0 -1
- package/dist/__tests__/economy.frontierInference.test.js +0 -61
- package/dist/__tests__/economy.frontierInference.test.js.map +0 -1
- package/dist/frontierPass.d.ts +0 -30
- package/dist/frontierPass.d.ts.map +0 -1
- package/dist/frontierPass.js +0 -42
- package/dist/frontierPass.js.map +0 -1
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EconomyManager.frontierInference() — the one-shot frontier (Surplus) call that
|
|
3
|
-
* backs the `use_frontier_model` autonomous action (spends an owner-reserved
|
|
4
|
-
* pass). Contract:
|
|
5
|
-
* 1. ALWAYS routes to Surplus regardless of the configured default source.
|
|
6
|
-
* 2. Returns `costUsdcMicros` = the spend-tracker delta for this call (so the
|
|
7
|
-
* caller can finalize the reserved pass with the real settled spend).
|
|
8
|
-
* 3. Throws a keyless SurplusError (no network) when there's no private key.
|
|
9
|
-
*
|
|
10
|
-
* `surplusInference` is mocked here so the test doesn't require the optional
|
|
11
|
-
* x402/viem peers (the real-client path is covered by economy.surplusBranch).
|
|
12
|
-
*/
|
|
13
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
14
|
-
vi.mock("../inference/surplusInference.js", async (importOriginal) => {
|
|
15
|
-
const actual = await importOriginal();
|
|
16
|
-
return {
|
|
17
|
-
...actual,
|
|
18
|
-
// Simulate an x402 spend of $0.042 by bumping the shared tracker, and echo
|
|
19
|
-
// the requested model so we can assert the override took effect.
|
|
20
|
-
surplusInference: vi.fn(async (params) => {
|
|
21
|
-
if (params.tracker)
|
|
22
|
-
params.tracker.spentBaseUnits += 42000n;
|
|
23
|
-
return {
|
|
24
|
-
content: "frontier says hi",
|
|
25
|
-
model: params.options?.model ?? "unknown",
|
|
26
|
-
provider: "surplus",
|
|
27
|
-
usage: { promptTokens: 1, completionTokens: 1, totalTokens: 2, creditsCost: 0 },
|
|
28
|
-
};
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
const { ConnectionManager } = await import("../connection.js");
|
|
33
|
-
const { EconomyManager } = await import("../economy.js");
|
|
34
|
-
const surplusMod = await import("../inference/surplusInference.js");
|
|
35
|
-
const TEST_PK = "0x" + "ab".repeat(32);
|
|
36
|
-
const TEST_BASE = "https://gateway.example.com";
|
|
37
|
-
const MSGS = [{ role: "user", content: "Prove the theorem." }];
|
|
38
|
-
beforeEach(() => vi.clearAllMocks());
|
|
39
|
-
describe("EconomyManager.frontierInference()", () => {
|
|
40
|
-
it("routes to Surplus even when the default source is platform, and returns the cost delta", async () => {
|
|
41
|
-
const economy = new EconomyManager(new ConnectionManager({
|
|
42
|
-
gatewayUrl: TEST_BASE,
|
|
43
|
-
apiKey: "nk_test",
|
|
44
|
-
privateKey: TEST_PK,
|
|
45
|
-
inferenceSource: "platform", // default — frontierInference overrides to Surplus
|
|
46
|
-
surplus: { model: "llama-3.3-70b" },
|
|
47
|
-
}));
|
|
48
|
-
const result = await economy.frontierInference(MSGS, { model: "claude-opus-4.8" });
|
|
49
|
-
expect(surplusMod.surplusInference).toHaveBeenCalledTimes(1);
|
|
50
|
-
expect(result.provider).toBe("surplus");
|
|
51
|
-
expect(result.content).toBe("frontier says hi");
|
|
52
|
-
expect(result.model).toBe("claude-opus-4.8"); // the per-call override won
|
|
53
|
-
expect(result.costUsdcMicros).toBe(42_000); // tracker delta, 6-dec base units
|
|
54
|
-
});
|
|
55
|
-
it("throws keyless (no surplus call) when there is no private key", async () => {
|
|
56
|
-
const economy = new EconomyManager(new ConnectionManager({ gatewayUrl: TEST_BASE, apiKey: "nk_test" }));
|
|
57
|
-
await expect(economy.frontierInference(MSGS, { model: "claude-opus-4.8" })).rejects.toMatchObject({ code: "keyless" });
|
|
58
|
-
expect(surplusMod.surplusInference).not.toHaveBeenCalled();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=economy.frontierInference.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"economy.frontierInference.test.js","sourceRoot":"","sources":["../../src/__tests__/economy.frontierInference.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,EAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,cAAc,EAAqD,CAAC;IACzF,OAAO;QACL,GAAG,MAAM;QACT,2EAA2E;QAC3E,iEAAiE;QACjE,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,KA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omous
|
|
3
|
-
* loop (autonomous.ts) and the CLI dispatcher (agentLoop.ts), which have
|
|
4
|
-
* parallel action-dispatch paths. Keeping the logic here prevents the two from
|
|
5
|
-
* drifting on a money path.
|
|
6
|
-
*
|
|
7
|
-
* Flow (client-executed, non-custodial — the gateway can't run this):
|
|
8
|
-
* 1. consume — claim ONE owner-reserved pass (gateway enforces reserved count
|
|
9
|
-
* + rolling daily cap; a 409/429 surfaces as a thrown request error).
|
|
10
|
-
* 2. run — one-shot Surplus completion paid by the agent's OWN client-signed
|
|
11
|
-
* x402 key (economy.frontierInference).
|
|
12
|
-
* 3. finalize — record the real settled spend; OR revert the pass to
|
|
13
|
-
* 'reserved' on failure so it isn't wasted.
|
|
14
|
-
*
|
|
15
|
-
* @module frontierPass
|
|
16
|
-
*/
|
|
17
|
-
import type { ConnectionManager } from "./connection.js";
|
|
18
|
-
import type { EconomyManager } from "./economy.js";
|
|
19
|
-
export interface FrontierPassResult {
|
|
20
|
-
ok?: boolean;
|
|
21
|
-
model?: string;
|
|
22
|
-
answer?: string;
|
|
23
|
-
spent_usdc?: string;
|
|
24
|
-
error?: string;
|
|
25
|
-
message?: string;
|
|
26
|
-
/** Loose result object the agent reads as a tool result. */
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
export declare function runFrontierPass(connection: ConnectionManager, economy: EconomyManager, args: Record<string, unknown>, agentAddress?: string): Promise<FrontierPassResult>;
|
|
30
|
-
//# sourceMappingURL=frontierPass.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frontierPass.d.ts","sourceRoot":"","sources":["../src/frontierPass.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAsB,eAAe,CACnC,UAAU,EAAE,iBAAiB,EAC7B,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAyC7B"}
|
package/dist/frontierPass.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export async function runFrontierPass(connection, economy, args, agentAddress) {
|
|
2
|
-
const model = String(args.model ?? "").trim();
|
|
3
|
-
const task = String(args.task ?? "").trim();
|
|
4
|
-
const reason = typeof args.reason === "string" ? args.reason.slice(0, 280) : undefined;
|
|
5
|
-
if (!model)
|
|
6
|
-
return { error: "bad_model", message: "Pass a `model` (a Surplus model id)." };
|
|
7
|
-
if (!task)
|
|
8
|
-
return { error: "bad_task", message: "Pass the `task` — the full self-contained prompt for the frontier model." };
|
|
9
|
-
if (!agentAddress)
|
|
10
|
-
return { error: "frontier_unavailable", message: "Agent address unknown — cannot consume a pass." };
|
|
11
|
-
// 1. Claim a reserved pass.
|
|
12
|
-
let claim;
|
|
13
|
-
try {
|
|
14
|
-
claim = await connection.request("POST", `/v1/agents/${agentAddress}/inference-passes/consume`, { model, reason });
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
18
|
-
return {
|
|
19
|
-
error: "no_reserved_pass",
|
|
20
|
-
message: `Couldn't claim a ${model} pass: ${msg}. Ask your owner to reserve passes in the agent's vault.`,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
// 2. Run the one-shot frontier completion (client-signed x402, own USDC).
|
|
24
|
-
try {
|
|
25
|
-
const out = await economy.frontierInference([{ role: "user", content: task }], { model });
|
|
26
|
-
const costUsdcMicros = Number.isFinite(out.costUsdcMicros) ? out.costUsdcMicros : 0;
|
|
27
|
-
// 3. Record the settled spend (best-effort — the inference already happened).
|
|
28
|
-
await connection
|
|
29
|
-
.request("POST", `/v1/agents/${agentAddress}/inference-passes/${claim.passId}/finalize`, { costUsdcMicros })
|
|
30
|
-
.catch(() => { });
|
|
31
|
-
return { ok: true, model, answer: out.content ?? "", spent_usdc: (costUsdcMicros / 1e6).toFixed(6) };
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
// x402 declined / timed out / provider error → return the pass to 'reserved'.
|
|
35
|
-
await connection
|
|
36
|
-
.request("POST", `/v1/agents/${agentAddress}/inference-passes/${claim.passId}/revert`, {})
|
|
37
|
-
.catch(() => { });
|
|
38
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
39
|
-
return { error: "frontier_call_failed", message: `Frontier call failed (your pass was NOT spent): ${msg}` };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=frontierPass.js.map
|
package/dist/frontierPass.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"frontierPass.js","sourceRoot":"","sources":["../src/frontierPass.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B,EAC7B,OAAuB,EACvB,IAA6B,EAC7B,YAAqB;IAErB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,MAAM,GAAG,OAAO,IAAI,CAAC,MAAM,K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