homegraph 1.5.1 → 1.5.2
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 -21
- package/README.md +305 -305
- package/dist/bin/homegraph.js +9 -9
- package/dist/db/index.js +36 -36
- package/dist/db/migrations.js +37 -37
- package/dist/db/queries.js +156 -156
- package/dist/db/schema.sql +203 -203
- package/dist/directory.js +5 -5
- package/dist/extraction/index.d.ts +1 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +54 -43
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +53 -6
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +565 -65
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/installer/instructions-template.js +9 -9
- package/dist/mcp/diff-impact.d.ts +131 -0
- package/dist/mcp/diff-impact.d.ts.map +1 -0
- package/dist/mcp/diff-impact.js +385 -0
- package/dist/mcp/diff-impact.js.map +1 -0
- package/dist/mcp/liveness-watchdog.js +51 -51
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +49 -47
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/tools.d.ts +21 -5
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +305 -55
- package/dist/mcp/tools.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +2 -1
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +153 -53
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -1
- package/dist/resolution/frameworks/arkts-entry.js +20 -9
- package/dist/resolution/frameworks/arkts-entry.js.map +1 -1
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/memory-budget.d.ts +33 -0
- package/dist/resolution/memory-budget.d.ts.map +1 -1
- package/dist/resolution/memory-budget.js +58 -0
- package/dist/resolution/memory-budget.js.map +1 -1
- package/dist/resolution/resolver-pool.d.ts +2 -0
- package/dist/resolution/resolver-pool.d.ts.map +1 -1
- package/dist/resolution/resolver-pool.js +4 -0
- package/dist/resolution/resolver-pool.js.map +1 -1
- package/dist/spec/db/commit-node.js +4 -4
- package/dist/spec/db/fragment-node.js +10 -10
- package/dist/spec/db/fts.js +8 -8
- package/dist/spec/db/relations.js +88 -88
- package/dist/spec/db/schema.js +6 -6
- package/dist/spec/db/schema.sql +121 -121
- package/dist/spec/db/spec-node.js +4 -4
- package/dist/spec/llm/prompts.js +53 -53
- package/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/dist/ui/shimmer-progress.js +4 -1
- package/dist/ui/shimmer-progress.js.map +1 -1
- package/package.json +61 -62
- package/dist/extraction/languages/arkts-viewtree.d.ts +0 -22
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +0 -1
- package/dist/extraction/languages/arkts-viewtree.js +0 -133
- package/dist/extraction/languages/arkts-viewtree.js.map +0 -1
- package/dist/reasoning/config.d.ts +0 -45
- package/dist/reasoning/config.d.ts.map +0 -1
- package/dist/reasoning/config.js +0 -171
- package/dist/reasoning/config.js.map +0 -1
- package/dist/reasoning/credentials.d.ts +0 -5
- package/dist/reasoning/credentials.d.ts.map +0 -1
- package/dist/reasoning/credentials.js +0 -83
- package/dist/reasoning/credentials.js.map +0 -1
- package/dist/reasoning/login.d.ts +0 -21
- package/dist/reasoning/login.d.ts.map +0 -1
- package/dist/reasoning/login.js +0 -85
- package/dist/reasoning/login.js.map +0 -1
- package/dist/reasoning/reasoner.d.ts +0 -43
- package/dist/reasoning/reasoner.d.ts.map +0 -1
- package/dist/reasoning/reasoner.js +0 -308
- package/dist/reasoning/reasoner.js.map +0 -1
- package/dist/spec/evolve/llm-client.d.ts +0 -50
- package/dist/spec/evolve/llm-client.d.ts.map +0 -1
- package/dist/spec/evolve/llm-client.js +0 -176
- package/dist/spec/evolve/llm-client.js.map +0 -1
- package/dist/spec/evolve/logic-checker.d.ts +0 -12
- package/dist/spec/evolve/logic-checker.d.ts.map +0 -1
- package/dist/spec/evolve/logic-checker.js +0 -24
- package/dist/spec/evolve/logic-checker.js.map +0 -1
- package/dist/spec/llm/index.d.ts +0 -3
- package/dist/spec/llm/index.d.ts.map +0 -1
- package/dist/spec/llm/index.js +0 -11
- package/dist/spec/llm/index.js.map +0 -1
- package/dist/spec/mining/diff-parser.d.ts +0 -33
- package/dist/spec/mining/diff-parser.d.ts.map +0 -1
- package/dist/spec/mining/diff-parser.js +0 -166
- package/dist/spec/mining/diff-parser.js.map +0 -1
- package/dist/spec/mining/git-scanner.d.ts +0 -103
- package/dist/spec/mining/git-scanner.d.ts.map +0 -1
- package/dist/spec/mining/git-scanner.js +0 -307
- package/dist/spec/mining/git-scanner.js.map +0 -1
- package/dist/spec/mining/pipeline.d.ts +0 -53
- package/dist/spec/mining/pipeline.d.ts.map +0 -1
- package/dist/spec/mining/pipeline.js +0 -178
- package/dist/spec/mining/pipeline.js.map +0 -1
- package/dist/spec/mining/scope-resolver.d.ts +0 -45
- package/dist/spec/mining/scope-resolver.d.ts.map +0 -1
- package/dist/spec/mining/scope-resolver.js +0 -103
- package/dist/spec/mining/scope-resolver.js.map +0 -1
- package/dist/spec/mining/spec-extractor.d.ts +0 -69
- package/dist/spec/mining/spec-extractor.d.ts.map +0 -1
- package/dist/spec/mining/spec-extractor.js +0 -369
- package/dist/spec/mining/spec-extractor.js.map +0 -1
- package/dist/spec/utils.d.ts +0 -167
- package/dist/spec/utils.d.ts.map +0 -1
- package/dist/spec/utils.js +0 -463
- package/dist/spec/utils.js.map +0 -1
- package/scripts/_tmp-cfwk-resolve.log +0 -0
- package/scripts/_tmp-cfwk-sig.log +0 -0
- package/scripts/_tmp-cfwk-vt.log +0 -0
- package/scripts/add-lang/bench.sh +0 -60
- package/scripts/add-lang/check-grammar.mjs +0 -75
- package/scripts/add-lang/dump-ast.mjs +0 -103
- package/scripts/add-lang/verify-extraction.mjs +0 -70
- package/scripts/agent-eval/ab-adoption.sh +0 -91
- package/scripts/agent-eval/ab-hook.sh +0 -86
- package/scripts/agent-eval/ab-impl.sh +0 -78
- package/scripts/agent-eval/ab-new-vs-baseline.sh +0 -102
- package/scripts/agent-eval/ab-sufficiency.sh +0 -78
- package/scripts/agent-eval/arms-F.sh +0 -21
- package/scripts/agent-eval/arms-matrix.sh +0 -37
- package/scripts/agent-eval/audit.sh +0 -68
- package/scripts/agent-eval/bench-readme.sh +0 -28
- package/scripts/agent-eval/bench-why-repo.sh +0 -22
- package/scripts/agent-eval/block-read-hook.sh +0 -19
- package/scripts/agent-eval/hook-settings.json +0 -15
- package/scripts/agent-eval/itrun.sh +0 -120
- package/scripts/agent-eval/offload-eval-3arm.sh +0 -72
- package/scripts/agent-eval/offload-eval-cost.mjs +0 -133
- package/scripts/agent-eval/offload-eval-effort.mjs +0 -108
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +0 -25
- package/scripts/agent-eval/offload-eval-frontload.sh +0 -47
- package/scripts/agent-eval/offload-eval-ground-truth.json +0 -18
- package/scripts/agent-eval/offload-eval-hook.mjs +0 -84
- package/scripts/agent-eval/offload-eval-judge.mjs +0 -103
- package/scripts/agent-eval/offload-eval-matrix.sh +0 -20
- package/scripts/agent-eval/offload-eval-metrics.mjs +0 -94
- package/scripts/agent-eval/offload-eval-refs1.sh +0 -50
- package/scripts/agent-eval/offload-eval-setup.sh +0 -24
- package/scripts/agent-eval/offload-eval-styles.sh +0 -72
- package/scripts/agent-eval/offload-eval-summarize.mjs +0 -68
- package/scripts/agent-eval/offload-eval.md +0 -76
- package/scripts/agent-eval/parse-arms.mjs +0 -116
- package/scripts/agent-eval/parse-bench-readme.mjs +0 -84
- package/scripts/agent-eval/parse-run.mjs +0 -45
- package/scripts/agent-eval/parse-session.mjs +0 -93
- package/scripts/agent-eval/probe-context.mjs +0 -21
- package/scripts/agent-eval/probe-explore.mjs +0 -40
- package/scripts/agent-eval/probe-node.mjs +0 -20
- package/scripts/agent-eval/probe-sweep.mjs +0 -119
- package/scripts/agent-eval/probe-trace.mjs +0 -20
- package/scripts/agent-eval/redirect-read-hook.sh +0 -38
- package/scripts/agent-eval/repro-concurrent-explore.mjs +0 -119
- package/scripts/agent-eval/repro-daemon-clients.mjs +0 -125
- package/scripts/agent-eval/run-agent.sh +0 -34
- package/scripts/agent-eval/run-all.sh +0 -75
- package/scripts/agent-eval/run-arms.sh +0 -56
- package/scripts/agent-eval/seq-matrix.mjs +0 -137
- package/scripts/bench-arkts-init-rss.log +0 -0
- package/scripts/build-bundle.sh +0 -123
- package/scripts/exp_boundary_eval/README.md +0 -247
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_all.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/win_mcp_launcher.cpython-38.pyc +0 -0
- package/scripts/exp_boundary_eval/_test_mcp_chain.py +0 -78
- package/scripts/exp_boundary_eval/_test_stdin.py +0 -8
- package/scripts/exp_boundary_eval/_utils.py +0 -1116
- package/scripts/exp_boundary_eval/analyze.py +0 -1313
- package/scripts/exp_boundary_eval/deveco_arm.py +0 -519
- package/scripts/exp_boundary_eval/run_all.py +0 -378
- package/scripts/exp_boundary_eval/run_one.py +0 -165
- package/scripts/exp_boundary_eval/run_session.py +0 -158
- package/scripts/exp_boundary_eval/setup.py +0 -120
- package/scripts/exp_boundary_eval/win_mcp_launcher.py +0 -73
- package/scripts/exp_boundary_eval/win_mcp_stdio_wrap.js +0 -36
- package/scripts/exp_boundary_eval/win_node_launcher.py +0 -24
- package/scripts/extract-release-notes.mjs +0 -130
- package/scripts/local-install.sh +0 -41
- package/scripts/npm-sdk.js +0 -75
- package/scripts/npm-shim.js +0 -275
- package/scripts/ohos-sdk-publish.mjs +0 -133
- package/scripts/pack-npm.sh +0 -119
- package/scripts/prepare-release.mjs +0 -270
- package/scripts/probe-arkts-mem-why-run.log +0 -0
- package/scripts/probe-banner-livecard-ir.log +0 -0
- package/scripts/probe-cfwk-ast.stderr.log +0 -0
- package/scripts/probe-cfwk-ast.stdout.log +0 -0
- package/scripts/probe-cfwk-attr-shape.log +0 -0
- package/scripts/probe-cfwk-cfgdump.stderr.log +0 -0
- package/scripts/probe-cfwk-cfgdump.stdout.log +0 -0
- package/scripts/probe-cfwk-cvc.stderr.log +0 -0
- package/scripts/probe-cfwk-cvc.stdout.log +0 -0
- package/scripts/probe-cfwk-diag2.log +0 -0
- package/scripts/probe-cfwk-diag3.log +0 -0
- package/scripts/probe-cfwk-fedbg.stderr.log +0 -0
- package/scripts/probe-cfwk-fedbg.stdout.log +0 -0
- package/scripts/probe-cfwk-fileresult.log +0 -0
- package/scripts/probe-cfwk-fix.stderr.log +0 -0
- package/scripts/probe-cfwk-fix.stdout.log +0 -0
- package/scripts/probe-cfwk-fix2.stderr.log +0 -0
- package/scripts/probe-cfwk-fix2.stdout.log +0 -0
- package/scripts/probe-cfwk-fix3.stderr.log +0 -0
- package/scripts/probe-cfwk-fix3.stdout.log +0 -0
- package/scripts/probe-cfwk-foreach.log +0 -0
- package/scripts/probe-cfwk-getmethod-throw.log +0 -0
- package/scripts/probe-cfwk-hg-extract.log +0 -0
- package/scripts/probe-cfwk-pr1003-noprior.stderr.log +0 -0
- package/scripts/probe-cfwk-pr1003-noprior.stdout.log +0 -0
- package/scripts/probe-cfwk-pr1003.stderr.log +0 -0
- package/scripts/probe-cfwk-pr1003.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-noprior.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-noprior.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-prior.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-prior.stdout.log +0 -0
- package/scripts/probe-cfwk-preroot-skipstate.stderr.log +0 -0
- package/scripts/probe-cfwk-preroot-skipstate.stdout.log +0 -0
- package/scripts/probe-cfwk-resolve-sim.log +0 -0
- package/scripts/probe-cfwk-tree-shape.log +0 -0
- package/scripts/probe-cfwk-walk-abort.log +0 -0
- package/scripts/probe-cfwk.log +0 -0
- package/scripts/probe-force-index.log +0 -0
- package/scripts/probe-no-force-index.log +0 -0
- package/scripts/probe-samefile-ir.stderr.log +0 -0
- package/scripts/probe-samefile-ir.stdout.log +0 -224
- package/scripts/probe-sdk-vs-project.log +0 -0
- package/scripts/probe-viewtree-downgrade.log +0 -0
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexViewTreeForClass = indexViewTreeForClass;
|
|
4
|
-
/**
|
|
5
|
-
* Ingest ArkAnalyzer ViewTree into HomeGraph nodes/edges.
|
|
6
|
-
*
|
|
7
|
-
* Maps declarative UI structure (component tree, event bindings, state usage,
|
|
8
|
-
* prop transfer) to traversable graph edges — no custom runtime heuristics.
|
|
9
|
-
*/
|
|
10
|
-
const arkanalyzer_1 = require("arkanalyzer");
|
|
11
|
-
const CALLBACK_ATTRS = new Set(arkanalyzer_1.CALLBACK_METHOD_NAME);
|
|
12
|
-
function lineFromStmt(stmt) {
|
|
13
|
-
return stmt?.getOriginFullPosition()?.getFirstLine() ?? 1;
|
|
14
|
-
}
|
|
15
|
-
function isClassSignature(sig) {
|
|
16
|
-
return sig instanceof arkanalyzer_1.ClassSignature;
|
|
17
|
-
}
|
|
18
|
-
function resolveMethodFromSignature(ctx, sig) {
|
|
19
|
-
return ctx.scene.getMethod(sig);
|
|
20
|
-
}
|
|
21
|
-
function resolveClassFromSignature(ctx, sig) {
|
|
22
|
-
return ctx.scene.getClass(sig);
|
|
23
|
-
}
|
|
24
|
-
function walkViewTree(node, visit) {
|
|
25
|
-
visit(node);
|
|
26
|
-
for (const child of node.children) {
|
|
27
|
-
walkViewTree(child, visit);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function extractMethodSignatures(values) {
|
|
31
|
-
const out = [];
|
|
32
|
-
for (const v of values) {
|
|
33
|
-
if (v instanceof arkanalyzer_1.MethodSignature) {
|
|
34
|
-
out.push(v);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
function indexViewTreeForClass(ctx, cls, result, relativePath) {
|
|
40
|
-
if (!cls.hasViewTree())
|
|
41
|
-
return;
|
|
42
|
-
const viewTree = cls.getViewTree();
|
|
43
|
-
if (!viewTree)
|
|
44
|
-
return;
|
|
45
|
-
const root = viewTree.getRoot();
|
|
46
|
-
if (!root)
|
|
47
|
-
return;
|
|
48
|
-
const classNodeId = ctx.resolveClassNodeId(cls);
|
|
49
|
-
if (!classNodeId)
|
|
50
|
-
return;
|
|
51
|
-
const buildMethod = cls.getMethods(true).find((m) => m.getName() === 'build');
|
|
52
|
-
if (!buildMethod)
|
|
53
|
-
return;
|
|
54
|
-
const buildId = ctx.ensureMethodNode(buildMethod, relativePath, result, classNodeId);
|
|
55
|
-
if (!buildId)
|
|
56
|
-
return;
|
|
57
|
-
const seen = new Set();
|
|
58
|
-
const link = (source, target, kind, via, line) => {
|
|
59
|
-
const key = `${source}>${target}>${kind}>${via}`;
|
|
60
|
-
if (seen.has(key))
|
|
61
|
-
return;
|
|
62
|
-
seen.add(key);
|
|
63
|
-
ctx.addEdge(result, source, target, kind, relativePath, via, line);
|
|
64
|
-
};
|
|
65
|
-
// Reverse index: state field → build (UI reads this state in the tree).
|
|
66
|
-
for (const [field] of viewTree.getStateValues()) {
|
|
67
|
-
const fieldId = ctx.fieldToId.get(field);
|
|
68
|
-
if (fieldId) {
|
|
69
|
-
const line = field.getOriginFullPosition?.()?.getFirstLine?.() ?? buildMethod.getImplOriginFullPosition()?.getFirstLine() ?? 1;
|
|
70
|
-
link(fieldId, buildId, 'references', 'state-binding', line);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
walkViewTree(root, (node) => {
|
|
74
|
-
// Custom sub-component or @Builder child.
|
|
75
|
-
const sig = node.signature;
|
|
76
|
-
if (sig) {
|
|
77
|
-
if (isClassSignature(sig)) {
|
|
78
|
-
const childCls = resolveClassFromSignature(ctx, sig);
|
|
79
|
-
if (childCls) {
|
|
80
|
-
const childId = ctx.resolveClassNodeId(childCls);
|
|
81
|
-
if (childId) {
|
|
82
|
-
const firstAttr = node.attributes.values().next().value;
|
|
83
|
-
const line = firstAttr ? lineFromStmt(firstAttr[0]) : buildMethod.getImplOriginFullPosition()?.getFirstLine() ?? 1;
|
|
84
|
-
link(buildId, childId, 'references', 'child-component', line);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
const builderMethod = resolveMethodFromSignature(ctx, sig);
|
|
90
|
-
if (builderMethod) {
|
|
91
|
-
const builderId = ctx.ensureMethodNode(builderMethod, relativePath, result, classNodeId);
|
|
92
|
-
if (builderId) {
|
|
93
|
-
link(buildId, builderId, 'references', 'builder', builderMethod.getImplOriginFullPosition()?.getFirstLine() ?? 1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Parent → child prop transfer on embedded custom components.
|
|
99
|
-
if (node.stateValuesTransfer) {
|
|
100
|
-
for (const [childField, parentValue] of node.stateValuesTransfer) {
|
|
101
|
-
const childFieldId = ctx.fieldToId.get(childField);
|
|
102
|
-
if (parentValue instanceof arkanalyzer_1.ArkField) {
|
|
103
|
-
const parentFieldId = ctx.fieldToId.get(parentValue);
|
|
104
|
-
if (childFieldId && parentFieldId) {
|
|
105
|
-
link(parentFieldId, childFieldId, 'references', 'prop-transfer', childField.getOriginFullPosition()?.getFirstLine() ?? 1);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else if (parentValue instanceof arkanalyzer_1.ArkMethod) {
|
|
109
|
-
const builderId = ctx.ensureMethodNode(parentValue, relativePath, result, classNodeId);
|
|
110
|
-
if (childFieldId && builderId) {
|
|
111
|
-
link(builderId, childFieldId, 'references', 'builder-param', childField.getOriginFullPosition()?.getFirstLine() ?? 1);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Event handler bindings (.onClick, .onTouch, …).
|
|
117
|
-
for (const [attr, [stmt, values]] of node.attributes) {
|
|
118
|
-
if (!CALLBACK_ATTRS.has(attr))
|
|
119
|
-
continue;
|
|
120
|
-
const line = lineFromStmt(stmt);
|
|
121
|
-
for (const methodSig of extractMethodSignatures(values)) {
|
|
122
|
-
const handler = resolveMethodFromSignature(ctx, methodSig);
|
|
123
|
-
if (!handler)
|
|
124
|
-
continue;
|
|
125
|
-
const handlerId = ctx.ensureMethodNode(handler, relativePath, result, classNodeId);
|
|
126
|
-
if (handlerId) {
|
|
127
|
-
link(buildId, handlerId, 'references', attr, line);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=arkts-viewtree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkts-viewtree.js","sourceRoot":"","sources":["../../../src/extraction/languages/arkts-viewtree.ts"],"names":[],"mappings":";;AAwFA,sDAuGC;AA/LD;;;;;GAKG;AACH,6CAUqB;AAGrB,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS,kCAAoB,CAAC,CAAC;AA4B7D,SAAS,YAAY,CAAC,IAAsB;IAC1C,OAAO,IAAI,EAAE,qBAAqB,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAqC;IAC7D,OAAO,GAAG,YAAY,4BAAc,CAAC;AACvC,CAAC;AAED,SAAS,0BAA0B,CACjC,GAA2B,EAC3B,GAAoB;IAEpB,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,yBAAyB,CAChC,GAA2B,EAC3B,GAAmB;IAEnB,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,YAAY,CAAC,IAAkB,EAAE,KAAmC;IAC3E,KAAK,CAAC,IAAI,CAAC,CAAC;IACZ,KAAK,MAAM,KAAK,IA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ACL,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** Managed tier ("HomeGraph AI") — the metered gateway used when logged in. */
|
|
2
|
-
export declare const MANAGED_DEFAULT_URL = "https://ai.gethomegraph.com/v1";
|
|
3
|
-
/** The gateway's public model id (it translates this to the upstream provider id). */
|
|
4
|
-
export declare const MANAGED_DEFAULT_MODEL = "openai/gpt-oss-120b";
|
|
5
|
-
export interface OffloadConfig {
|
|
6
|
-
/** Managed tier: route through HomeGraph AI (metered) with the logged-in org token. */
|
|
7
|
-
managed?: boolean;
|
|
8
|
-
/** OpenAI-compatible base URL ending in `/v1` (e.g. https://api.cerebras.ai/v1). */
|
|
9
|
-
url?: string;
|
|
10
|
-
/** Model id to request (default `gpt-oss-120b` BYO, `openai/gpt-oss-120b` managed). */
|
|
11
|
-
model?: string;
|
|
12
|
-
/** Name of the env var holding the provider API key (never persisted). BYO only. */
|
|
13
|
-
keyEnv?: string;
|
|
14
|
-
/** reasoning_effort: low | medium | high (default `low`). */
|
|
15
|
-
effort?: string;
|
|
16
|
-
/** Output style: plain | report (default `plain`). */
|
|
17
|
-
style?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ResolvedOffload {
|
|
20
|
-
/** True when the offload is usable (endpoint present; for managed, a token too). */
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
/** Managed tier (HomeGraph AI, metered) vs BYO endpoint. */
|
|
23
|
-
managed: boolean;
|
|
24
|
-
url?: string;
|
|
25
|
-
model: string;
|
|
26
|
-
/** Resolved API key / org token (from env, the configured `keyEnv`, or login), if any. */
|
|
27
|
-
apiKey?: string;
|
|
28
|
-
/** Where the key/token came from (for `status` display) — never the secret itself. */
|
|
29
|
-
keySource?: string;
|
|
30
|
-
effort: string;
|
|
31
|
-
style: string;
|
|
32
|
-
timeoutMs: number;
|
|
33
|
-
maxTokens: number;
|
|
34
|
-
strip: boolean;
|
|
35
|
-
debug: boolean;
|
|
36
|
-
/** Where the endpoint came from — drives `homegraph offload status`. */
|
|
37
|
-
origin: 'env' | 'config' | 'none';
|
|
38
|
-
}
|
|
39
|
-
/** The persisted offload block (empty object if none). */
|
|
40
|
-
export declare function readOffloadConfig(): OffloadConfig;
|
|
41
|
-
/** Persist (or, with `null`, clear) the offload block, leaving other config keys intact. */
|
|
42
|
-
export declare function writeOffloadConfig(offload: OffloadConfig | null): void;
|
|
43
|
-
/** Merge the persisted config with `HOMEGRAPH_OFFLOAD_*` env overrides (env wins). */
|
|
44
|
-
export declare function resolveOffload(env?: NodeJS.ProcessEnv): ResolvedOffload;
|
|
45
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/reasoning/config.ts"],"names":[],"mappings":"AAqBA,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AACpE,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,wBAAwB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,uFAAuF;IACvF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oFAAoF;IACpF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACnC;AAsBD,0DAA0D;AAC1D,wBAAgB,iBAAiB,IAAI,aAAa,CAIjD;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAKtE;AAOD,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,eAAe,CAwDpF"}
|
package/dist/reasoning/config.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MANAGED_DEFAULT_MODEL = exports.MANAGED_DEFAULT_URL = void 0;
|
|
37
|
-
exports.readOffloadConfig = readOffloadConfig;
|
|
38
|
-
exports.writeOffloadConfig = writeOffloadConfig;
|
|
39
|
-
exports.resolveOffload = resolveOffload;
|
|
40
|
-
/**
|
|
41
|
-
* Reasoning-offload configuration: the persistent, machine-level settings the
|
|
42
|
-
* `homegraph offload` CLI writes, merged with `HOMEGRAPH_OFFLOAD_*` env overrides.
|
|
43
|
-
*
|
|
44
|
-
* Stored in `~/.homegraph/config.json` under the `offload` key — the same global
|
|
45
|
-
* home HomeGraph already uses for the daemon registry — because the reasoning
|
|
46
|
-
* endpoint is a per-machine choice (the model you bring), not per-project state.
|
|
47
|
-
* Every homegraph MCP server on the machine picks it up, so a user configures it
|
|
48
|
-
* once. Env vars override the file (CI / ephemeral / advanced use).
|
|
49
|
-
*
|
|
50
|
-
* For a BYO endpoint, the API key is NEVER written to disk: the CLI stores the
|
|
51
|
-
* NAME of an env var (`keyEnv`) and reads the key from it at call time. The
|
|
52
|
-
* MANAGED tier ("HomeGraph AI") instead authenticates with a revocable, org-scoped
|
|
53
|
-
* token from `homegraph offload login`, stored separately in `credentials.json`
|
|
54
|
-
* (see ./credentials) — so `config.json` itself never carries a secret either way.
|
|
55
|
-
*/
|
|
56
|
-
const fs = __importStar(require("fs"));
|
|
57
|
-
const path = __importStar(require("path"));
|
|
58
|
-
const os = __importStar(require("os"));
|
|
59
|
-
const credentials_1 = require("./credentials");
|
|
60
|
-
/** Managed tier ("HomeGraph AI") — the metered gateway used when logged in. */
|
|
61
|
-
exports.MANAGED_DEFAULT_URL = 'https://ai.gethomegraph.com/v1';
|
|
62
|
-
/** The gateway's public model id (it translates this to the upstream provider id). */
|
|
63
|
-
exports.MANAGED_DEFAULT_MODEL = 'openai/gpt-oss-120b';
|
|
64
|
-
function configDir() {
|
|
65
|
-
return path.join(os.homedir(), '.homegraph');
|
|
66
|
-
}
|
|
67
|
-
function configPath() {
|
|
68
|
-
return path.join(configDir(), 'config.json');
|
|
69
|
-
}
|
|
70
|
-
function readUserConfig() {
|
|
71
|
-
try {
|
|
72
|
-
return JSON.parse(fs.readFileSync(configPath(), 'utf8'));
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function writeUserConfig(cfg) {
|
|
79
|
-
fs.mkdirSync(configDir(), { recursive: true });
|
|
80
|
-
fs.writeFileSync(configPath(), JSON.stringify(cfg, null, 2) + '\n');
|
|
81
|
-
}
|
|
82
|
-
/** The persisted offload block (empty object if none). */
|
|
83
|
-
function readOffloadConfig() {
|
|
84
|
-
const cfg = readUserConfig();
|
|
85
|
-
const o = cfg.offload;
|
|
86
|
-
return o && typeof o === 'object' ? o : {};
|
|
87
|
-
}
|
|
88
|
-
/** Persist (or, with `null`, clear) the offload block, leaving other config keys intact. */
|
|
89
|
-
function writeOffloadConfig(offload) {
|
|
90
|
-
const cfg = readUserConfig();
|
|
91
|
-
if (offload === null)
|
|
92
|
-
delete cfg.offload;
|
|
93
|
-
else
|
|
94
|
-
cfg.offload = offload;
|
|
95
|
-
writeUserConfig(cfg);
|
|
96
|
-
}
|
|
97
|
-
const trimmed = (v) => {
|
|
98
|
-
const t = v?.trim();
|
|
99
|
-
return t ? t : undefined;
|
|
100
|
-
};
|
|
101
|
-
/** Merge the persisted config with `HOMEGRAPH_OFFLOAD_*` env overrides (env wins). */
|
|
102
|
-
function resolveOffload(env = process.env) {
|
|
103
|
-
// Hard kill-switch: disable the offload for this process/session without touching
|
|
104
|
-
// the persisted config or the stored login — e.g. one A/B arm, or a user who wants
|
|
105
|
-
// homegraph_explore to return raw source for a session. Env-only by design.
|
|
106
|
-
if (env.HOMEGRAPH_OFFLOAD_DISABLE === '1') {
|
|
107
|
-
return {
|
|
108
|
-
enabled: false, managed: false, url: undefined, model: exports.MANAGED_DEFAULT_MODEL,
|
|
109
|
-
apiKey: undefined, keySource: undefined, effort: 'low', style: 'plain',
|
|
110
|
-
timeoutMs: 20000, maxTokens: 12000, strip: false,
|
|
111
|
-
debug: env.HOMEGRAPH_OFFLOAD_DEBUG === '1', origin: 'none',
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
const c = readOffloadConfig();
|
|
115
|
-
const managed = !!c.managed;
|
|
116
|
-
const envUrl = trimmed(env.HOMEGRAPH_OFFLOAD_URL);
|
|
117
|
-
const envKey = trimmed(env.HOMEGRAPH_OFFLOAD_KEY);
|
|
118
|
-
let url;
|
|
119
|
-
let apiKey;
|
|
120
|
-
let keySource;
|
|
121
|
-
let model;
|
|
122
|
-
if (managed) {
|
|
123
|
-
// Managed tier: default to the HomeGraph AI gateway + its public model id; the
|
|
124
|
-
// bearer is the org token from `homegraph offload login` (or an env override).
|
|
125
|
-
url = envUrl ?? trimmed(c.url) ?? exports.MANAGED_DEFAULT_URL;
|
|
126
|
-
model = trimmed(env.HOMEGRAPH_OFFLOAD_MODEL) ?? trimmed(c.model) ?? exports.MANAGED_DEFAULT_MODEL;
|
|
127
|
-
if (envKey) {
|
|
128
|
-
apiKey = envKey;
|
|
129
|
-
keySource = 'HOMEGRAPH_OFFLOAD_KEY';
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
const t = (0, credentials_1.readOffloadToken)();
|
|
133
|
-
if (t) {
|
|
134
|
-
apiKey = t;
|
|
135
|
-
keySource = 'homegraph login';
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
// BYO: endpoint + (optional) provider key resolved from env or the named env var.
|
|
141
|
-
url = envUrl ?? trimmed(c.url);
|
|
142
|
-
model = trimmed(env.HOMEGRAPH_OFFLOAD_MODEL) ?? trimmed(c.model) ?? 'gpt-oss-120b';
|
|
143
|
-
if (envKey) {
|
|
144
|
-
apiKey = envKey;
|
|
145
|
-
keySource = 'HOMEGRAPH_OFFLOAD_KEY';
|
|
146
|
-
}
|
|
147
|
-
else if (c.keyEnv && trimmed(env[c.keyEnv])) {
|
|
148
|
-
apiKey = trimmed(env[c.keyEnv]);
|
|
149
|
-
keySource = c.keyEnv;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const origin = envUrl ? 'env' : (managed || trimmed(c.url)) ? 'config' : 'none';
|
|
153
|
-
return {
|
|
154
|
-
// Managed needs both an endpoint AND a token (no token → effectively logged out);
|
|
155
|
-
// BYO needs only an endpoint (some endpoints require no auth).
|
|
156
|
-
enabled: managed ? (!!url && !!apiKey) : !!url,
|
|
157
|
-
managed,
|
|
158
|
-
url,
|
|
159
|
-
model,
|
|
160
|
-
apiKey,
|
|
161
|
-
keySource,
|
|
162
|
-
effort: trimmed(env.HOMEGRAPH_OFFLOAD_EFFORT) ?? trimmed(c.effort) ?? 'low',
|
|
163
|
-
style: trimmed(env.HOMEGRAPH_OFFLOAD_STYLE) ?? trimmed(c.style) ?? 'plain',
|
|
164
|
-
timeoutMs: Number(env.HOMEGRAPH_OFFLOAD_TIMEOUT_MS) || 20000,
|
|
165
|
-
maxTokens: Number(env.HOMEGRAPH_OFFLOAD_MAXTOKENS) || 12000,
|
|
166
|
-
strip: env.HOMEGRAPH_OFFLOAD_STRIP === '1',
|
|
167
|
-
debug: env.HOMEGRAPH_OFFLOAD_DEBUG === '1',
|
|
168
|
-
origin,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/reasoning/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,8CAIC;AAGD,gDAKC;AAQD,wCAwDC;AA/JD;;;;;;;;;;;;;;;GAeG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,+CAAiD;AAEjD,+EAA+E;AAClE,QAAA,mBAAmB,GAAG,gCAAgC,CAAC;AACpE,sFAAsF;AACzE,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAsC3D,SAAS,SAAS;IAChB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC/C,CAAC;AACD,SAAS,UAAU;IACjB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAA4B,CAAC;IACtF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,GAA4B;IACnD,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,0DAA0D;AAC1D,SAAgB,iBAAiB;IAC/B,MAAM,GAAG,GAAG,cAAc,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C,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YAAC,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;QAAC,CAAC;IACzG,CAAC;IAED,MAAM,MAAM,GAA8B,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3G,OAAO;QACL,kFAAkF;QAClF,+DAA+D;QAC/D,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QAC9C,OAAO;QACP,GAAG;QACH,KAAK;QACL,MAAM;QACN,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK;QAC3E,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO;QAC1E,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,KAAK;QAC5D,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,KAAK;QAC3D,KAAK,EAAE,GAAG,CAAC,uBAAuB,KAAK,GAAG;QAC1C,KAAK,EAAE,GAAG,CAAC,uBAAuB,KAAK,GAAG;QAC1C,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** The stored managed-offload org token, if the machine is logged in. */
|
|
2
|
-
export declare function readOffloadToken(): string | undefined;
|
|
3
|
-
/** Persist (or, with `null`, clear) the managed-offload org token at `0600`. */
|
|
4
|
-
export declare function writeOffloadToken(token: string | null): void;
|
|
5
|
-
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/reasoning/credentials.ts"],"names":[],"mappings":"AA0BA,yEAAyE;AACzE,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAGrD;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAS5D"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.readOffloadToken = readOffloadToken;
|
|
37
|
-
exports.writeOffloadToken = writeOffloadToken;
|
|
38
|
-
/**
|
|
39
|
-
* Managed-offload credentials: the HomeGraph org token that authenticates the
|
|
40
|
-
* managed reasoning tier against `homegraph-ai` (the metered gateway).
|
|
41
|
-
*
|
|
42
|
-
* Unlike a BYO provider key (which is never persisted — the config stores only the
|
|
43
|
-
* NAME of an env var), the org token IS a revocable, org-scoped auth token issued
|
|
44
|
-
* to this machine — like the token `gh auth` or `npm login` stores. So it lives in
|
|
45
|
-
* its own file, `~/.homegraph/credentials.json`, written `0600`, kept out of the
|
|
46
|
-
* shareable `config.json`.
|
|
47
|
-
*/
|
|
48
|
-
const fs = __importStar(require("fs"));
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const os = __importStar(require("os"));
|
|
51
|
-
function credentialsPath() {
|
|
52
|
-
return path.join(os.homedir(), '.homegraph', 'credentials.json');
|
|
53
|
-
}
|
|
54
|
-
function read() {
|
|
55
|
-
try {
|
|
56
|
-
return JSON.parse(fs.readFileSync(credentialsPath(), 'utf8'));
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return {};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/** The stored managed-offload org token, if the machine is logged in. */
|
|
63
|
-
function readOffloadToken() {
|
|
64
|
-
const t = read().offloadToken;
|
|
65
|
-
return typeof t === 'string' && t.trim() ? t.trim() : undefined;
|
|
66
|
-
}
|
|
67
|
-
/** Persist (or, with `null`, clear) the managed-offload org token at `0600`. */
|
|
68
|
-
function writeOffloadToken(token) {
|
|
69
|
-
const p = credentialsPath();
|
|
70
|
-
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
71
|
-
const creds = read();
|
|
72
|
-
if (token === null)
|
|
73
|
-
delete creds.offloadToken;
|
|
74
|
-
else
|
|
75
|
-
creds.offloadToken = token;
|
|
76
|
-
// Write restrictively: create at 0600, and tighten an existing file too.
|
|
77
|
-
fs.writeFileSync(p, JSON.stringify(creds, null, 2) + '\n', { mode: 0o600 });
|
|
78
|
-
try {
|
|
79
|
-
fs.chmodSync(p, 0o600);
|
|
80
|
-
}
|
|
81
|
-
catch { /* best-effort on platforms without POSIX modes */ }
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/reasoning/credentials.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,4CAGC;AAGD,8CASC;AA1CD;;;;;;;;;GASG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,SAAS,eAAe;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,IAAI;IACX,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,MAAM,CAAC,CAA4B,CAAC;IAC3F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,SAAgB,gBAAgB;IAC9B,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,YAAY,CAAC;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,gFAAgF;AAChF,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,MAAM,CAAC,GAAG,eAAe,EAAE,CAAC;IAC5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,EAAE,CAAC;IACrB,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC,YAAY,CAAC;;QACzC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;IAChC,yEAAyE;IACzE,EAAE,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC;QAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,kDAAkD,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Dashboard base for the device-login endpoints; override for testing via HOMEGRAPH_LOGIN_URL. */
|
|
2
|
-
export declare function loginBaseUrl(): string;
|
|
3
|
-
/** The dashboard's response to a device-authorization start request. */
|
|
4
|
-
export interface DeviceStart {
|
|
5
|
-
device_code: string;
|
|
6
|
-
user_code: string;
|
|
7
|
-
verification_uri: string;
|
|
8
|
-
/** Same URL with the code prefilled, for one-click open. */
|
|
9
|
-
verification_uri_complete?: string;
|
|
10
|
-
/** Seconds the CLI should wait between polls. */
|
|
11
|
-
interval?: number;
|
|
12
|
-
/** Seconds until the request expires. */
|
|
13
|
-
expires_in?: number;
|
|
14
|
-
}
|
|
15
|
-
/** Begin a device-authorization request. */
|
|
16
|
-
export declare function startDeviceLogin(): Promise<DeviceStart>;
|
|
17
|
-
/** Poll until the user approves in the browser; resolves with the org token. */
|
|
18
|
-
export declare function pollForToken(deviceCode: string, intervalSec: number, expiresInSec: number): Promise<string>;
|
|
19
|
-
/** Best-effort: open a URL in the default browser. Never throws — the URL is also printed. */
|
|
20
|
-
export declare function openBrowser(url: string): Promise<void>;
|
|
21
|
-
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/reasoning/login.ts"],"names":[],"mappings":"AAeA,mGAAmG;AACnG,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,4CAA4C;AAC5C,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC,CAY7D;AAED,gFAAgF;AAChF,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBjH;AAED,8FAA8F;AAC9F,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5D"}
|
package/dist/reasoning/login.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loginBaseUrl = loginBaseUrl;
|
|
4
|
-
exports.startDeviceLogin = startDeviceLogin;
|
|
5
|
-
exports.pollForToken = pollForToken;
|
|
6
|
-
exports.openBrowser = openBrowser;
|
|
7
|
-
/**
|
|
8
|
-
* Managed-login device flow for `homegraph login`.
|
|
9
|
-
*
|
|
10
|
-
* Opens the user's browser to the HomeGraph dashboard, where they authorize with
|
|
11
|
-
* their account; the CLI meanwhile polls for the minted, org-scoped token and
|
|
12
|
-
* stores it (see ./credentials + ./config) to turn on managed reasoning.
|
|
13
|
-
*
|
|
14
|
-
* This talks to the DASHBOARD (app.gethomegraph.com), not the metered gateway —
|
|
15
|
-
* it's a plain OAuth-style device handshake (RFC 8628 shape), nothing proprietary.
|
|
16
|
-
* The resulting token is what authenticates the managed reasoning calls (./reasoner).
|
|
17
|
-
*/
|
|
18
|
-
const child_process_1 = require("child_process");
|
|
19
|
-
const DEFAULT_BASE = 'https://app.gethomegraph.com';
|
|
20
|
-
/** Dashboard base for the device-login endpoints; override for testing via HOMEGRAPH_LOGIN_URL. */
|
|
21
|
-
function loginBaseUrl() {
|
|
22
|
-
const raw = process.env.HOMEGRAPH_LOGIN_URL?.trim() || DEFAULT_BASE;
|
|
23
|
-
return raw.replace(/\/+$/, '');
|
|
24
|
-
}
|
|
25
|
-
/** Begin a device-authorization request. */
|
|
26
|
-
async function startDeviceLogin() {
|
|
27
|
-
const base = loginBaseUrl();
|
|
28
|
-
const res = await fetch(`${base}/api/cli/device/start`, {
|
|
29
|
-
method: 'POST',
|
|
30
|
-
headers: { 'content-type': 'application/json' },
|
|
31
|
-
body: '{}',
|
|
32
|
-
}).catch(() => null);
|
|
33
|
-
if (!res)
|
|
34
|
-
throw new Error(`couldn't reach ${base} — check your connection`);
|
|
35
|
-
if (!res.ok)
|
|
36
|
-
throw new Error(`couldn't start login (HTTP ${res.status})`);
|
|
37
|
-
const j = (await res.json().catch(() => null));
|
|
38
|
-
if (!j?.device_code || !j.user_code)
|
|
39
|
-
throw new Error('login start returned an unexpected response');
|
|
40
|
-
return j;
|
|
41
|
-
}
|
|
42
|
-
/** Poll until the user approves in the browser; resolves with the org token. */
|
|
43
|
-
async function pollForToken(deviceCode, intervalSec, expiresInSec) {
|
|
44
|
-
const deadline = Date.now() + Math.max(30, expiresInSec || 600) * 1000;
|
|
45
|
-
let waitMs = Math.max(2, intervalSec || 5) * 1000;
|
|
46
|
-
const base = loginBaseUrl();
|
|
47
|
-
while (Date.now() < deadline) {
|
|
48
|
-
await new Promise((r) => setTimeout(r, waitMs));
|
|
49
|
-
const res = await fetch(`${base}/api/cli/device/token`, {
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: { 'content-type': 'application/json' },
|
|
52
|
-
body: JSON.stringify({ device_code: deviceCode }),
|
|
53
|
-
}).catch(() => null);
|
|
54
|
-
if (!res)
|
|
55
|
-
continue; // transient network blip — keep polling until the deadline
|
|
56
|
-
if (res.status === 200) {
|
|
57
|
-
const j = (await res.json().catch(() => null));
|
|
58
|
-
if (j?.token)
|
|
59
|
-
return j.token;
|
|
60
|
-
}
|
|
61
|
-
else if (res.status === 429) {
|
|
62
|
-
waitMs += 2000; // server asked us to slow down
|
|
63
|
-
}
|
|
64
|
-
else if (res.status === 404 || res.status === 410) {
|
|
65
|
-
throw new Error('the login request expired — run `homegraph login` again');
|
|
66
|
-
}
|
|
67
|
-
// 202 (authorization pending) → keep waiting
|
|
68
|
-
}
|
|
69
|
-
throw new Error('login timed out before you approved — run `homegraph login` again');
|
|
70
|
-
}
|
|
71
|
-
/** Best-effort: open a URL in the default browser. Never throws — the URL is also printed. */
|
|
72
|
-
async function openBrowser(url) {
|
|
73
|
-
const [cmd, args] = process.platform === 'darwin' ? ['open', [url]]
|
|
74
|
-
: process.platform === 'win32' ? ['cmd', ['/c', 'start', '', url]]
|
|
75
|
-
: ['xdg-open', [url]];
|
|
76
|
-
try {
|
|
77
|
-
const child = (0, child_process_1.spawn)(cmd, args, { stdio: 'ignore', detached: true, windowsHide: true });
|
|
78
|
-
child.on('error', () => { });
|
|
79
|
-
child.unref();
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
/* the URL is printed for manual open */
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=login.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/reasoning/login.ts"],"names":[],"mappings":";;AAgBA,oCAGC;AAgBD,4CAYC;AAGD,oCAuBC;AAGD,kCAYC;AAxFD;;;;;;;;;;GAUG;AACH,iDAAsC;AAEtC,MAAM,YAAY,GAAG,8BAA8B,CAAC;AAEpD,mGAAmG;AACnG,SAAgB,YAAY;IAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,YAAY,CAAC;IACpE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAeD,4CAA4C;AACrC,KAAK,UAAU,gBAAgB;IACpC,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,uBAAuB,EAAE;QACtD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI;KACX,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,0BAA0B,CAAC,CAAC;IAC5E,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1E,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAuB,CAAC;IACrE,IAAI,CAAC,CAAC,EAAE,WAAW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|
|
5
|
-
/** True when a reasoning offload endpoint is configured (env or `~/.homegraph/config.json`). */
|
|
6
|
-
export declare function isOffloadEnabled(): boolean;
|
|
7
|
-
export interface OffloadUsage {
|
|
8
|
-
plan?: string;
|
|
9
|
-
allowance?: number;
|
|
10
|
-
used?: number;
|
|
11
|
-
overage?: number;
|
|
12
|
-
remaining?: number;
|
|
13
|
-
periodEnd?: number;
|
|
14
|
-
unlimited?: boolean;
|
|
15
|
-
banned?: boolean;
|
|
16
|
-
tokensLast30?: number;
|
|
17
|
-
callsLast30?: number;
|
|
18
|
-
creditsLast30?: number;
|
|
19
|
-
models?: string[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* GET `/v1/usage` from the configured (managed) endpoint → the org's credit
|
|
23
|
-
* balance/usage, or null on any failure. Drives `homegraph offload status`.
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchUsage(): Promise<OffloadUsage | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Strip sections of the explore output addressed to the AGENT (not useful to a
|
|
28
|
-
* reasoning model): the "Not shown above" pointer list, the completeness signal,
|
|
29
|
-
* the explore-budget note, the trimmed/truncation notices, and the redundant
|
|
30
|
-
* "## Exploration:/Found N symbols" header (the query is sent separately). Left
|
|
31
|
-
* in, some models regurgitate them ("We have 2 explore calls. Let's explore…")
|
|
32
|
-
* and they add noise. Source code, blast radius, relationships, and flow stay.
|
|
33
|
-
* Opt-in (`HOMEGRAPH_OFFLOAD_STRIP=1`) — default off (it also removes the "Not
|
|
34
|
-
* shown above" pointers, which can be useful navigation).
|
|
35
|
-
*/
|
|
36
|
-
export declare function stripAgentDirectives(context: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Offload reasoning over the retrieved `context` to the configured model and
|
|
39
|
-
* return its synthesized answer, or null to signal "fall back to local source".
|
|
40
|
-
*/
|
|
41
|
-
export declare function synthesizeOffload({ query, context }: SynthArgs): Promise<string | null>;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=reasoner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reasoner.d.ts","sourceRoot":"","sources":["../../src/reasoning/reasoner.ts"],"names":[],"mappings":"AAiCA,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAmB/D;AA6ED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuB5D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwF7F"}
|