@ainize/core 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 +21 -0
- package/README.md +20 -0
- package/dist/ain-ledger.d.ts +191 -0
- package/dist/ain-ledger.d.ts.map +1 -0
- package/dist/ain-ledger.js +714 -0
- package/dist/ain-ledger.js.map +1 -0
- package/dist/browser.d.ts +15 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +16 -0
- package/dist/browser.js.map +1 -0
- package/dist/bytes.d.ts +3 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +14 -0
- package/dist/bytes.js.map +1 -0
- package/dist/canonical.d.ts +5 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +70 -0
- package/dist/canonical.js.map +1 -0
- package/dist/catalog.d.ts +181 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +496 -0
- package/dist/catalog.js.map +1 -0
- package/dist/config-schema.d.ts +222 -0
- package/dist/config-schema.d.ts.map +1 -0
- package/dist/config-schema.js +302 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +128 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +330 -0
- package/dist/config.js.map +1 -0
- package/dist/events.d.ts +14 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +20 -0
- package/dist/events.js.map +1 -0
- package/dist/identity.d.ts +15 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +59 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +134 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +2 -0
- package/dist/ledger.js.map +1 -0
- package/dist/lineage.d.ts +63 -0
- package/dist/lineage.d.ts.map +1 -0
- package/dist/lineage.js +156 -0
- package/dist/lineage.js.map +1 -0
- package/dist/local-ledger.d.ts +74 -0
- package/dist/local-ledger.d.ts.map +1 -0
- package/dist/local-ledger.js +229 -0
- package/dist/local-ledger.js.map +1 -0
- package/dist/npz.d.ts +107 -0
- package/dist/npz.d.ts.map +1 -0
- package/dist/npz.js +502 -0
- package/dist/npz.js.map +1 -0
- package/dist/ops.d.ts +65 -0
- package/dist/ops.d.ts.map +1 -0
- package/dist/ops.js +9 -0
- package/dist/ops.js.map +1 -0
- package/dist/teach-auth.d.ts +19 -0
- package/dist/teach-auth.d.ts.map +1 -0
- package/dist/teach-auth.js +33 -0
- package/dist/teach-auth.js.map +1 -0
- package/dist/types.d.ts +1096 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +98 -0
- package/dist/types.js.map +1 -0
- package/dist/x402.d.ts +35 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +84 -0
- package/dist/x402.js.map +1 -0
- package/package.json +49 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { NodeConfig, NodeRole, TeachConfig, TeachEffort } from './types.js';
|
|
2
|
+
export declare const VERSION = "0.1.0";
|
|
3
|
+
export declare function buildStamp(): string | undefined;
|
|
4
|
+
export declare const DEFAULT_HOME: string;
|
|
5
|
+
export declare function configPath(home?: string): string;
|
|
6
|
+
export interface InitOptions {
|
|
7
|
+
home?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
port?: number;
|
|
10
|
+
host?: string;
|
|
11
|
+
roles?: NodeRole[];
|
|
12
|
+
peers?: string[];
|
|
13
|
+
ledger?: 'local' | 'ain';
|
|
14
|
+
ainProviderUrl?: string;
|
|
15
|
+
ainEventUrl?: string | null;
|
|
16
|
+
ainChainId?: number;
|
|
17
|
+
privateKey?: string;
|
|
18
|
+
runtimeRepo?: string;
|
|
19
|
+
runtimeApi?: string;
|
|
20
|
+
runtimePatchDir?: string;
|
|
21
|
+
currency?: 'AIN' | 'CREDIT';
|
|
22
|
+
publicUrl?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Twelve fixed locality prompts (prose / code / digits / general knowledge). Greedy answers must stay identical on ≥ minSame. */
|
|
25
|
+
export declare const DEFAULT_LOCALITY_PROMPTS: string[];
|
|
26
|
+
/** Teach-mode defaults (spec §7.4): disabled, review-before-publish, gradient trainer in the `flashtrain` container. */
|
|
27
|
+
export declare const DEFAULT_TEACH_CONFIG: TeachConfig;
|
|
28
|
+
/**
|
|
29
|
+
* What a verifier will spend on unpaid work for strangers (items 332 / 333 / 336). Every one of these was
|
|
30
|
+
* unbounded: the round verified hidden test listings, held the shared model in front of the node's own visitors,
|
|
31
|
+
* and kept every body it ever downloaded.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_VERIFIER_BUDGET: {
|
|
34
|
+
/**
|
|
35
|
+
* Stop attesting below this balance where the chain charges gas (item 341). An attestation is a write the VERIFIER
|
|
36
|
+
* signs and pays for — the plan's "seller pays gas" cannot hold for a record the verifier signs — so the unpaid
|
|
37
|
+
* role becomes a net-paying one the moment gas is real, and `verifier.auto` would spend the account to nothing,
|
|
38
|
+
* taking announce, settle and payout with it. No effect on the local ledger, which has no gas.
|
|
39
|
+
*/
|
|
40
|
+
readonly minBalance: 1;
|
|
41
|
+
readonly includeTest: false;
|
|
42
|
+
readonly minPrice: "0";
|
|
43
|
+
readonly maxPerHour: 40;
|
|
44
|
+
readonly maxModelMinutesPerHour: 10;
|
|
45
|
+
readonly window: null;
|
|
46
|
+
readonly retainBodies: false;
|
|
47
|
+
};
|
|
48
|
+
/** `cfg.verifier` with the budget defaults filled in (a config.json written before they existed has none of them). */
|
|
49
|
+
export declare function verifierConfig(cfg: Pick<NodeConfig, 'verifier'>): NonNullable<NodeConfig['verifier']>;
|
|
50
|
+
/** Operator ceiling for `dataset.maxBytes` — a node may not accept an upload larger than this whatever the config says. */
|
|
51
|
+
export declare const DATASET_MAX_BYTES_CEILING = 20000000;
|
|
52
|
+
/** Effective teach config: `cfg.teach` merged over the defaults (older config.json files have no `teach` block). */
|
|
53
|
+
export declare function teachConfig(cfg: Pick<NodeConfig, 'teach'>): TeachConfig;
|
|
54
|
+
/** One measured lesson, as `teach_stats` records it (design §6.5). Only `backend: 'gradient'` rows may drive a visitor-facing number. */
|
|
55
|
+
export interface TeachTimingSample {
|
|
56
|
+
total_s: number;
|
|
57
|
+
load_s: number | null;
|
|
58
|
+
steps: number | null;
|
|
59
|
+
rows_trained: number | null;
|
|
60
|
+
sentences: number | null;
|
|
61
|
+
}
|
|
62
|
+
/** How many questions per lesson, and whether the number was measured (design §D1). */
|
|
63
|
+
export interface RowsPerJobResult {
|
|
64
|
+
rows: number;
|
|
65
|
+
source: 'default' | 'measured' | 'operator';
|
|
66
|
+
/** p50 seconds per question per pass, gradient samples only; null until the fit exists. */
|
|
67
|
+
s_per_row_p50: number | null;
|
|
68
|
+
s_per_row_p90: number | null;
|
|
69
|
+
load_s_p50: number | null;
|
|
70
|
+
samples: number;
|
|
71
|
+
}
|
|
72
|
+
export declare const ETA_MIN_SAMPLES = 3;
|
|
73
|
+
export declare function percentileOf(xs: number[], p: number): number | null;
|
|
74
|
+
/**
|
|
75
|
+
* How many questions one lesson may train on this node (design §D1).
|
|
76
|
+
*
|
|
77
|
+
* s_per_row_p90 = p90( (total_s − load_s) / (rows_trained × steps) ) over gradient samples only
|
|
78
|
+
* max_rows = floor( (timeoutMs/1000 − load_s_p90) / (passes × s_per_row_p90) / safetyFactor )
|
|
79
|
+
* rowsPerJob = clamp(floor, max_rows, ceiling)
|
|
80
|
+
*
|
|
81
|
+
* The whole derivation is skipped — the floor is used — while fewer than `ETA_MIN_SAMPLES` gradient samples exist, or
|
|
82
|
+
* while the trainer has not shown that it supports sampled evaluation (design §16: an unsampled eval at 100 questions
|
|
83
|
+
* would spend more time probing than training). An operator override disables the derivation entirely.
|
|
84
|
+
*/
|
|
85
|
+
export declare function deriveRowsPerJob(cfg: TeachConfig, samples: TeachTimingSample[], opts?: {
|
|
86
|
+
effort?: TeachEffort;
|
|
87
|
+
override?: number | null;
|
|
88
|
+
trainerSupportsSampling?: boolean;
|
|
89
|
+
}): RowsPerJobResult;
|
|
90
|
+
/** `"4,5"` / `"0,1,2,3"` → a set of GPU indices; anything unparseable is simply not in the set. */
|
|
91
|
+
export declare function gpuSet(spec: string | undefined | null): Set<string>;
|
|
92
|
+
/**
|
|
93
|
+
* The GPUs `teach.trainer.gpus` and `runtime.gpus` have in common (item 145).
|
|
94
|
+
*
|
|
95
|
+
* deploy/README states the rule — "never let the two sets overlap: the trainer loads a second copy of the model's
|
|
96
|
+
* memory table and would starve vLLM" — and nothing in the code checked it. The shipped default named the very GPUs
|
|
97
|
+
* the shipped cluster serves on, and the README then invited the operator to switch gradient training on.
|
|
98
|
+
*/
|
|
99
|
+
export declare function gpuOverlap(servingGpus: string | undefined | null, trainerGpus: string | undefined | null): string[];
|
|
100
|
+
/** How long raw `events` rows are kept when the operator has not said otherwise (item 128). */
|
|
101
|
+
export declare const DEFAULT_EVENTS_RETENTION_DAYS = 90;
|
|
102
|
+
/**
|
|
103
|
+
* What a fresh node accepts from peer exchange (items 136/137). Discovery stays ON — a marketplace whose nodes only
|
|
104
|
+
* ever talk to a hand-written list is not a network — but it is now bounded, marked and reversible: learned peers
|
|
105
|
+
* are labelled `learned` in `ainize peers ls`, capped at `maxPeers`, dropped when they stop answering, and an
|
|
106
|
+
* endpoint the operator removes stays removed until they add it back.
|
|
107
|
+
*/
|
|
108
|
+
export declare const DEFAULT_P2P_CONFIG: {
|
|
109
|
+
acceptExchange: boolean;
|
|
110
|
+
maxPeers: number;
|
|
111
|
+
evictAfterFailures: number;
|
|
112
|
+
staleDays: number;
|
|
113
|
+
};
|
|
114
|
+
export declare function defaultConfig(opts?: InitOptions): NodeConfig;
|
|
115
|
+
export declare function loadConfig(home?: string): NodeConfig | null;
|
|
116
|
+
export declare function saveConfig(cfg: NodeConfig, home?: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Fold the changes a running node made to its own config (`boot` → `live`: the operator password, a peer added or
|
|
119
|
+
* removed in the console, a display name) onto whatever is on disk NOW, instead of writing the node's whole
|
|
120
|
+
* start-up snapshot over it. Without this, one click in the console silently reverted every `ainize config set`
|
|
121
|
+
* made since the node started (item 124).
|
|
122
|
+
*/
|
|
123
|
+
export declare function mergeConfigChanges(onDisk: NodeConfig, boot: NodeConfig, live: NodeConfig): NodeConfig;
|
|
124
|
+
/** Environment overrides (handy for docker / multi-node demos). */
|
|
125
|
+
export declare function applyEnv(cfg: NodeConfig, env?: NodeJS.ProcessEnv): NodeConfig;
|
|
126
|
+
/** `AINIZE_TRUST_PROXY`: `0|false` → off, `1|2|…` → hop count, `true` → every proxy (only behind a proxy that overwrites X-Forwarded-For), anything else → Express IP/CIDR/`loopback` list. */
|
|
127
|
+
export declare function parseTrustProxy(v: string): boolean | number | string;
|
|
128
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjF,eAAO,MAAM,OAAO,UAAU,CAAC;AAa/B,wBAAgB,UAAU,IAAI,MAAM,GAAG,SAAS,CAAwB;AACxE,eAAO,MAAM,YAAY,QAAwD,CAAC;AAElF,wBAAgB,UAAU,CAAC,IAAI,SAAe,GAAG,MAAM,CAEtD;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACzB,cAAc,C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kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAkBrG;AAED,mEAAmE;AACnE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAc,GAAG,UAAU,CAgBvE;AAED,+LAA+L;AAC/L,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAMpE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { createIdentity, identityFromPrivateKey } from './identity.js';
|
|
6
|
+
import { NETWORK_MIN_ROYALTY_SHARE, NETWORK_MIN_VERIFIER_SHARE } from './types.js';
|
|
7
|
+
export const VERSION = '0.1.0';
|
|
8
|
+
/**
|
|
9
|
+
* When the running code was last built. Measured — the mtime of this very module — never a string frozen into a
|
|
10
|
+
* config file: after an upgrade `version` alone (unchanged for a year) cannot tell two builds apart (item 141).
|
|
11
|
+
*
|
|
12
|
+
* Measured ONCE, when the module is loaded: the file is read then, so that is the code this process runs. A
|
|
13
|
+
* `npm run build` under a running node replaces the file on disk but not the code in memory — stat'ing it again
|
|
14
|
+
* on every call made a node started at 09:04 report the 11:36 build it had never loaded.
|
|
15
|
+
*/
|
|
16
|
+
const BUILD_STAMP = (() => {
|
|
17
|
+
try {
|
|
18
|
+
return statSync(fileURLToPath(import.meta.url)).mtime.toISOString();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
24
|
+
export function buildStamp() { return BUILD_STAMP; }
|
|
25
|
+
export const DEFAULT_HOME = process.env.AINIZE_HOME ?? join(homedir(), '.ainize');
|
|
26
|
+
export function configPath(home = DEFAULT_HOME) {
|
|
27
|
+
return join(home, 'config.json');
|
|
28
|
+
}
|
|
29
|
+
/** Twelve fixed locality prompts (prose / code / digits / general knowledge). Greedy answers must stay identical on ≥ minSame. */
|
|
30
|
+
export const DEFAULT_LOCALITY_PROMPTS = [
|
|
31
|
+
'What is the capital of France?',
|
|
32
|
+
'Write one sentence about the ocean.',
|
|
33
|
+
'Translate "good morning" into Spanish.',
|
|
34
|
+
'What is 17 + 25?',
|
|
35
|
+
'Name three primary colors.',
|
|
36
|
+
'Write a Python function that returns the square of a number.',
|
|
37
|
+
'What year did the first human land on the Moon?',
|
|
38
|
+
'Summarize the water cycle in one sentence.',
|
|
39
|
+
'What is the chemical symbol for gold?',
|
|
40
|
+
'List the days of the week.',
|
|
41
|
+
'대한민국의 수도는 어디입니까?',
|
|
42
|
+
'1부터 10까지 더하면 얼마입니까?',
|
|
43
|
+
];
|
|
44
|
+
/** Teach-mode defaults (spec §7.4): disabled, review-before-publish, gradient trainer in the `flashtrain` container. */
|
|
45
|
+
export const DEFAULT_TEACH_CONFIG = {
|
|
46
|
+
enabled: false,
|
|
47
|
+
publish: 'review',
|
|
48
|
+
factsPerJob: 8,
|
|
49
|
+
jobsPerKeyPerDay: 3,
|
|
50
|
+
jobsPerIpPerDay: 5,
|
|
51
|
+
queueMax: 10,
|
|
52
|
+
contributorShare: 0.7,
|
|
53
|
+
draftTtlDays: 7,
|
|
54
|
+
backend: 'gradient',
|
|
55
|
+
stubOffline: false,
|
|
56
|
+
// `gpus` is deliberately UNSET (item 145). It used to ship as '4,5,6' — a claim about one host that was wrong for
|
|
57
|
+
// the cluster this repo ships, which serves the model on GPUs 4,5: the trainer's own free-memory pre-check then
|
|
58
|
+
// watched the GPUs vLLM was holding and blocked every lesson with a megabyte figure that never named the cause.
|
|
59
|
+
// An operator naming the trainer's GPUs is the only way this can be right, and gradient training refuses without it.
|
|
60
|
+
trainer: { container: 'flashtrain', script: 'train/teach.py', gpus: '', maxSteps: 20, timeoutMs: 1_800_000, minFreeGpuMb: 20_000, idleStopMin: 30 },
|
|
61
|
+
locality: { prompts: DEFAULT_LOCALITY_PROMPTS, minSame: 11 },
|
|
62
|
+
dataset: {
|
|
63
|
+
maxBytes: 4_000_000, maxSourceLines: 50_000, maxRows: 2_000,
|
|
64
|
+
perKeyPerDay: 10, keptPerKey: 20,
|
|
65
|
+
rowsPerKeyPerDay: 300, rowsPerIpPerDay: 500, bytesPerKeyPerDay: 20_000_000,
|
|
66
|
+
ttlDays: 7, stagedTtlHours: 24, createsPerIpPerMin: 10, declarationRows: 100,
|
|
67
|
+
},
|
|
68
|
+
rowsPerJob: { floorGradient: 8, floorStub: 200, ceiling: 1_000, safetyFactor: 2 },
|
|
69
|
+
effort: { quick: { maxSteps: 8, evalEvery: 2 }, balanced: { maxSteps: 20, evalEvery: 2 }, thorough: { maxSteps: 40, evalEvery: 4 }, lr: 2e-3 },
|
|
70
|
+
check: { callBudget: 68, sampleRows: 24, chatFormRows: 8, parentSamplesMax: 20, lockTargetMs: 300_000, lockAbortMs: 480_000, lockGraceMs: 30 * 60_000 },
|
|
71
|
+
preflight: { sampleRows: 24, perCall: 8 },
|
|
72
|
+
queuedRowsMax: 2_000,
|
|
73
|
+
checkStubLessons: false,
|
|
74
|
+
trustedKeys: [],
|
|
75
|
+
lineage: false,
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* What a verifier will spend on unpaid work for strangers (items 332 / 333 / 336). Every one of these was
|
|
79
|
+
* unbounded: the round verified hidden test listings, held the shared model in front of the node's own visitors,
|
|
80
|
+
* and kept every body it ever downloaded.
|
|
81
|
+
*/
|
|
82
|
+
export const DEFAULT_VERIFIER_BUDGET = {
|
|
83
|
+
/**
|
|
84
|
+
* Stop attesting below this balance where the chain charges gas (item 341). An attestation is a write the VERIFIER
|
|
85
|
+
* signs and pays for — the plan's "seller pays gas" cannot hold for a record the verifier signs — so the unpaid
|
|
86
|
+
* role becomes a net-paying one the moment gas is real, and `verifier.auto` would spend the account to nothing,
|
|
87
|
+
* taking announce, settle and payout with it. No effect on the local ledger, which has no gas.
|
|
88
|
+
*/
|
|
89
|
+
minBalance: 1,
|
|
90
|
+
includeTest: false,
|
|
91
|
+
minPrice: '0',
|
|
92
|
+
maxPerHour: 40,
|
|
93
|
+
maxModelMinutesPerHour: 10,
|
|
94
|
+
window: null,
|
|
95
|
+
retainBodies: false,
|
|
96
|
+
};
|
|
97
|
+
/** `cfg.verifier` with the budget defaults filled in (a config.json written before they existed has none of them). */
|
|
98
|
+
export function verifierConfig(cfg) {
|
|
99
|
+
const v = cfg.verifier ?? { quorum: 2, allowSelfAttest: false, intervalMs: 5000 };
|
|
100
|
+
return { ...DEFAULT_VERIFIER_BUDGET, ...v };
|
|
101
|
+
}
|
|
102
|
+
/** Operator ceiling for `dataset.maxBytes` — a node may not accept an upload larger than this whatever the config says. */
|
|
103
|
+
export const DATASET_MAX_BYTES_CEILING = 20_000_000;
|
|
104
|
+
/** Effective teach config: `cfg.teach` merged over the defaults (older config.json files have no `teach` block). */
|
|
105
|
+
export function teachConfig(cfg) {
|
|
106
|
+
const t = (cfg.teach ?? {});
|
|
107
|
+
const d = DEFAULT_TEACH_CONFIG;
|
|
108
|
+
return {
|
|
109
|
+
...d, ...t,
|
|
110
|
+
trainer: { ...d.trainer, ...(t.trainer ?? {}) },
|
|
111
|
+
locality: { ...d.locality, ...(t.locality ?? {}) },
|
|
112
|
+
dataset: { ...d.dataset, ...(t.dataset ?? {}) },
|
|
113
|
+
rowsPerJob: { ...d.rowsPerJob, ...(t.rowsPerJob ?? {}) },
|
|
114
|
+
effort: {
|
|
115
|
+
...d.effort, ...(t.effort ?? {}),
|
|
116
|
+
quick: { ...d.effort.quick, ...(t.effort?.quick ?? {}) },
|
|
117
|
+
balanced: { ...d.effort.balanced, ...(t.effort?.balanced ?? {}) },
|
|
118
|
+
thorough: { ...d.effort.thorough, ...(t.effort?.thorough ?? {}) },
|
|
119
|
+
},
|
|
120
|
+
check: { ...d.check, ...(t.check ?? {}) },
|
|
121
|
+
preflight: { ...d.preflight, ...(t.preflight ?? {}) },
|
|
122
|
+
queuedRowsMax: t.queuedRowsMax ?? d.queuedRowsMax,
|
|
123
|
+
checkStubLessons: t.checkStubLessons ?? d.checkStubLessons,
|
|
124
|
+
trustedKeys: t.trustedKeys ?? d.trustedKeys,
|
|
125
|
+
lineage: t.lineage ?? d.lineage,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export const ETA_MIN_SAMPLES = 3;
|
|
129
|
+
export function percentileOf(xs, p) {
|
|
130
|
+
if (!xs.length)
|
|
131
|
+
return null;
|
|
132
|
+
const s = [...xs].sort((a, b) => a - b);
|
|
133
|
+
return s[Math.min(s.length - 1, Math.floor(p * (s.length - 1)))];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* How many questions one lesson may train on this node (design §D1).
|
|
137
|
+
*
|
|
138
|
+
* s_per_row_p90 = p90( (total_s − load_s) / (rows_trained × steps) ) over gradient samples only
|
|
139
|
+
* max_rows = floor( (timeoutMs/1000 − load_s_p90) / (passes × s_per_row_p90) / safetyFactor )
|
|
140
|
+
* rowsPerJob = clamp(floor, max_rows, ceiling)
|
|
141
|
+
*
|
|
142
|
+
* The whole derivation is skipped — the floor is used — while fewer than `ETA_MIN_SAMPLES` gradient samples exist, or
|
|
143
|
+
* while the trainer has not shown that it supports sampled evaluation (design §16: an unsampled eval at 100 questions
|
|
144
|
+
* would spend more time probing than training). An operator override disables the derivation entirely.
|
|
145
|
+
*/
|
|
146
|
+
export function deriveRowsPerJob(cfg, samples, opts = {}) {
|
|
147
|
+
const floor = cfg.backend === 'stub' ? cfg.rowsPerJob.floorStub : cfg.rowsPerJob.floorGradient;
|
|
148
|
+
const ceiling = Math.max(floor, cfg.rowsPerJob.ceiling);
|
|
149
|
+
const passes = cfg.effort[opts.effort ?? 'balanced'].maxSteps;
|
|
150
|
+
const usable = samples.filter((s) => Number.isFinite(s.total_s) && (s.rows_trained ?? 0) > 0 && (s.steps ?? 0) > 0);
|
|
151
|
+
const perRow = usable.map((s) => (s.total_s - (s.load_s ?? 0)) / (s.rows_trained * s.steps)).filter((x) => Number.isFinite(x) && x > 0);
|
|
152
|
+
const loads = usable.map((s) => s.load_s).filter((x) => typeof x === 'number' && Number.isFinite(x));
|
|
153
|
+
const s50 = percentileOf(perRow, 0.5);
|
|
154
|
+
const s90 = percentileOf(perRow, 0.9);
|
|
155
|
+
const l50 = percentileOf(loads, 0.5);
|
|
156
|
+
const base = { s_per_row_p50: s50, s_per_row_p90: s90, load_s_p50: l50, samples: perRow.length };
|
|
157
|
+
if (typeof opts.override === 'number' && opts.override > 0)
|
|
158
|
+
return { rows: Math.min(ceiling, Math.max(1, Math.floor(opts.override))), source: 'operator', ...base };
|
|
159
|
+
if (perRow.length < ETA_MIN_SAMPLES || s90 === null || opts.trainerSupportsSampling !== true)
|
|
160
|
+
return { rows: floor, source: 'default', ...base };
|
|
161
|
+
const budget_s = cfg.trainer.timeoutMs / 1000 - (l50 ?? 0);
|
|
162
|
+
const maxRows = Math.floor(budget_s / (passes * s90) / Math.max(1, cfg.rowsPerJob.safetyFactor));
|
|
163
|
+
return { rows: Math.min(ceiling, Math.max(floor, maxRows)), source: 'measured', ...base };
|
|
164
|
+
}
|
|
165
|
+
/** `"4,5"` / `"0,1,2,3"` → a set of GPU indices; anything unparseable is simply not in the set. */
|
|
166
|
+
export function gpuSet(spec) {
|
|
167
|
+
return new Set((spec ?? '').split(',').map((s) => s.trim()).filter(Boolean));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The GPUs `teach.trainer.gpus` and `runtime.gpus` have in common (item 145).
|
|
171
|
+
*
|
|
172
|
+
* deploy/README states the rule — "never let the two sets overlap: the trainer loads a second copy of the model's
|
|
173
|
+
* memory table and would starve vLLM" — and nothing in the code checked it. The shipped default named the very GPUs
|
|
174
|
+
* the shipped cluster serves on, and the README then invited the operator to switch gradient training on.
|
|
175
|
+
*/
|
|
176
|
+
export function gpuOverlap(servingGpus, trainerGpus) {
|
|
177
|
+
const serving = gpuSet(servingGpus);
|
|
178
|
+
return [...gpuSet(trainerGpus)].filter((g) => serving.has(g));
|
|
179
|
+
}
|
|
180
|
+
/** How long raw `events` rows are kept when the operator has not said otherwise (item 128). */
|
|
181
|
+
export const DEFAULT_EVENTS_RETENTION_DAYS = 90;
|
|
182
|
+
/**
|
|
183
|
+
* What a fresh node accepts from peer exchange (items 136/137). Discovery stays ON — a marketplace whose nodes only
|
|
184
|
+
* ever talk to a hand-written list is not a network — but it is now bounded, marked and reversible: learned peers
|
|
185
|
+
* are labelled `learned` in `ainize peers ls`, capped at `maxPeers`, dropped when they stop answering, and an
|
|
186
|
+
* endpoint the operator removes stays removed until they add it back.
|
|
187
|
+
*/
|
|
188
|
+
export const DEFAULT_P2P_CONFIG = { acceptExchange: true, maxPeers: 50, evictAfterFailures: 60, staleDays: 7 };
|
|
189
|
+
export function defaultConfig(opts = {}) {
|
|
190
|
+
const home = opts.home ?? DEFAULT_HOME;
|
|
191
|
+
const identity = opts.privateKey ? identityFromPrivateKey(opts.privateKey) : createIdentity();
|
|
192
|
+
const ledger = opts.ledger ?? 'local';
|
|
193
|
+
return {
|
|
194
|
+
name: opts.name ?? `node-${identity.address.slice(2, 8).toLowerCase()}`,
|
|
195
|
+
dataDir: join(home, 'data'),
|
|
196
|
+
port: opts.port ?? 3402,
|
|
197
|
+
// Loopback by default (item 121). Between `start` and the first `login` a node has no operator password, and a
|
|
198
|
+
// node bound to every interface is claimed by whoever scans the port first — `POST /api/auth/setup` hands them
|
|
199
|
+
// a session that can announce, buy, spend the wallet and change the payout address. Going public is a decision
|
|
200
|
+
// the operator makes on purpose: `ainize init --host 0.0.0.0` (or `--public`), or AINIZE_HOST.
|
|
201
|
+
host: opts.host ?? '127.0.0.1',
|
|
202
|
+
publicUrl: opts.publicUrl,
|
|
203
|
+
roles: opts.roles ?? ['seller', 'verifier', 'serving'],
|
|
204
|
+
peers: opts.peers ?? [],
|
|
205
|
+
ledger: {
|
|
206
|
+
kind: ledger,
|
|
207
|
+
ain: {
|
|
208
|
+
providerUrl: opts.ainProviderUrl ?? 'http://localhost:8081',
|
|
209
|
+
eventHandlerUrl: opts.ainEventUrl ?? null,
|
|
210
|
+
chainId: opts.ainChainId ?? 0,
|
|
211
|
+
appName: 'knowledge',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
identity,
|
|
215
|
+
runtime: {
|
|
216
|
+
repo: opts.runtimeRepo ?? (existsSync('/mnt/newdata/qwen3.8') ? '/mnt/newdata/qwen3.8' : undefined),
|
|
217
|
+
api: opts.runtimeApi ?? 'http://localhost:8000',
|
|
218
|
+
patchDir: opts.runtimePatchDir,
|
|
219
|
+
hookApi: 'http://localhost:8001',
|
|
220
|
+
python: 'python3',
|
|
221
|
+
},
|
|
222
|
+
verifier: { quorum: 2, allowSelfAttest: false, intervalMs: 5000, auto: true, ...DEFAULT_VERIFIER_BUDGET },
|
|
223
|
+
market: {
|
|
224
|
+
currency: opts.currency ?? (ledger === 'ain' ? 'AIN' : 'CREDIT'),
|
|
225
|
+
defaultPrice: '0.1',
|
|
226
|
+
royaltyShare: NETWORK_MIN_ROYALTY_SHARE,
|
|
227
|
+
verifierShare: NETWORK_MIN_VERIFIER_SHARE,
|
|
228
|
+
initialCredit: '100',
|
|
229
|
+
creditGrants: 100,
|
|
230
|
+
},
|
|
231
|
+
teach: structuredClone(DEFAULT_TEACH_CONFIG),
|
|
232
|
+
p2p: { ...DEFAULT_P2P_CONFIG },
|
|
233
|
+
server: { trustProxy: false },
|
|
234
|
+
events: { retentionDays: DEFAULT_EVENTS_RETENTION_DAYS },
|
|
235
|
+
gossipIntervalMs: 4000,
|
|
236
|
+
version: VERSION,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
export function loadConfig(home = DEFAULT_HOME) {
|
|
240
|
+
const p = configPath(home);
|
|
241
|
+
if (!existsSync(p))
|
|
242
|
+
return null;
|
|
243
|
+
const cfg = JSON.parse(readFileSync(p, 'utf8'));
|
|
244
|
+
cfg.dataDir = resolve(cfg.dataDir);
|
|
245
|
+
cfg.teach = teachConfig(cfg);
|
|
246
|
+
return cfg;
|
|
247
|
+
}
|
|
248
|
+
export function saveConfig(cfg, home = DEFAULT_HOME) {
|
|
249
|
+
mkdirSync(home, { recursive: true });
|
|
250
|
+
mkdirSync(cfg.dataDir, { recursive: true });
|
|
251
|
+
const p = configPath(home);
|
|
252
|
+
writeFileSync(p, JSON.stringify(cfg, null, 2) + '\n', { mode: 0o600 });
|
|
253
|
+
return p;
|
|
254
|
+
}
|
|
255
|
+
const isPlainObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
256
|
+
/**
|
|
257
|
+
* Fold the changes a running node made to its own config (`boot` → `live`: the operator password, a peer added or
|
|
258
|
+
* removed in the console, a display name) onto whatever is on disk NOW, instead of writing the node's whole
|
|
259
|
+
* start-up snapshot over it. Without this, one click in the console silently reverted every `ainize config set`
|
|
260
|
+
* made since the node started (item 124).
|
|
261
|
+
*/
|
|
262
|
+
export function mergeConfigChanges(onDisk, boot, live) {
|
|
263
|
+
const out = structuredClone(onDisk);
|
|
264
|
+
const walk = (b, l, target) => {
|
|
265
|
+
for (const k of new Set([...Object.keys(b ?? {}), ...Object.keys(l ?? {})])) {
|
|
266
|
+
const bv = b?.[k];
|
|
267
|
+
const lv = l?.[k];
|
|
268
|
+
if (JSON.stringify(bv) === JSON.stringify(lv))
|
|
269
|
+
continue; // the node did not touch it — the disk wins
|
|
270
|
+
if (lv === undefined) {
|
|
271
|
+
delete target[k];
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (isPlainObject(bv) && isPlainObject(lv)) {
|
|
275
|
+
if (!isPlainObject(target[k]))
|
|
276
|
+
target[k] = {};
|
|
277
|
+
walk(bv, lv, target[k]);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
target[k] = structuredClone(lv);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
walk(boot, live, out);
|
|
285
|
+
return out;
|
|
286
|
+
}
|
|
287
|
+
/** Environment overrides (handy for docker / multi-node demos). */
|
|
288
|
+
export function applyEnv(cfg, env = process.env) {
|
|
289
|
+
if (env.AINIZE_PORT)
|
|
290
|
+
cfg.port = Number(env.AINIZE_PORT);
|
|
291
|
+
if (env.AINIZE_HOST)
|
|
292
|
+
cfg.host = env.AINIZE_HOST;
|
|
293
|
+
if (env.AINIZE_PEERS)
|
|
294
|
+
cfg.peers = env.AINIZE_PEERS.split(',').map((s) => s.trim()).filter(Boolean);
|
|
295
|
+
if (env.AINIZE_LEDGER === 'ain' || env.AINIZE_LEDGER === 'local')
|
|
296
|
+
cfg.ledger.kind = env.AINIZE_LEDGER;
|
|
297
|
+
if (env.AIN_PROVIDER_URL)
|
|
298
|
+
cfg.ledger.ain.providerUrl = env.AIN_PROVIDER_URL;
|
|
299
|
+
if (env.AINIZE_ROLES)
|
|
300
|
+
cfg.roles = env.AINIZE_ROLES.split(',');
|
|
301
|
+
if (env.AINIZE_PUBLIC_URL)
|
|
302
|
+
cfg.publicUrl = env.AINIZE_PUBLIC_URL;
|
|
303
|
+
if (env.AINIZE_RUNTIME_REPO)
|
|
304
|
+
cfg.runtime = { ...cfg.runtime, repo: env.AINIZE_RUNTIME_REPO };
|
|
305
|
+
if (env.AINIZE_RUNTIME_API)
|
|
306
|
+
cfg.runtime = { ...cfg.runtime, api: env.AINIZE_RUNTIME_API };
|
|
307
|
+
if (env.AINIZE_RUNTIME_PATCH_DIR)
|
|
308
|
+
cfg.runtime = { ...cfg.runtime, patchDir: env.AINIZE_RUNTIME_PATCH_DIR };
|
|
309
|
+
if (env.AINIZE_TEACH_BACKEND === 'stub' || env.AINIZE_TEACH_BACKEND === 'gradient')
|
|
310
|
+
cfg.teach = { ...teachConfig(cfg), backend: env.AINIZE_TEACH_BACKEND };
|
|
311
|
+
if (env.AINIZE_TEACH_ENABLED === '1' || env.AINIZE_TEACH_ENABLED === '0')
|
|
312
|
+
cfg.teach = { ...teachConfig(cfg), enabled: env.AINIZE_TEACH_ENABLED === '1' };
|
|
313
|
+
if (env.AINIZE_TRUST_PROXY !== undefined)
|
|
314
|
+
cfg.server = { ...(cfg.server ?? {}), trustProxy: parseTrustProxy(env.AINIZE_TRUST_PROXY) };
|
|
315
|
+
if (env.AINIZE_TEACH_STUB_OFFLINE === '1' || env.AINIZE_TEACH_STUB_OFFLINE === '0')
|
|
316
|
+
cfg.teach = { ...teachConfig(cfg), stubOffline: env.AINIZE_TEACH_STUB_OFFLINE === '1' };
|
|
317
|
+
return cfg;
|
|
318
|
+
}
|
|
319
|
+
/** `AINIZE_TRUST_PROXY`: `0|false` → off, `1|2|…` → hop count, `true` → every proxy (only behind a proxy that overwrites X-Forwarded-For), anything else → Express IP/CIDR/`loopback` list. */
|
|
320
|
+
export function parseTrustProxy(v) {
|
|
321
|
+
const s = v.trim();
|
|
322
|
+
if (s === '' || s === '0' || s.toLowerCase() === 'false')
|
|
323
|
+
return false;
|
|
324
|
+
if (s.toLowerCase() === 'true')
|
|
325
|
+
return true;
|
|
326
|
+
if (/^\d+$/.test(s))
|
|
327
|
+
return Number(s);
|
|
328
|
+
return s;
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,eAAe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|
+
* `ainize logs --kind` offers exactly this list, so a mistyped kind is refused with the list instead of
|
|
5
|
+
* printing an empty screen that looks like an idle node (items 116/132) — and the CLI has to know the list
|
|
6
|
+
* to do that. It used to import it from `@ainize/node`, which meant a terminal that only ever talks to a
|
|
7
|
+
* remote node over HTTP still had to install express, sqlite and the trainer to spell-check a flag.
|
|
8
|
+
*/
|
|
9
|
+
/** Severity order (low → high): a `level` filter means "this level and worse". */
|
|
10
|
+
export declare const EVENT_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
11
|
+
export type EventLevel = (typeof EVENT_LEVELS)[number];
|
|
12
|
+
/** Every `kind` a node writes events under. */
|
|
13
|
+
export declare const EVENT_KINDS: readonly ["blob", "branch", "buy", "challenge", "config", "drive", "lineage", "node", "p2p", "patch", "payout", "publish", "royalty", "runtime", "seed", "settings", "teach", "trade", "usage", "verifier", "verify"];
|
|
14
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kFAAkF;AAClF,eAAO,MAAM,YAAY,6CAA8C,CAAC;AACxE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,+CAA+C;AAC/C,eAAO,MAAM,WAAW,uNAOd,CAAC"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary of a node's event log, in core because the things that READ the log are not the node.
|
|
3
|
+
*
|
|
4
|
+
* `ainize logs --kind` offers exactly this list, so a mistyped kind is refused with the list instead of
|
|
5
|
+
* printing an empty screen that looks like an idle node (items 116/132) — and the CLI has to know the list
|
|
6
|
+
* to do that. It used to import it from `@ainize/node`, which meant a terminal that only ever talks to a
|
|
7
|
+
* remote node over HTTP still had to install express, sqlite and the trainer to spell-check a flag.
|
|
8
|
+
*/
|
|
9
|
+
/** Severity order (low → high): a `level` filter means "this level and worse". */
|
|
10
|
+
export const EVENT_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
11
|
+
/** Every `kind` a node writes events under. */
|
|
12
|
+
export const EVENT_KINDS = [
|
|
13
|
+
'blob', 'branch', 'buy', 'challenge', 'config', 'drive',
|
|
14
|
+
// `lineage` = somebody published a knowledge built on one of ours; `royalty` = a sale of theirs paid us for it
|
|
15
|
+
// (items 183, 195, 318, 319). Both are derived from the catalogue, so `ainize logs --kind lineage` works on
|
|
16
|
+
// whichever route the record took.
|
|
17
|
+
'lineage', 'node', 'p2p', 'patch', 'payout', 'publish', 'royalty',
|
|
18
|
+
'runtime', 'seed', 'settings', 'teach', 'trade', 'usage', 'verifier', 'verify',
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kFAAkF;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAGxE,+CAA+C;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO;IACvD,+GAA+G;IAC/G,4GAA4G;IAC5G,mCAAmC;IACnC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;IACjE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ;CACtE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Identity {
|
|
2
|
+
privateKey: string;
|
|
3
|
+
publicKey: string;
|
|
4
|
+
address: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createIdentity(): Identity;
|
|
7
|
+
export declare function identityFromPrivateKey(privHex: string): Identity;
|
|
8
|
+
export declare function signMessage(message: string, privHex: string): string;
|
|
9
|
+
export declare function verifyMessage(message: string, signature: string, address: string): boolean;
|
|
10
|
+
export declare function isAddress(value: string): boolean;
|
|
11
|
+
export declare function checksum(address: string): string;
|
|
12
|
+
/** Operator password hashing (scrypt) for the web console login. */
|
|
13
|
+
export declare function hashPassword(password: string): string;
|
|
14
|
+
export declare function verifyPassword(password: string, stored: string): boolean;
|
|
15
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,IAAI,QAAQ,CAKzC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAKhE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAM1F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMhD;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMxE"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node identity = an AIN blockchain account (secp256k1). We reuse @ainblockchain/ain-util
|
|
3
|
+
* exactly like the original ainize-cli did for request signing (ecSignMessage / ecVerifySig),
|
|
4
|
+
* so a node's signature over a ledger record is verifiable by any peer with only the address.
|
|
5
|
+
*/
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { randomBytes, scryptSync, timingSafeEqual } from 'node:crypto';
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
// ain-util is CommonJS
|
|
10
|
+
const ainUtil = require('@ainblockchain/ain-util');
|
|
11
|
+
export function createIdentity() {
|
|
12
|
+
const priv = randomBytes(32);
|
|
13
|
+
const pub = ainUtil.privateToPublic(priv);
|
|
14
|
+
const address = ainUtil.toChecksumAddress(ainUtil.bufferToHex(ainUtil.pubToAddress(pub)));
|
|
15
|
+
return { privateKey: priv.toString('hex'), publicKey: pub.toString('hex'), address };
|
|
16
|
+
}
|
|
17
|
+
export function identityFromPrivateKey(privHex) {
|
|
18
|
+
const priv = Buffer.from(privHex.replace(/^0x/, ''), 'hex');
|
|
19
|
+
const pub = ainUtil.privateToPublic(priv);
|
|
20
|
+
const address = ainUtil.toChecksumAddress(ainUtil.bufferToHex(ainUtil.pubToAddress(pub)));
|
|
21
|
+
return { privateKey: priv.toString('hex'), publicKey: pub.toString('hex'), address };
|
|
22
|
+
}
|
|
23
|
+
export function signMessage(message, privHex) {
|
|
24
|
+
return ainUtil.ecSignMessage(message, Buffer.from(privHex.replace(/^0x/, ''), 'hex'));
|
|
25
|
+
}
|
|
26
|
+
export function verifyMessage(message, signature, address) {
|
|
27
|
+
try {
|
|
28
|
+
return ainUtil.ecVerifySig(message, signature, address);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function isAddress(value) {
|
|
35
|
+
try {
|
|
36
|
+
return ainUtil.isValidAddress(value);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function checksum(address) {
|
|
43
|
+
return ainUtil.toChecksumAddress(address);
|
|
44
|
+
}
|
|
45
|
+
/** Operator password hashing (scrypt) for the web console login. */
|
|
46
|
+
export function hashPassword(password) {
|
|
47
|
+
const salt = randomBytes(16);
|
|
48
|
+
const key = scryptSync(password, salt, 32);
|
|
49
|
+
return `scrypt$${salt.toString('hex')}$${key.toString('hex')}`;
|
|
50
|
+
}
|
|
51
|
+
export function verifyPassword(password, stored) {
|
|
52
|
+
const [alg, saltHex, keyHex] = stored.split('$');
|
|
53
|
+
if (alg !== 'scrypt' || !saltHex || !keyHex)
|
|
54
|
+
return false;
|
|
55
|
+
const key = scryptSync(password, Buffer.from(saltHex, 'hex'), 32);
|
|
56
|
+
const expected = Buffer.from(keyHex, 'hex');
|
|
57
|
+
return key.length === expected.length && timingSafeEqual(key, expected);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,uBAAuB;AACvB,MAAM,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAA6C,CAAC;AAQ/F,MAAM,UAAU,cAAc;IAC5B,MAAM,IAAI,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC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ical.js';
|
|
3
|
+
export * from './identity.js';
|
|
4
|
+
export * from './npz.js';
|
|
5
|
+
export * from './x402.js';
|
|
6
|
+
export * from './ledger.js';
|
|
7
|
+
export * from './local-ledger.js';
|
|
8
|
+
export * from './ain-ledger.js';
|
|
9
|
+
export * from './catalog.js';
|
|
10
|
+
export * from './lineage.js';
|
|
11
|
+
export * from './config.js';
|
|
12
|
+
export * from './config-schema.js';
|
|
13
|
+
export * from './events.js';
|
|
14
|
+
export * from './bytes.js';
|
|
15
|
+
export * from './teach-auth.js';
|
|
16
|
+
export * from './ops.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|