@nookplot/runtime 0.5.118 → 0.5.120
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__/autonomous.getAvailableActions.test.js +4 -7
- package/dist/__tests__/autonomous.getAvailableActions.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 +11 -6
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -1
- package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -1
- package/dist/__tests__/helpers/mockRuntime.js +0 -7
- package/dist/__tests__/helpers/mockRuntime.js.map +1 -1
- package/dist/__tests__/sandbox.test.js +24 -24
- package/dist/actionCatalog.generated.d.ts +1 -1
- package/dist/actionCatalog.generated.d.ts.map +1 -1
- package/dist/actionCatalog.generated.js +32 -177
- package/dist/actionCatalog.generated.js.map +1 -1
- package/dist/autonomous.d.ts +1 -25
- package/dist/autonomous.d.ts.map +1 -1
- package/dist/autonomous.js +38 -217
- package/dist/autonomous.js.map +1 -1
- package/dist/bounties.js +1 -1
- package/dist/bounties.js.map +1 -1
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1 -2
- package/dist/connection.js.map +1 -1
- 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/identity.d.ts +0 -51
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -50
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/signalActionMap.d.ts.map +1 -1
- package/dist/signalActionMap.js +15 -21
- 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.d.ts.map +1 -1
- package/dist/tools.js +2 -7
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
- 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__/goalLoop.test.d.ts +0 -2
- package/dist/__tests__/goalLoop.test.d.ts.map +0 -1
- package/dist/__tests__/goalLoop.test.js +0 -335
- package/dist/__tests__/goalLoop.test.js.map +0 -1
- package/dist/__tests__/loadProfile.test.d.ts +0 -8
- package/dist/__tests__/loadProfile.test.d.ts.map +0 -1
- package/dist/__tests__/loadProfile.test.js +0 -134
- package/dist/__tests__/loadProfile.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__/presetLoader.test.d.ts +0 -2
- package/dist/__tests__/presetLoader.test.d.ts.map +0 -1
- package/dist/__tests__/presetLoader.test.js +0 -749
- package/dist/__tests__/presetLoader.test.js.map +0 -1
- package/dist/goal/goalLoop.d.ts +0 -78
- package/dist/goal/goalLoop.d.ts.map +0 -1
- package/dist/goal/goalLoop.js +0 -376
- package/dist/goal/goalLoop.js.map +0 -1
- package/dist/goal/goalPrompts.d.ts +0 -20
- package/dist/goal/goalPrompts.d.ts.map +0 -1
- package/dist/goal/goalPrompts.js +0 -54
- package/dist/goal/goalPrompts.js.map +0 -1
- package/dist/goal/types.d.ts +0 -98
- package/dist/goal/types.d.ts.map +0 -1
- package/dist/goal/types.js +0 -7
- package/dist/goal/types.js.map +0 -1
- package/dist/loadProfile.d.ts +0 -100
- package/dist/loadProfile.d.ts.map +0 -1
- package/dist/loadProfile.js +0 -221
- package/dist/loadProfile.js.map +0 -1
- package/dist/mining.d.ts +0 -155
- package/dist/mining.d.ts.map +0 -1
- package/dist/mining.js +0 -365
- package/dist/mining.js.map +0 -1
- package/dist/presetLoader.d.ts +0 -130
- package/dist/presetLoader.d.ts.map +0 -1
- package/dist/presetLoader.js +0 -734
- package/dist/presetLoader.js.map +0 -1
package/dist/goal/types.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Goal loop types — shared interfaces for the L3 autonomous goal execution loop.
|
|
3
|
-
*
|
|
4
|
-
* @module goal/types
|
|
5
|
-
*/
|
|
6
|
-
import type { NookplotRuntime } from "../index.js";
|
|
7
|
-
/**
|
|
8
|
-
* One action the LLM can return each turn of the goal loop.
|
|
9
|
-
* Parsed from the model's JSON response.
|
|
10
|
-
*/
|
|
11
|
-
export type GoalAction = {
|
|
12
|
-
type: "action";
|
|
13
|
-
actionName: string;
|
|
14
|
-
actionParams: Record<string, unknown>;
|
|
15
|
-
description: string;
|
|
16
|
-
} | {
|
|
17
|
-
type: "complete";
|
|
18
|
-
title: string;
|
|
19
|
-
body: string;
|
|
20
|
-
domain: string;
|
|
21
|
-
description: string;
|
|
22
|
-
} | {
|
|
23
|
-
type: "noop";
|
|
24
|
-
description: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: "needs_capability";
|
|
27
|
-
description: string;
|
|
28
|
-
suggestedPreset?: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Terminal state of a GoalLoop.run() invocation. Always one of the four
|
|
32
|
-
* outcomes — the loop never throws for normal termination conditions.
|
|
33
|
-
*/
|
|
34
|
-
export type GoalResult = {
|
|
35
|
-
outcome: "complete";
|
|
36
|
-
artifact: {
|
|
37
|
-
title: string;
|
|
38
|
-
body: string;
|
|
39
|
-
domain: string;
|
|
40
|
-
};
|
|
41
|
-
stepsExecuted: number;
|
|
42
|
-
spentNook: bigint;
|
|
43
|
-
} | {
|
|
44
|
-
outcome: "blocked_budget";
|
|
45
|
-
spentNook: bigint;
|
|
46
|
-
} | {
|
|
47
|
-
outcome: "blocked_stuck";
|
|
48
|
-
stuckReason: string;
|
|
49
|
-
spentNook: bigint;
|
|
50
|
-
} | {
|
|
51
|
-
outcome: "blocked_capability";
|
|
52
|
-
capabilityNeeded: string;
|
|
53
|
-
suggestedPreset?: string;
|
|
54
|
-
spentNook: bigint;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Configuration for a single run of the GoalLoop.
|
|
58
|
-
*/
|
|
59
|
-
export interface GoalLoopOptions {
|
|
60
|
-
runtime: NookplotRuntime;
|
|
61
|
-
goal: string;
|
|
62
|
-
/** Soft cap — loop continues past this but emits a warning. */
|
|
63
|
-
budgetNook: bigint;
|
|
64
|
-
parentSwarmId?: string | null;
|
|
65
|
-
/** Hard stop on step count. Default 20. */
|
|
66
|
-
maxSteps?: number;
|
|
67
|
-
/** Hard stop on consecutive no-op responses. Default 3. */
|
|
68
|
-
maxConsecutiveNoops?: number;
|
|
69
|
-
/** Hard stop on consecutive identical step descriptions. Default 3. */
|
|
70
|
-
maxReformulations?: number;
|
|
71
|
-
/** Optional verbose logging. */
|
|
72
|
-
verbose?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Optional LLM caller — defaults to runtime.economy.inference or a runtime
|
|
75
|
-
* provided by the consumer. The caller is abstracted because different
|
|
76
|
-
* environments wire inference differently (platform / BYOK / Ollama).
|
|
77
|
-
*/
|
|
78
|
-
inferenceCall?: (input: {
|
|
79
|
-
systemPrompt: string;
|
|
80
|
-
userPrompt: string;
|
|
81
|
-
maxTokens: number;
|
|
82
|
-
temperature: number;
|
|
83
|
-
}) => Promise<{
|
|
84
|
-
content: string;
|
|
85
|
-
costNook?: number;
|
|
86
|
-
}>;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Result of executing a single step within the goal loop.
|
|
90
|
-
* costNook is optional because many actions are free (off-chain tools).
|
|
91
|
-
*/
|
|
92
|
-
export interface StepExecutionResult {
|
|
93
|
-
ok: boolean;
|
|
94
|
-
output: string;
|
|
95
|
-
costNook: number;
|
|
96
|
-
error?: string;
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/goal/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/goal/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ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;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/goal/types.js
DELETED
package/dist/goal/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/goal/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/loadProfile.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Profile-aware credential loading for @nookplot/runtime.
|
|
3
|
-
*
|
|
4
|
-
* The SDK normally takes `{ apiKey, gatewayUrl }` at instantiation —
|
|
5
|
-
* developers pass keys directly. This helper is for developers who want
|
|
6
|
-
* the SDK to read from `~/.nookplot/` like @nookplot/cli and @nookplot/mcp
|
|
7
|
-
* do, so a user running multiple forged agents can point the SDK at
|
|
8
|
-
* whichever scope is active in their shell.
|
|
9
|
-
*
|
|
10
|
-
* Reads from the same files the rest of the Nookplot stack uses:
|
|
11
|
-
* ~/.nookplot/credentials.json ← creator API key (shared)
|
|
12
|
-
* ~/.nookplot/profiles/<name>/profile.json ← per-agent scope
|
|
13
|
-
* ~/.nookplot/active-profile ← sticky default (CLI-written)
|
|
14
|
-
*
|
|
15
|
-
* Resolution order:
|
|
16
|
-
* 1. Explicit `name` argument to loadProfile()
|
|
17
|
-
* 2. NOOKPLOT_PROFILE env var
|
|
18
|
-
* 3. Sticky default from ~/.nookplot/active-profile
|
|
19
|
-
* 4. null (load default creds only, no scope)
|
|
20
|
-
*
|
|
21
|
-
* @module loadProfile
|
|
22
|
-
*
|
|
23
|
-
* @example Basic usage — pick up whatever profile is active
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { NookplotRuntime } from "@nookplot/runtime";
|
|
26
|
-
* import { loadProfile } from "@nookplot/runtime/loadProfile";
|
|
27
|
-
*
|
|
28
|
-
* const creds = loadProfile(); // respects NOOKPLOT_PROFILE env + sticky default
|
|
29
|
-
* if (!creds) throw new Error("No credentials — run `nookplot register` first");
|
|
30
|
-
*
|
|
31
|
-
* const runtime = new NookplotRuntime({
|
|
32
|
-
* apiKey: creds.apiKey,
|
|
33
|
-
* gatewayUrl: creds.gatewayUrl,
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example Explicit profile override
|
|
38
|
-
* ```ts
|
|
39
|
-
* const creds = loadProfile("jeffs-researcher");
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @example Multi-agent — run two SDK instances in parallel
|
|
43
|
-
* ```ts
|
|
44
|
-
* const researcherCreds = loadProfile("jeffs-researcher");
|
|
45
|
-
* const writerCreds = loadProfile("jeffs-writer");
|
|
46
|
-
*
|
|
47
|
-
* const researcher = new NookplotRuntime({ apiKey: researcherCreds!.apiKey, ... });
|
|
48
|
-
* const writer = new NookplotRuntime({ apiKey: writerCreds!.apiKey, ... });
|
|
49
|
-
* // Both clients share the creator's API key but scope to different forged agents.
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export interface LoadedProfile {
|
|
53
|
-
/** Creator's API key (shared across all forged agents owned by this creator). */
|
|
54
|
-
apiKey: string;
|
|
55
|
-
/** Creator's wallet address. */
|
|
56
|
-
address: string;
|
|
57
|
-
/** Creator's private key — only read if developer passes { requirePrivateKey }. */
|
|
58
|
-
privateKey: string;
|
|
59
|
-
/** Gateway base URL, honoring NOOKPLOT_GATEWAY_URL env if set. */
|
|
60
|
-
gatewayUrl: string;
|
|
61
|
-
/** Present when a profile was active — the forged agent's address to scope to. */
|
|
62
|
-
scopedAgentAddress?: string;
|
|
63
|
-
/** Present when a profile was active — the profile's name (for logging). */
|
|
64
|
-
profileName?: string;
|
|
65
|
-
/** Display name of the creator (not the scoped forged agent). */
|
|
66
|
-
displayName?: string;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Resolve the active profile name in priority order.
|
|
70
|
-
* Exported for testing + for developers who want to see which profile
|
|
71
|
-
* WOULD be used without actually loading credentials.
|
|
72
|
-
*/
|
|
73
|
-
export declare function resolveActiveProfileName(explicitName?: string): string | null;
|
|
74
|
-
/**
|
|
75
|
-
* Load credentials, optionally merging a named profile's scope on top.
|
|
76
|
-
*
|
|
77
|
-
* Returns null if no `credentials.json` exists — the developer should
|
|
78
|
-
* surface a clear "run `nookplot register` first" message in that case.
|
|
79
|
-
*
|
|
80
|
-
* Does not throw on invalid profiles — if the named profile doesn't
|
|
81
|
-
* exist or is malformed, falls back to plain creator-direct credentials
|
|
82
|
-
* (matches @nookplot/mcp's fail-open behavior so stale env vars don't
|
|
83
|
-
* break unrelated commands).
|
|
84
|
-
*/
|
|
85
|
-
export declare function loadProfile(name?: string): LoadedProfile | null;
|
|
86
|
-
/**
|
|
87
|
-
* List all profiles registered on the local machine. Each entry includes
|
|
88
|
-
* the profile name + its metadata. Useful for SDK consumers who want to
|
|
89
|
-
* enumerate the user's forged agents programmatically.
|
|
90
|
-
*
|
|
91
|
-
* Returns an empty array if ~/.nookplot/profiles doesn't exist. Never
|
|
92
|
-
* throws — invalid profiles are silently skipped.
|
|
93
|
-
*/
|
|
94
|
-
export declare function listProfiles(): Array<{
|
|
95
|
-
name: string;
|
|
96
|
-
scopedAgentAddress: string;
|
|
97
|
-
displayName?: string;
|
|
98
|
-
hermesProfile?: string;
|
|
99
|
-
}>;
|
|
100
|
-
//# sourceMappingURL=loadProfile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadProfile.d.ts","sourceRoot":"","sources":["../src/loadProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAMH,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAsBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa7E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAwE/D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8BhI"}
|
package/dist/loadProfile.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Profile-aware credential loading for @nookplot/runtime.
|
|
3
|
-
*
|
|
4
|
-
* The SDK normally takes `{ apiKey, gatewayUrl }` at instantiation —
|
|
5
|
-
* developers pass keys directly. This helper is for developers who want
|
|
6
|
-
* the SDK to read from `~/.nookplot/` like @nookplot/cli and @nookplot/mcp
|
|
7
|
-
* do, so a user running multiple forged agents can point the SDK at
|
|
8
|
-
* whichever scope is active in their shell.
|
|
9
|
-
*
|
|
10
|
-
* Reads from the same files the rest of the Nookplot stack uses:
|
|
11
|
-
* ~/.nookplot/credentials.json ← creator API key (shared)
|
|
12
|
-
* ~/.nookplot/profiles/<name>/profile.json ← per-agent scope
|
|
13
|
-
* ~/.nookplot/active-profile ← sticky default (CLI-written)
|
|
14
|
-
*
|
|
15
|
-
* Resolution order:
|
|
16
|
-
* 1. Explicit `name` argument to loadProfile()
|
|
17
|
-
* 2. NOOKPLOT_PROFILE env var
|
|
18
|
-
* 3. Sticky default from ~/.nookplot/active-profile
|
|
19
|
-
* 4. null (load default creds only, no scope)
|
|
20
|
-
*
|
|
21
|
-
* @module loadProfile
|
|
22
|
-
*
|
|
23
|
-
* @example Basic usage — pick up whatever profile is active
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { NookplotRuntime } from "@nookplot/runtime";
|
|
26
|
-
* import { loadProfile } from "@nookplot/runtime/loadProfile";
|
|
27
|
-
*
|
|
28
|
-
* const creds = loadProfile(); // respects NOOKPLOT_PROFILE env + sticky default
|
|
29
|
-
* if (!creds) throw new Error("No credentials — run `nookplot register` first");
|
|
30
|
-
*
|
|
31
|
-
* const runtime = new NookplotRuntime({
|
|
32
|
-
* apiKey: creds.apiKey,
|
|
33
|
-
* gatewayUrl: creds.gatewayUrl,
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example Explicit profile override
|
|
38
|
-
* ```ts
|
|
39
|
-
* const creds = loadProfile("jeffs-researcher");
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @example Multi-agent — run two SDK instances in parallel
|
|
43
|
-
* ```ts
|
|
44
|
-
* const researcherCreds = loadProfile("jeffs-researcher");
|
|
45
|
-
* const writerCreds = loadProfile("jeffs-writer");
|
|
46
|
-
*
|
|
47
|
-
* const researcher = new NookplotRuntime({ apiKey: researcherCreds!.apiKey, ... });
|
|
48
|
-
* const writer = new NookplotRuntime({ apiKey: writerCreds!.apiKey, ... });
|
|
49
|
-
* // Both clients share the creator's API key but scope to different forged agents.
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
53
|
-
import { homedir } from "node:os";
|
|
54
|
-
import { join } from "node:path";
|
|
55
|
-
function nookplotDir() {
|
|
56
|
-
return join(homedir(), ".nookplot");
|
|
57
|
-
}
|
|
58
|
-
function credentialsPath() {
|
|
59
|
-
return join(nookplotDir(), "credentials.json");
|
|
60
|
-
}
|
|
61
|
-
function profilePath(name) {
|
|
62
|
-
return join(nookplotDir(), "profiles", name, "profile.json");
|
|
63
|
-
}
|
|
64
|
-
function activeProfilePath() {
|
|
65
|
-
return join(nookplotDir(), "active-profile");
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Resolve the active profile name in priority order.
|
|
69
|
-
* Exported for testing + for developers who want to see which profile
|
|
70
|
-
* WOULD be used without actually loading credentials.
|
|
71
|
-
*/
|
|
72
|
-
export function resolveActiveProfileName(explicitName) {
|
|
73
|
-
if (explicitName)
|
|
74
|
-
return explicitName;
|
|
75
|
-
const env = process.env.NOOKPLOT_PROFILE;
|
|
76
|
-
if (env)
|
|
77
|
-
return env;
|
|
78
|
-
try {
|
|
79
|
-
if (existsSync(activeProfilePath())) {
|
|
80
|
-
const content = readFileSync(activeProfilePath(), "utf-8").trim();
|
|
81
|
-
if (content)
|
|
82
|
-
return content;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
// Permissions error or disk issue — fall through
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Load credentials, optionally merging a named profile's scope on top.
|
|
92
|
-
*
|
|
93
|
-
* Returns null if no `credentials.json` exists — the developer should
|
|
94
|
-
* surface a clear "run `nookplot register` first" message in that case.
|
|
95
|
-
*
|
|
96
|
-
* Does not throw on invalid profiles — if the named profile doesn't
|
|
97
|
-
* exist or is malformed, falls back to plain creator-direct credentials
|
|
98
|
-
* (matches @nookplot/mcp's fail-open behavior so stale env vars don't
|
|
99
|
-
* break unrelated commands).
|
|
100
|
-
*/
|
|
101
|
-
export function loadProfile(name) {
|
|
102
|
-
// 1. Load base credentials — the shared creator API key.
|
|
103
|
-
if (!existsSync(credentialsPath()))
|
|
104
|
-
return null;
|
|
105
|
-
let creds;
|
|
106
|
-
try {
|
|
107
|
-
creds = JSON.parse(readFileSync(credentialsPath(), "utf-8"));
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (!creds.apiKey || !creds.address || !creds.privateKey || !creds.gatewayUrl) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
// 2. Honor NOOKPLOT_GATEWAY_URL env if set (matches SDK + MCP convention).
|
|
116
|
-
const gatewayUrl = process.env.NOOKPLOT_GATEWAY_URL ?? creds.gatewayUrl;
|
|
117
|
-
// 3. Resolve profile (if any) and read its scope.
|
|
118
|
-
const profileName = resolveActiveProfileName(name);
|
|
119
|
-
if (!profileName) {
|
|
120
|
-
return {
|
|
121
|
-
apiKey: creds.apiKey,
|
|
122
|
-
address: creds.address,
|
|
123
|
-
privateKey: creds.privateKey,
|
|
124
|
-
gatewayUrl,
|
|
125
|
-
displayName: creds.displayName,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
const pPath = profilePath(profileName);
|
|
129
|
-
if (!existsSync(pPath)) {
|
|
130
|
-
// Stale profile reference — fall back to creator-direct. Matches
|
|
131
|
-
// @nookplot/mcp's fail-open pattern.
|
|
132
|
-
return {
|
|
133
|
-
apiKey: creds.apiKey,
|
|
134
|
-
address: creds.address,
|
|
135
|
-
privateKey: creds.privateKey,
|
|
136
|
-
gatewayUrl,
|
|
137
|
-
displayName: creds.displayName,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
try {
|
|
141
|
-
const p = JSON.parse(readFileSync(pPath, "utf-8"));
|
|
142
|
-
if (typeof p.scopedAgentAddress !== "string" || p.scopedAgentAddress.length === 0) {
|
|
143
|
-
// Malformed profile — fall back.
|
|
144
|
-
return {
|
|
145
|
-
apiKey: creds.apiKey,
|
|
146
|
-
address: creds.address,
|
|
147
|
-
privateKey: creds.privateKey,
|
|
148
|
-
gatewayUrl,
|
|
149
|
-
displayName: creds.displayName,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
apiKey: creds.apiKey,
|
|
154
|
-
address: creds.address,
|
|
155
|
-
privateKey: creds.privateKey,
|
|
156
|
-
gatewayUrl,
|
|
157
|
-
scopedAgentAddress: p.scopedAgentAddress,
|
|
158
|
-
profileName,
|
|
159
|
-
displayName: creds.displayName,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
// JSON parse error on profile — fall back to creator-direct.
|
|
164
|
-
return {
|
|
165
|
-
apiKey: creds.apiKey,
|
|
166
|
-
address: creds.address,
|
|
167
|
-
privateKey: creds.privateKey,
|
|
168
|
-
gatewayUrl,
|
|
169
|
-
displayName: creds.displayName,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* List all profiles registered on the local machine. Each entry includes
|
|
175
|
-
* the profile name + its metadata. Useful for SDK consumers who want to
|
|
176
|
-
* enumerate the user's forged agents programmatically.
|
|
177
|
-
*
|
|
178
|
-
* Returns an empty array if ~/.nookplot/profiles doesn't exist. Never
|
|
179
|
-
* throws — invalid profiles are silently skipped.
|
|
180
|
-
*/
|
|
181
|
-
export function listProfiles() {
|
|
182
|
-
const dir = join(nookplotDir(), "profiles");
|
|
183
|
-
if (!existsSync(dir))
|
|
184
|
-
return [];
|
|
185
|
-
const out = [];
|
|
186
|
-
try {
|
|
187
|
-
const { readdirSync, statSync } = require("node:fs");
|
|
188
|
-
for (const name of readdirSync(dir).sort()) {
|
|
189
|
-
const full = join(dir, name);
|
|
190
|
-
try {
|
|
191
|
-
if (!statSync(full).isDirectory())
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
const pPath = join(full, "profile.json");
|
|
198
|
-
if (!existsSync(pPath))
|
|
199
|
-
continue;
|
|
200
|
-
try {
|
|
201
|
-
const p = JSON.parse(readFileSync(pPath, "utf-8"));
|
|
202
|
-
if (typeof p.scopedAgentAddress !== "string")
|
|
203
|
-
continue;
|
|
204
|
-
out.push({
|
|
205
|
-
name,
|
|
206
|
-
scopedAgentAddress: p.scopedAgentAddress,
|
|
207
|
-
displayName: p.displayName,
|
|
208
|
-
hermesProfile: p.hermesProfile,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
// Skip invalid profiles
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
catch {
|
|
217
|
-
// Missing dir or perms — return empty
|
|
218
|
-
}
|
|
219
|
-
return out;
|
|
220
|
-
}
|
|
221
|
-
//# sourceMappingURL=loadProfile.js.map
|
package/dist/loadProfile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadProfile.js","sourceRoot":"","sources":["../src/loadProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmBjC,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AACtC,CAAC;AACD,SAAS,eAAe;IACtB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACjD,CAAC;AACD,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AAC/D,CAAC;AACD,SAAS,iBAAiB;IACxB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,gBAAgB,CAAC,CAAC;AAC/C,CAAC;AASD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAA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AAE,CAAC,CAAC,aAAa;iBAC/B,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/mining.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified mining loop for the Nookplot Agent Runtime SDK.
|
|
3
|
-
*
|
|
4
|
-
* Surfaces a single `np.mining.start()` API that handles the full
|
|
5
|
-
* "discover → rank → solve → submit" cycle across all enabled tracks
|
|
6
|
-
* (knowledge, embedding, RLM). Per-track solver dispatch is private
|
|
7
|
-
* here — solver implementations call out to the gateway via
|
|
8
|
-
* `connection.request()` and the user's existing inference setup
|
|
9
|
-
* (BYOK / local Ollama / gateway-credit-based inference).
|
|
10
|
-
*
|
|
11
|
-
* Usage from the CLI's `nookplot mine` command:
|
|
12
|
-
* const session = await runtime.mining.start({
|
|
13
|
-
* tracks: ["knowledge", "embedding", "rlm"],
|
|
14
|
-
* maxCredits: 5000,
|
|
15
|
-
* once: false,
|
|
16
|
-
* });
|
|
17
|
-
* await session.until(() => process.signals.interrupted);
|
|
18
|
-
* await session.stop();
|
|
19
|
-
*
|
|
20
|
-
* Same surface from the `mining_opportunity` autonomous handler:
|
|
21
|
-
* await runtime.mining.runOnce({ tracks: ["knowledge"] });
|
|
22
|
-
*
|
|
23
|
-
* @module mining
|
|
24
|
-
*/
|
|
25
|
-
import type { ConnectionManager } from "./connection.js";
|
|
26
|
-
import type { EconomyManager } from "./economy.js";
|
|
27
|
-
export type MiningTrack = "knowledge" | "embedding" | "rlm" | "gradient";
|
|
28
|
-
/**
|
|
29
|
-
* Options shared by every mining entry point — the per-tick concerns that
|
|
30
|
-
* apply to both single-shot (`runOnce`) and long-running (`start`) modes.
|
|
31
|
-
*/
|
|
32
|
-
export interface MiningTickOptions {
|
|
33
|
-
/** Tracks to mine. `'auto'` queries the gateway for tracks with open challenges. */
|
|
34
|
-
tracks?: MiningTrack[] | "auto";
|
|
35
|
-
/** Optional guild to attribute submissions to (for guild-tier reward boost). */
|
|
36
|
-
guildId?: string;
|
|
37
|
-
/** Log decisions but don't submit. Default false. */
|
|
38
|
-
dryRun?: boolean;
|
|
39
|
-
/** Print scoring math for each ranked challenge. Default false. */
|
|
40
|
-
explain?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* User-supplied embedding generator. Required for the embedding track —
|
|
43
|
-
* the runtime intentionally does not bundle an Ollama client because that
|
|
44
|
-
* is a CLI concern. If absent, the embedding track is skipped with a clear
|
|
45
|
-
* "no embedding generator provided" status.
|
|
46
|
-
*/
|
|
47
|
-
generateEmbeddings?: (prompts: string[], dimensions: number) => Promise<number[][]>;
|
|
48
|
-
/**
|
|
49
|
-
* Override the default knowledge solver. Receives the challenge object,
|
|
50
|
-
* returns the trace text. Defaults to a single inference call seeded with
|
|
51
|
-
* the challenge title + description.
|
|
52
|
-
*/
|
|
53
|
-
solveKnowledge?: (challenge: ChallengeSummary, economy: EconomyManager) => Promise<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Override the default RLM solver. Default is a no-op stub that records
|
|
56
|
-
* "deferred" — full RLM autosolve is gated on a future phase. Custom
|
|
57
|
-
* solvers can drive the REPL via `runtime.connection.request()`.
|
|
58
|
-
*/
|
|
59
|
-
solveRlm?: (challenge: ChallengeSummary, economy: EconomyManager) => Promise<TrackResult>;
|
|
60
|
-
/** Optional verbose logger. Defaults to no-op. */
|
|
61
|
-
log?: (msg: string) => void;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Options for the long-running loop mode (`start`). Adds budget caps and
|
|
65
|
-
* tick scheduling that don't apply to single-shot dispatch.
|
|
66
|
-
*/
|
|
67
|
-
export interface MiningStartOptions extends MiningTickOptions {
|
|
68
|
-
/** Total credit budget for this session across all RLM sub-calls. Defaults to 5000. */
|
|
69
|
-
maxCredits?: number;
|
|
70
|
-
/** Solve all currently-open challenges, then exit. Default false. */
|
|
71
|
-
once?: boolean;
|
|
72
|
-
/** Tick interval in milliseconds. Default 60_000. */
|
|
73
|
-
tickIntervalMs?: number;
|
|
74
|
-
}
|
|
75
|
-
export interface ChallengeSummary {
|
|
76
|
-
id: string;
|
|
77
|
-
track: MiningTrack;
|
|
78
|
-
title: string;
|
|
79
|
-
description?: string;
|
|
80
|
-
difficulty: "easy" | "medium" | "hard" | "expert";
|
|
81
|
-
estimatedRewardNook: number;
|
|
82
|
-
domainTags: string[];
|
|
83
|
-
sourceType: string;
|
|
84
|
-
closesAt: string;
|
|
85
|
-
/** Filled after rank() with the challenge's composite score. */
|
|
86
|
-
rankScore?: number;
|
|
87
|
-
}
|
|
88
|
-
export interface TrackResult {
|
|
89
|
-
track: MiningTrack;
|
|
90
|
-
challengeId: string;
|
|
91
|
-
status: "submitted" | "skipped" | "error";
|
|
92
|
-
reason?: string;
|
|
93
|
-
submissionId?: string;
|
|
94
|
-
estimatedRewardNook?: number;
|
|
95
|
-
}
|
|
96
|
-
export interface MiningStats {
|
|
97
|
-
ticks: number;
|
|
98
|
-
attempted: number;
|
|
99
|
-
submitted: number;
|
|
100
|
-
/** Solver chose not to submit (no prompts, trace too short, no callback, etc.). */
|
|
101
|
-
skipped: number;
|
|
102
|
-
/** Suppressed submissions because of `dryRun: true`. Counted separately so
|
|
103
|
-
* the end-of-session banner can distinguish a dry-run from real skips. */
|
|
104
|
-
dryRun: number;
|
|
105
|
-
errors: number;
|
|
106
|
-
creditsSpent: number;
|
|
107
|
-
byTrack: Record<MiningTrack, {
|
|
108
|
-
attempted: number;
|
|
109
|
-
submitted: number;
|
|
110
|
-
errors: number;
|
|
111
|
-
}>;
|
|
112
|
-
}
|
|
113
|
-
export interface MiningSession {
|
|
114
|
-
/** Resolves when the session has stopped (either via `stop()` or `once: true` completion). */
|
|
115
|
-
done: Promise<void>;
|
|
116
|
-
/** Request graceful shutdown. Idempotent. */
|
|
117
|
-
stop(): Promise<void>;
|
|
118
|
-
/** Snapshot of running stats. */
|
|
119
|
-
stats(): MiningStats;
|
|
120
|
-
}
|
|
121
|
-
export declare function trackOf(sourceType: string): MiningTrack;
|
|
122
|
-
export declare class MiningManager {
|
|
123
|
-
private readonly connection;
|
|
124
|
-
private readonly economy;
|
|
125
|
-
private activeSession;
|
|
126
|
-
constructor(connection: ConnectionManager, economy: EconomyManager);
|
|
127
|
-
/**
|
|
128
|
-
* Start a long-running mining session. Returns immediately; the loop runs
|
|
129
|
-
* in the background until `session.stop()` or `once: true` completion.
|
|
130
|
-
*/
|
|
131
|
-
start(opts?: MiningStartOptions): Promise<MiningSession>;
|
|
132
|
-
/**
|
|
133
|
-
* Run one tick (discover → rank → solve top → submit) and return the
|
|
134
|
-
* results. Suitable for `mining_opportunity` autonomous-handler dispatch.
|
|
135
|
-
* Loop-only options (`maxCredits`, `tickIntervalMs`, `once`) are not
|
|
136
|
-
* accepted here — they're meaningless for a single-shot call.
|
|
137
|
-
*/
|
|
138
|
-
runOnce(opts?: MiningTickOptions): Promise<TrackResult[]>;
|
|
139
|
-
/** Snapshot stats from the active session, if any. */
|
|
140
|
-
stats(): MiningStats | null;
|
|
141
|
-
private makeSession;
|
|
142
|
-
private tick;
|
|
143
|
-
private resolveTracks;
|
|
144
|
-
private discoverAcross;
|
|
145
|
-
private discoverKnowledge;
|
|
146
|
-
private discoverEmbedding;
|
|
147
|
-
private discoverRlm;
|
|
148
|
-
private toSummary;
|
|
149
|
-
private solveOne;
|
|
150
|
-
private solveKnowledgeChallenge;
|
|
151
|
-
private defaultKnowledgeSolver;
|
|
152
|
-
private solveEmbeddingChallenge;
|
|
153
|
-
private solveRlmChallenge;
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=mining.d.ts.map
|
package/dist/mining.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mining.d.ts","sourceRoot":"","sources":["../src/mining.ts"],"names":[],"m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