@chengxianglibra/dsh-data-analysis 0.1.1 → 0.1.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/README.md +83 -34
- package/lib/bin/environment.js +1 -1
- package/lib/bin/presentation-lint.js +21 -0
- package/lib/bridges.js +2 -2
- package/lib/client/credentials/create-datasource.js +67 -0
- package/lib/client/credentials/install.js +191 -0
- package/lib/client/credentials/model.js +494 -0
- package/lib/client/credentials/styles.js +17 -0
- package/lib/client/workspace-header-action.js +11 -0
- package/lib/client.js +1133 -736
- package/lib/compatibility.js +1 -1
- package/lib/datasource/authoring.js +70 -0
- package/lib/datasource/bridge-programs.js +30 -18
- package/lib/datasource/bridge.js +100 -8
- package/lib/datasource/index.js +3 -2
- package/lib/datasource/python.js +115 -0
- package/lib/datasource/resolver-program.js +112 -0
- package/lib/datasource/rpc.js +88 -0
- package/lib/datasource/service.js +687 -0
- package/lib/datasource/shell-env.js +2 -333
- package/lib/datasource/test.js +24 -51
- package/lib/environment/binding.js +54 -9
- package/lib/environment/runtime.js +89 -78
- package/lib/environment/subprocess.js +6 -1
- package/lib/environment/summary.js +3 -3
- package/lib/environment/workspace.js +5 -0
- package/lib/index.js +1 -1
- package/lib/plugin.js +168 -51
- package/lib/presentation/assets/portable.js +606 -0
- package/lib/presentation/assets/static.js +945 -0
- package/lib/presentation/build/index.js +71 -0
- package/lib/presentation/commit.js +156 -0
- package/lib/presentation/contracts/charts.js +476 -0
- package/lib/presentation/contracts/editing.js +58 -0
- package/lib/presentation/contracts/index.js +651 -0
- package/lib/presentation/contracts/interaction.js +62 -0
- package/lib/presentation/contracts/types.js +15 -0
- package/lib/presentation/contracts/values.js +28 -0
- package/lib/presentation/delivery.js +56 -0
- package/lib/presentation/files.js +83 -0
- package/lib/presentation/index.js +6 -0
- package/lib/presentation/lint.js +46 -0
- package/lib/presentation/projection/files.js +85 -0
- package/lib/presentation/projection/index.js +195 -0
- package/lib/presentation/projection/program.js +144 -0
- package/lib/presentation/projection/sql-code.js +79 -0
- package/lib/presentation/receipt.js +34 -0
- package/lib/presentation/reports.js +122 -0
- package/lib/presentation/rpc.js +148 -0
- package/lib/presentation/tool.js +122 -0
- package/lib/python-execution-contracts.js +1 -0
- package/lib/python-execution.js +232 -0
- package/lib/semantic-browser/contracts.js +80 -0
- package/lib/semantic-browser/definition.js +64 -0
- package/lib/semantic-browser/program.js +119 -0
- package/lib/semantic-browser/service.js +72 -0
- package/lib/semantic-reference/bridge.js +118 -0
- package/lib/semantic-reference/contracts.js +113 -0
- package/lib/semantic-reference/index.js +3 -0
- package/lib/semantic-reference/rpc.js +122 -0
- package/lib/semantic-reference/search.js +94 -0
- package/lib/semantic-reference/usage.js +143 -0
- package/lib/types/bridges.d.ts +2 -2
- package/lib/types/client/credentials/create-datasource.d.ts +5 -0
- package/lib/types/client/credentials/install.d.ts +1 -0
- package/lib/types/client/credentials/model.d.ts +59 -0
- package/lib/types/client/credentials/styles.d.ts +1 -0
- package/lib/types/client/presentation/ask-dsh.d.ts +9 -0
- package/lib/types/client/presentation/chart-explorer.d.ts +12 -0
- package/lib/types/client/presentation/chart-geometry.d.ts +30 -0
- package/lib/types/client/presentation/chart-renderer.d.ts +10 -0
- package/lib/types/client/presentation/chart-specials.d.ts +10 -0
- package/lib/types/client/presentation/chart-styles.d.ts +1 -0
- package/lib/types/client/presentation/chart-tooltip.d.ts +13 -0
- package/lib/types/client/presentation/chart-view.d.ts +23 -0
- package/lib/types/client/presentation/copy-context.d.ts +5 -0
- package/lib/types/client/presentation/delivery-model.d.ts +54 -0
- package/lib/types/client/presentation/delivery.d.ts +77 -0
- package/lib/types/client/presentation/editor-controls.d.ts +12 -0
- package/lib/types/client/presentation/global-filters.d.ts +6 -0
- package/lib/types/client/presentation/host-entry.d.ts +12 -0
- package/lib/types/client/presentation/icons.d.ts +4 -0
- package/lib/types/client/presentation/install.d.ts +15 -0
- package/lib/types/client/presentation/markdown.d.ts +5 -0
- package/lib/types/client/presentation/model.d.ts +62 -0
- package/lib/types/client/presentation/reader.d.ts +11 -0
- package/lib/types/client/presentation/source-code-model.d.ts +16 -0
- package/lib/types/client/presentation/source-code.d.ts +11 -0
- package/lib/types/client/presentation/source-dialog.d.ts +13 -0
- package/lib/types/client/presentation/source-facts.d.ts +20 -0
- package/lib/types/client/presentation/source-format.d.ts +5 -0
- package/lib/types/client/presentation/source-highlight.d.ts +7 -0
- package/lib/types/client/presentation/sources.d.ts +13 -0
- package/lib/types/client/presentation/styles.d.ts +1 -0
- package/lib/types/client/presentation/table.d.ts +12 -0
- package/lib/types/client/presentation/use-element-width.d.ts +5 -0
- package/lib/types/client/workspace-header-action.d.ts +7 -0
- package/lib/types/client.d.ts +4 -122
- package/lib/types/compatibility.d.ts +2 -2
- package/lib/types/datasource/authoring.d.ts +25 -0
- package/lib/types/datasource/bridge.d.ts +21 -3
- package/lib/types/datasource/index.d.ts +3 -5
- package/lib/types/datasource/python.d.ts +4 -0
- package/lib/types/datasource/resolver-program.d.ts +6 -0
- package/lib/types/datasource/rpc.d.ts +4 -0
- package/lib/types/datasource/service.d.ts +112 -0
- package/lib/types/datasource/shell-env.d.ts +0 -29
- package/lib/types/datasource/test.d.ts +6 -29
- package/lib/types/environment/binding.d.ts +5 -1
- package/lib/types/environment/errors.d.ts +1 -1
- package/lib/types/environment/runtime.d.ts +5 -5
- package/lib/types/environment/types.d.ts +13 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/plugin.d.ts +11 -5
- package/lib/types/presentation/build/index.d.ts +11 -0
- package/lib/types/presentation/commit.d.ts +4 -0
- package/lib/types/presentation/contracts/charts.d.ts +13 -0
- package/lib/types/presentation/contracts/editing.d.ts +8 -0
- package/lib/types/presentation/contracts/index.d.ts +11 -0
- package/lib/types/presentation/contracts/interaction.d.ts +8 -0
- package/lib/types/presentation/contracts/types.d.ts +252 -0
- package/lib/types/presentation/contracts/values.d.ts +9 -0
- package/lib/types/presentation/delivery.d.ts +3 -0
- package/lib/types/presentation/files.d.ts +7 -0
- package/lib/types/presentation/index.d.ts +6 -0
- package/lib/types/presentation/lint.d.ts +13 -0
- package/lib/types/presentation/projection/files.d.ts +2 -0
- package/lib/types/presentation/projection/index.d.ts +20 -0
- package/lib/types/presentation/projection/program.d.ts +2 -0
- package/lib/types/presentation/projection/sql-code.d.ts +2 -0
- package/lib/types/presentation/receipt.d.ts +14 -0
- package/lib/types/presentation/reports.d.ts +5 -0
- package/lib/types/presentation/rpc.d.ts +24 -0
- package/lib/types/presentation/tool.d.ts +12 -0
- package/lib/types/python-execution-contracts.d.ts +10 -0
- package/lib/types/python-execution.d.ts +10 -0
- package/lib/types/semantic-browser/contracts.d.ts +40 -0
- package/lib/types/semantic-browser/definition.d.ts +20 -0
- package/lib/types/semantic-browser/program.d.ts +2 -0
- package/lib/types/semantic-browser/service.d.ts +20 -0
- package/lib/types/semantic-reference/bridge.d.ts +11 -0
- package/lib/types/semantic-reference/contracts.d.ts +51 -0
- package/lib/types/semantic-reference/index.d.ts +3 -0
- package/lib/types/semantic-reference/rpc.d.ts +15 -0
- package/lib/types/semantic-reference/search.d.ts +10 -0
- package/lib/types/semantic-reference/usage.d.ts +43 -0
- package/package.json +43 -19
- package/python/presentation-kit/dist/dsh_data_analysis_presentation_kit-1.1.0-py3-none-any.whl +0 -0
- package/skills/dsh-data-analysis-presentation/SKILL.md +24 -0
- package/skills/dsh-data-analysis-presentation/references/chart-examples.md +18 -0
- package/skills/dsh-data-analysis-presentation/references/charts.md +55 -0
- package/skills/dsh-data-analysis-presentation/references/examples/artifact.draft.json +27 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-bins.dataset.json +33 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-boxes.dataset.json +45 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-composition.dataset.json +33 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-funnel.dataset.json +27 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-precision.dataset.json +21 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-series.dataset.json +58 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-shares.dataset.json +33 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts-waterfall.dataset.json +44 -0
- package/skills/dsh-data-analysis-presentation/references/examples/charts.draft.json +392 -0
- package/skills/dsh-data-analysis-presentation/references/examples/comparison-selected.dataset.json +24 -0
- package/skills/dsh-data-analysis-presentation/references/examples/comparison-summary.dataset.json +22 -0
- package/skills/dsh-data-analysis-presentation/references/examples/comparison.dataset.json +18 -0
- package/skills/dsh-data-analysis-presentation/references/examples/comparison.draft.json +79 -0
- package/skills/dsh-data-analysis-presentation/references/examples/computed-sources.draft.json +35 -0
- package/skills/dsh-data-analysis-presentation/references/examples/computed.dataset.json +12 -0
- package/skills/dsh-data-analysis-presentation/references/examples/computed.draft.json +57 -0
- package/skills/dsh-data-analysis-presentation/references/examples/interaction-detail.dataset.json +30 -0
- package/skills/dsh-data-analysis-presentation/references/examples/interaction-summary.dataset.json +22 -0
- package/skills/dsh-data-analysis-presentation/references/examples/interaction.draft.json +278 -0
- package/skills/dsh-data-analysis-presentation/references/examples/source-only.draft.json +19 -0
- package/skills/dsh-data-analysis-presentation/references/examples/write-charts.py +73 -0
- package/skills/dsh-data-analysis-presentation/references/examples/write-comparison.py +42 -0
- package/skills/dsh-data-analysis-presentation/references/examples/write-computed.py +21 -0
- package/skills/dsh-data-analysis-presentation/references/examples/write-interaction.py +33 -0
- package/skills/dsh-data-analysis-presentation/references/examples.md +42 -0
- package/skills/dsh-data-analysis-presentation/references/interaction.md +56 -0
- package/skills/dsh-data-analysis-presentation/references/narrative.md +37 -0
- package/skills/dsh-data-analysis-presentation/references/schema.md +138 -0
- package/lib/datasource/access.js +0 -60
- package/lib/datasource/credentials.js +0 -24
- package/lib/evidence/bridge-program.js +0 -153
- package/lib/evidence/bridge.js +0 -166
- package/lib/evidence/index.js +0 -2
- package/lib/evidence/sources.js +0 -263
- package/lib/types/datasource/access.d.ts +0 -27
- package/lib/types/evidence/bridge.d.ts +0 -40
- package/lib/types/evidence/index.d.ts +0 -4
- package/lib/types/evidence/sources.d.ts +0 -57
- package/python/report-kit/dist/dsh_data_analysis_report_kit-3.0.0-py3-none-any.whl +0 -0
- package/skills/dsh-data-analysis-report/SKILL.md +0 -57
- package/skills/dsh-data-analysis-report/assets/marivo-artifact.js +0 -113
- package/skills/dsh-data-analysis-report/assets/marivo-session-dag.js +0 -1201
- package/skills/dsh-data-analysis-report/assets/report-data.js +0 -449
|
@@ -11,38 +11,41 @@ import { FixedSubprocessPolicy } from "./subprocess.js";
|
|
|
11
11
|
export const SHARED_PYTHON_SPEC = '3.10';
|
|
12
12
|
const PINNED_MARIVO_VERSION = MARIVO_VERSION;
|
|
13
13
|
export const SHARED_MARIVO_PACKAGE_SPEC = MARIVO_PACKAGE_SPEC;
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
14
|
+
export const PRESENTATION_KIT_DISTRIBUTION = 'dsh-data-analysis-presentation-kit';
|
|
15
|
+
export const PRESENTATION_KIT_VERSION = '1.1.0';
|
|
16
|
+
export const PRESENTATION_KIT_PANDAS_RANGE = '>=2.2.0,<3.0.0';
|
|
17
|
+
export const PRESENTATION_KIT_WHEEL_FILENAME = 'dsh_data_analysis_presentation_kit-1.1.0-py3-none-any.whl';
|
|
18
18
|
export const DEFAULT_SHARED_RUNTIME_INSTALL_TIMEOUT_MS = 600_000;
|
|
19
19
|
const INSTALLATION_SCHEMA = RUNTIME_INSTALLATION_VERSION;
|
|
20
20
|
const INSTALLATION_FILENAME = 'installation.json';
|
|
21
21
|
const SKILL_NAMES = ['marivo-analysis', 'marivo-semantic'];
|
|
22
|
-
const REPORT_ADAPTER_KIND = 'dsh-data-analysis-report-transport-adapter';
|
|
23
22
|
const PROBE_SCRIPT = String.raw `
|
|
24
23
|
import json
|
|
25
24
|
import os
|
|
26
25
|
import sys
|
|
26
|
+
from importlib.metadata import distribution
|
|
27
27
|
import marivo
|
|
28
|
+
from marivo.semantic.definition import SemanticDefinition
|
|
28
29
|
import pandas
|
|
29
|
-
import
|
|
30
|
+
import dsh_data_analysis_presentation
|
|
30
31
|
from packaging.specifiers import SpecifierSet
|
|
31
32
|
from packaging.version import Version
|
|
32
33
|
|
|
34
|
+
presentation_distribution = distribution("dsh-data-analysis-presentation-kit")
|
|
35
|
+
|
|
33
36
|
print(json.dumps({
|
|
34
37
|
"python_executable": os.path.abspath(sys.executable),
|
|
35
38
|
"marivo_version": marivo.__version__,
|
|
36
39
|
"package_path": os.path.abspath(marivo.__file__ or ""),
|
|
37
40
|
"pandas_version": pandas.__version__,
|
|
38
41
|
"pandas_supported": Version(pandas.__version__) in SpecifierSet(">=2.2.0,<3.0.0"),
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
42
|
+
"presentation_kit_version": dsh_data_analysis_presentation.__version__,
|
|
43
|
+
"presentation_kit_distribution_version": presentation_distribution.version,
|
|
44
|
+
"presentation_kit_package_path": os.path.abspath(dsh_data_analysis_presentation.__file__ or ""),
|
|
45
|
+
"presentation_kit_import_identity": os.path.realpath(dsh_data_analysis_presentation.__file__ or "") == os.path.realpath(
|
|
46
|
+
presentation_distribution.locate_file("dsh_data_analysis_presentation/__init__.py")
|
|
47
|
+
),
|
|
48
|
+
"presentation_kit_public_imports": callable(dsh_data_analysis_presentation.write_dataset),
|
|
46
49
|
}, sort_keys=True))
|
|
47
50
|
`.trim();
|
|
48
51
|
const PYTHON_VERSION_SCRIPT = String.raw `
|
|
@@ -56,8 +59,8 @@ print(json.dumps({
|
|
|
56
59
|
"prefix": os.path.abspath(sys.prefix),
|
|
57
60
|
}, sort_keys=True))
|
|
58
61
|
`.trim();
|
|
59
|
-
function administratorRepair(executable,
|
|
60
|
-
const dependencies = [SHARED_MARIVO_PACKAGE_SPEC, `pandas${
|
|
62
|
+
function administratorRepair(executable, presentationKitWheel) {
|
|
63
|
+
const dependencies = [SHARED_MARIVO_PACKAGE_SPEC, `pandas${PRESENTATION_KIT_PANDAS_RANGE}`];
|
|
61
64
|
const commands = [
|
|
62
65
|
{
|
|
63
66
|
executable,
|
|
@@ -65,7 +68,7 @@ function administratorRepair(executable, reportKitWheel) {
|
|
|
65
68
|
},
|
|
66
69
|
{
|
|
67
70
|
executable,
|
|
68
|
-
args: ['-m', 'pip', 'install', '--no-deps',
|
|
71
|
+
args: ['-m', 'pip', 'install', '--no-deps', presentationKitWheel],
|
|
69
72
|
},
|
|
70
73
|
];
|
|
71
74
|
const commandText = (command) => [command.executable, ...command.args].map((value) => JSON.stringify(value)).join(' ');
|
|
@@ -90,22 +93,22 @@ function normalizeAbsolute(name, value) {
|
|
|
90
93
|
function defaultRuntimeRoot() {
|
|
91
94
|
return path.join(resolveDshHome(), 'dsh-data-analysis', 'runtimes', 'marivo');
|
|
92
95
|
}
|
|
93
|
-
function
|
|
94
|
-
return fileURLToPath(new URL(`../../python/
|
|
96
|
+
function bundledPresentationKitWheel() {
|
|
97
|
+
return fileURLToPath(new URL(`../../python/presentation-kit/dist/${PRESENTATION_KIT_WHEEL_FILENAME}`, import.meta.url));
|
|
95
98
|
}
|
|
96
|
-
async function
|
|
99
|
+
async function assertPresentationKitWheel(filename) {
|
|
97
100
|
const selected = path.normalize(path.resolve(filename));
|
|
98
|
-
if (path.basename(selected) !==
|
|
99
|
-
throw new MarivoEnvironmentError('shared-runtime-
|
|
101
|
+
if (path.basename(selected) !== PRESENTATION_KIT_WHEEL_FILENAME) {
|
|
102
|
+
throw new MarivoEnvironmentError('shared-runtime-presentation-kit-wheel-invalid', `Bundled presentation-kit wheel must be named ${PRESENTATION_KIT_WHEEL_FILENAME}`, { expectedWheel: PRESENTATION_KIT_WHEEL_FILENAME, actualWheel: path.basename(selected) });
|
|
100
103
|
}
|
|
101
104
|
try {
|
|
102
105
|
if (!(await stat(selected)).isFile())
|
|
103
106
|
throw new Error('not a file');
|
|
104
107
|
}
|
|
105
108
|
catch (cause) {
|
|
106
|
-
throw new MarivoEnvironmentError('shared-runtime-
|
|
107
|
-
distribution:
|
|
108
|
-
version:
|
|
109
|
+
throw new MarivoEnvironmentError('shared-runtime-presentation-kit-wheel-unavailable', `Bundled presentation-kit wheel is unavailable: ${selected}`, {
|
|
110
|
+
distribution: PRESENTATION_KIT_DISTRIBUTION,
|
|
111
|
+
version: PRESENTATION_KIT_VERSION,
|
|
109
112
|
wheel: selected,
|
|
110
113
|
}, { cause });
|
|
111
114
|
}
|
|
@@ -153,7 +156,7 @@ function parseJsonObject(stage, result) {
|
|
|
153
156
|
throw new MarivoEnvironmentError('shared-runtime-install-failed', `Shared Marivo runtime stage returned invalid JSON: ${stage}`, { stage, stdout: boundedText(result.stdout), stderr: boundedText(result.stderr) }, { cause });
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
|
-
async function probeRuntime(runtimeRoot, executable, environment, timeoutMs,
|
|
159
|
+
async function probeRuntime(runtimeRoot, executable, environment, timeoutMs, presentationKitWheel, administrator, expectedMarivoVersion) {
|
|
157
160
|
const canonical = await assertExecutable(executable);
|
|
158
161
|
const policy = new FixedSubprocessPolicy(runtimeRoot, environment);
|
|
159
162
|
const result = await policy.run({
|
|
@@ -161,15 +164,15 @@ async function probeRuntime(runtimeRoot, executable, environment, timeoutMs, rep
|
|
|
161
164
|
args: ['-c', PROBE_SCRIPT],
|
|
162
165
|
limits: { timeoutMs, stdoutMaxBytes: 16_384, stderrMaxBytes: 16_384 },
|
|
163
166
|
});
|
|
164
|
-
const repair = administrator ? administratorRepair(canonical,
|
|
167
|
+
const repair = administrator ? administratorRepair(canonical, presentationKitWheel) : undefined;
|
|
165
168
|
if (administrator && result.exitCode !== 0) {
|
|
166
|
-
throw new MarivoEnvironmentError('shared-runtime-package-unavailable', `Administrator Python must provide Marivo ${PINNED_MARIVO_VERSION}, pandas ${
|
|
169
|
+
throw new MarivoEnvironmentError('shared-runtime-package-unavailable', `Administrator Python must provide Marivo ${PINNED_MARIVO_VERSION}, pandas ${PRESENTATION_KIT_PANDAS_RANGE}, and ${PRESENTATION_KIT_DISTRIBUTION} ${PRESENTATION_KIT_VERSION}. ${repair.message}`, {
|
|
167
170
|
pythonExecutable: canonical,
|
|
168
171
|
marivoVersion: PINNED_MARIVO_VERSION,
|
|
169
|
-
pandasRange:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
pandasRange: PRESENTATION_KIT_PANDAS_RANGE,
|
|
173
|
+
presentationKitDistribution: PRESENTATION_KIT_DISTRIBUTION,
|
|
174
|
+
presentationKitVersion: PRESENTATION_KIT_VERSION,
|
|
175
|
+
presentationKitWheel: presentationKitWheel,
|
|
173
176
|
exitCode: result.exitCode,
|
|
174
177
|
stderr: boundedText(result.stderr),
|
|
175
178
|
repairCommands: repair.commands,
|
|
@@ -184,12 +187,15 @@ async function probeRuntime(runtimeRoot, executable, environment, timeoutMs, rep
|
|
|
184
187
|
typeof probe.pandas_version !== 'string' ||
|
|
185
188
|
probe.pandas_version.length === 0 ||
|
|
186
189
|
typeof probe.pandas_supported !== 'boolean' ||
|
|
187
|
-
typeof probe.
|
|
188
|
-
probe.
|
|
189
|
-
typeof probe.
|
|
190
|
-
probe.
|
|
191
|
-
probe.
|
|
192
|
-
|
|
190
|
+
typeof probe.presentation_kit_version !== 'string' ||
|
|
191
|
+
probe.presentation_kit_version.length === 0 ||
|
|
192
|
+
typeof probe.presentation_kit_distribution_version !== 'string' ||
|
|
193
|
+
probe.presentation_kit_distribution_version.length === 0 ||
|
|
194
|
+
typeof probe.presentation_kit_package_path !== 'string' ||
|
|
195
|
+
probe.presentation_kit_package_path.length === 0 ||
|
|
196
|
+
probe.presentation_kit_import_identity !== true ||
|
|
197
|
+
probe.presentation_kit_public_imports !== true) {
|
|
198
|
+
throw new MarivoEnvironmentError('shared-runtime-identity-mismatch', 'Shared Runtime returned an incomplete or mismatched package identity', { probe, ...(repair === undefined ? {} : { repairCommands: repair.commands }) });
|
|
193
199
|
}
|
|
194
200
|
const actualPython = await realpath(path.resolve(probe.python_executable));
|
|
195
201
|
const selectedPython = await realpath(canonical);
|
|
@@ -202,18 +208,20 @@ async function probeRuntime(runtimeRoot, executable, environment, timeoutMs, rep
|
|
|
202
208
|
});
|
|
203
209
|
}
|
|
204
210
|
if (!probe.pandas_supported) {
|
|
205
|
-
throw new MarivoEnvironmentError('shared-runtime-pandas-unsupported', `Shared Runtime pandas ${probe.pandas_version} is unsupported; install ${
|
|
206
|
-
supportedPandasRange:
|
|
211
|
+
throw new MarivoEnvironmentError('shared-runtime-pandas-unsupported', `Shared Runtime pandas ${probe.pandas_version} is unsupported; install ${PRESENTATION_KIT_PANDAS_RANGE}.${repair === undefined ? '' : ` ${repair.message}`}`, {
|
|
212
|
+
supportedPandasRange: PRESENTATION_KIT_PANDAS_RANGE,
|
|
207
213
|
actualPandasVersion: probe.pandas_version,
|
|
208
214
|
...(repair === undefined ? {} : { repairCommands: repair.commands }),
|
|
209
215
|
});
|
|
210
216
|
}
|
|
211
|
-
if (probe.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
if (probe.presentation_kit_version !== PRESENTATION_KIT_VERSION ||
|
|
218
|
+
probe.presentation_kit_distribution_version !== PRESENTATION_KIT_VERSION) {
|
|
219
|
+
throw new MarivoEnvironmentError('shared-runtime-presentation-kit-unsupported', `Shared Runtime presentation kit module ${probe.presentation_kit_version} and distribution ${probe.presentation_kit_distribution_version} must both be ${PRESENTATION_KIT_VERSION}; install from ${presentationKitWheel}.${repair === undefined ? '' : ` ${repair.message}`}`, {
|
|
220
|
+
supportedPresentationKitVersion: PRESENTATION_KIT_VERSION,
|
|
221
|
+
actualPresentationKitVersion: probe.presentation_kit_version,
|
|
222
|
+
actualPresentationKitDistributionVersion: probe.presentation_kit_distribution_version,
|
|
223
|
+
presentationKitPackagePath: probe.presentation_kit_package_path,
|
|
224
|
+
presentationKitWheel,
|
|
217
225
|
...(repair === undefined ? {} : { repairCommands: repair.commands }),
|
|
218
226
|
});
|
|
219
227
|
}
|
|
@@ -230,9 +238,11 @@ async function probeRuntime(runtimeRoot, executable, environment, timeoutMs, rep
|
|
|
230
238
|
package_path: path.resolve(probe.package_path),
|
|
231
239
|
pandas_version: probe.pandas_version,
|
|
232
240
|
pandas_supported: probe.pandas_supported,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
241
|
+
presentation_kit_version: probe.presentation_kit_version,
|
|
242
|
+
presentation_kit_distribution_version: probe.presentation_kit_distribution_version,
|
|
243
|
+
presentation_kit_package_path: path.resolve(probe.presentation_kit_package_path),
|
|
244
|
+
presentation_kit_import_identity: true,
|
|
245
|
+
presentation_kit_public_imports: true,
|
|
236
246
|
};
|
|
237
247
|
}
|
|
238
248
|
async function validateSkills(skillsRoot) {
|
|
@@ -308,12 +318,12 @@ async function readInstallation(runtimeRoot) {
|
|
|
308
318
|
'marivoVersion',
|
|
309
319
|
'packagePath',
|
|
310
320
|
'pythonExecutable',
|
|
311
|
-
'
|
|
312
|
-
'
|
|
313
|
-
'
|
|
321
|
+
'presentationKitDistribution',
|
|
322
|
+
'presentationKitPackagePath',
|
|
323
|
+
'presentationKitVersion',
|
|
314
324
|
'schema',
|
|
315
325
|
'skillsRoot',
|
|
316
|
-
];
|
|
326
|
+
].sort();
|
|
317
327
|
if (fields.length !== expectedFields.length ||
|
|
318
328
|
fields.some((field, index) => field !== expectedFields[index]) ||
|
|
319
329
|
record.schema !== INSTALLATION_SCHEMA ||
|
|
@@ -323,11 +333,11 @@ async function readInstallation(runtimeRoot) {
|
|
|
323
333
|
record.pythonExecutable.length === 0 ||
|
|
324
334
|
typeof record.packagePath !== 'string' ||
|
|
325
335
|
record.packagePath.length === 0 ||
|
|
326
|
-
record.
|
|
327
|
-
typeof record.
|
|
328
|
-
record.
|
|
329
|
-
typeof record.
|
|
330
|
-
record.
|
|
336
|
+
record.presentationKitDistribution !== PRESENTATION_KIT_DISTRIBUTION ||
|
|
337
|
+
typeof record.presentationKitVersion !== 'string' ||
|
|
338
|
+
record.presentationKitVersion.length === 0 ||
|
|
339
|
+
typeof record.presentationKitPackagePath !== 'string' ||
|
|
340
|
+
record.presentationKitPackagePath.length === 0 ||
|
|
331
341
|
typeof record.skillsRoot !== 'string' ||
|
|
332
342
|
record.skillsRoot.length === 0)
|
|
333
343
|
return undefined;
|
|
@@ -349,13 +359,13 @@ async function writeInstallation(runtimeRoot, record) {
|
|
|
349
359
|
await rename(temporary, installationPath);
|
|
350
360
|
return installationPath;
|
|
351
361
|
}
|
|
352
|
-
async function validatedExisting(runtimeRoot, configuredPython, environment, timeoutMs,
|
|
362
|
+
async function validatedExisting(runtimeRoot, configuredPython, environment, timeoutMs, presentationKitWheel) {
|
|
353
363
|
const record = await readInstallation(runtimeRoot);
|
|
354
364
|
if (record === undefined)
|
|
355
365
|
return undefined;
|
|
356
366
|
if (record.marivoVersion !== PINNED_MARIVO_VERSION)
|
|
357
367
|
return undefined;
|
|
358
|
-
if (record.
|
|
368
|
+
if (record.presentationKitVersion !== PRESENTATION_KIT_VERSION)
|
|
359
369
|
return undefined;
|
|
360
370
|
const expectedPython = configuredPython ?? venvPython(runtimeRoot);
|
|
361
371
|
const expectedSkillsRoot = path.join(runtimeRoot, 'skills');
|
|
@@ -365,10 +375,11 @@ async function validatedExisting(runtimeRoot, configuredPython, environment, tim
|
|
|
365
375
|
const selectedPython = await assertExecutable(expectedPython);
|
|
366
376
|
if (path.normalize(record.pythonExecutable) !== selectedPython)
|
|
367
377
|
return undefined;
|
|
368
|
-
const probe = await probeRuntime(runtimeRoot, selectedPython, environment, timeoutMs,
|
|
378
|
+
const probe = await probeRuntime(runtimeRoot, selectedPython, environment, timeoutMs, presentationKitWheel, configuredPython !== undefined, record.marivoVersion);
|
|
369
379
|
if (path.normalize(probe.package_path) !== path.normalize(record.packagePath))
|
|
370
380
|
return undefined;
|
|
371
|
-
if (path.normalize(probe.
|
|
381
|
+
if (path.normalize(probe.presentation_kit_package_path) !==
|
|
382
|
+
path.normalize(record.presentationKitPackagePath))
|
|
372
383
|
return undefined;
|
|
373
384
|
await validateSkills(record.skillsRoot);
|
|
374
385
|
return {
|
|
@@ -376,8 +387,8 @@ async function validatedExisting(runtimeRoot, configuredPython, environment, tim
|
|
|
376
387
|
pythonExecutable: probe.python_executable,
|
|
377
388
|
marivoVersion: probe.marivo_version,
|
|
378
389
|
packagePath: probe.package_path,
|
|
379
|
-
|
|
380
|
-
|
|
390
|
+
presentationKitVersion: probe.presentation_kit_version,
|
|
391
|
+
presentationKitPackagePath: probe.presentation_kit_package_path,
|
|
381
392
|
skillsRoot: record.skillsRoot,
|
|
382
393
|
installationPath: path.join(runtimeRoot, INSTALLATION_FILENAME),
|
|
383
394
|
};
|
|
@@ -451,7 +462,7 @@ async function backupInvalidRuntime(runtimeRoot) {
|
|
|
451
462
|
}
|
|
452
463
|
await rename(runtimeRoot, `${runtimeRoot}.invalid-${Date.now()}-${randomUUID()}`);
|
|
453
464
|
}
|
|
454
|
-
async function installManagedRuntime(runtimeRoot, uvExecutable,
|
|
465
|
+
async function installManagedRuntime(runtimeRoot, uvExecutable, presentationKitWheel, environment, timeoutMs) {
|
|
455
466
|
const policy = new FixedSubprocessPolicy(runtimeRoot, environment);
|
|
456
467
|
const limits = { timeoutMs, stdoutMaxBytes: 1_048_576, stderrMaxBytes: 1_048_576 };
|
|
457
468
|
requireSuccess('install managed Python', await policy.run({
|
|
@@ -492,12 +503,12 @@ async function installManagedRuntime(runtimeRoot, uvExecutable, reportKitWheel,
|
|
|
492
503
|
args: ['pip', 'install', '--python', executable, '--upgrade', SHARED_MARIVO_PACKAGE_SPEC],
|
|
493
504
|
limits,
|
|
494
505
|
}));
|
|
495
|
-
requireSuccess(`install
|
|
506
|
+
requireSuccess(`install presentation kit ${PRESENTATION_KIT_VERSION}`, await policy.run({
|
|
496
507
|
executable: uvExecutable,
|
|
497
|
-
args: ['pip', 'install', '--python', executable, '--no-deps',
|
|
508
|
+
args: ['pip', 'install', '--python', executable, '--no-deps', presentationKitWheel],
|
|
498
509
|
limits,
|
|
499
510
|
}));
|
|
500
|
-
return probeRuntime(runtimeRoot, executable, environment, timeoutMs,
|
|
511
|
+
return probeRuntime(runtimeRoot, executable, environment, timeoutMs, presentationKitWheel, false, PINNED_MARIVO_VERSION);
|
|
501
512
|
}
|
|
502
513
|
/** Ensure and validate the one DSH-home-owned Marivo installation. */
|
|
503
514
|
export async function ensureSharedMarivoRuntime(config = {}, options = {}) {
|
|
@@ -511,33 +522,33 @@ export async function ensureSharedMarivoRuntime(config = {}, options = {}) {
|
|
|
511
522
|
? 'uv'
|
|
512
523
|
: normalizeAbsolute('uvExecutable', config.uvExecutable);
|
|
513
524
|
const timeoutMs = positiveTimeout(config.installTimeoutMs);
|
|
514
|
-
const
|
|
515
|
-
const existing = await validatedExisting(runtimeRoot, configuredPython, options.environment, timeoutMs,
|
|
525
|
+
const presentationKitWheel = path.normalize(path.resolve(options.presentationKitWheelPath ?? bundledPresentationKitWheel()));
|
|
526
|
+
const existing = await validatedExisting(runtimeRoot, configuredPython, options.environment, timeoutMs, presentationKitWheel);
|
|
516
527
|
if (existing !== undefined)
|
|
517
528
|
return existing;
|
|
518
529
|
await mkdir(path.dirname(runtimeRoot), { recursive: true });
|
|
519
530
|
const lockPath = `${runtimeRoot}.install-lock`;
|
|
520
531
|
const release = await acquireLock(lockPath, timeoutMs, options.waitIntervalMs ?? 100);
|
|
521
532
|
try {
|
|
522
|
-
const afterLock = await validatedExisting(runtimeRoot, configuredPython, options.environment, timeoutMs,
|
|
533
|
+
const afterLock = await validatedExisting(runtimeRoot, configuredPython, options.environment, timeoutMs, presentationKitWheel);
|
|
523
534
|
if (afterLock !== undefined)
|
|
524
535
|
return afterLock;
|
|
525
536
|
if (configuredPython === undefined)
|
|
526
|
-
await
|
|
537
|
+
await assertPresentationKitWheel(presentationKitWheel);
|
|
527
538
|
await backupInvalidRuntime(runtimeRoot);
|
|
528
539
|
await mkdir(runtimeRoot, { recursive: true });
|
|
529
540
|
const probe = configuredPython === undefined
|
|
530
|
-
? await installManagedRuntime(runtimeRoot, uvExecutable,
|
|
531
|
-
: await probeRuntime(runtimeRoot, configuredPython, options.environment, timeoutMs,
|
|
541
|
+
? await installManagedRuntime(runtimeRoot, uvExecutable, presentationKitWheel, options.environment, timeoutMs)
|
|
542
|
+
: await probeRuntime(runtimeRoot, configuredPython, options.environment, timeoutMs, presentationKitWheel, true, PINNED_MARIVO_VERSION);
|
|
532
543
|
const skillsRoot = await syncSkills(runtimeRoot, probe.package_path);
|
|
533
544
|
const record = {
|
|
534
545
|
schema: INSTALLATION_SCHEMA,
|
|
535
546
|
marivoVersion: probe.marivo_version,
|
|
536
547
|
pythonExecutable: probe.python_executable,
|
|
537
548
|
packagePath: probe.package_path,
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
549
|
+
presentationKitDistribution: PRESENTATION_KIT_DISTRIBUTION,
|
|
550
|
+
presentationKitVersion: probe.presentation_kit_version,
|
|
551
|
+
presentationKitPackagePath: probe.presentation_kit_package_path,
|
|
541
552
|
skillsRoot,
|
|
542
553
|
};
|
|
543
554
|
const installationPath = await writeInstallation(runtimeRoot, record);
|
|
@@ -546,8 +557,8 @@ export async function ensureSharedMarivoRuntime(config = {}, options = {}) {
|
|
|
546
557
|
pythonExecutable: probe.python_executable,
|
|
547
558
|
marivoVersion: probe.marivo_version,
|
|
548
559
|
packagePath: probe.package_path,
|
|
549
|
-
|
|
550
|
-
|
|
560
|
+
presentationKitVersion: probe.presentation_kit_version,
|
|
561
|
+
presentationKitPackagePath: probe.presentation_kit_package_path,
|
|
551
562
|
skillsRoot,
|
|
552
563
|
installationPath,
|
|
553
564
|
};
|
|
@@ -71,7 +71,7 @@ export class FixedSubprocessPolicy {
|
|
|
71
71
|
shell: false,
|
|
72
72
|
windowsHide: true,
|
|
73
73
|
detached: process.platform !== 'win32',
|
|
74
|
-
stdio: ['
|
|
74
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
75
75
|
});
|
|
76
76
|
let child;
|
|
77
77
|
try {
|
|
@@ -84,6 +84,9 @@ export class FixedSubprocessPolicy {
|
|
|
84
84
|
}));
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
+
// A child may reject its input before all bytes are written. Do not log payloads.
|
|
88
|
+
child.stdin.on('error', () => { });
|
|
89
|
+
child.stdin.end(request.stdin);
|
|
87
90
|
const stdout = [];
|
|
88
91
|
const stderr = [];
|
|
89
92
|
let stdoutBytes = 0;
|
|
@@ -127,6 +130,8 @@ export class FixedSubprocessPolicy {
|
|
|
127
130
|
timeout.unref();
|
|
128
131
|
const onAbort = () => terminate(new MarivoEnvironmentError('subprocess-cancelled', 'Marivo subprocess was cancelled'));
|
|
129
132
|
request.signal?.addEventListener('abort', onAbort, { once: true });
|
|
133
|
+
if (request.signal?.aborted)
|
|
134
|
+
onAbort();
|
|
130
135
|
child.stdout.on('data', (chunk) => {
|
|
131
136
|
stdoutBytes += chunk.byteLength;
|
|
132
137
|
if (stdoutBytes > limits.stdoutMaxBytes) {
|
|
@@ -10,9 +10,9 @@ export function environmentPayload(runtime, environment) {
|
|
|
10
10
|
version: environment.binding.marivoVersion,
|
|
11
11
|
packagePath: environment.binding.packagePath,
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
version: runtime.
|
|
15
|
-
packagePath: runtime.
|
|
13
|
+
presentationKit: {
|
|
14
|
+
version: runtime.presentationKitVersion,
|
|
15
|
+
packagePath: runtime.presentationKitPackagePath,
|
|
16
16
|
},
|
|
17
17
|
fingerprint: environment.binding.fingerprint,
|
|
18
18
|
};
|
|
@@ -38,6 +38,11 @@ export class MarivoWorkspaceEnvironmentManager {
|
|
|
38
38
|
binding = bindMarivoEnvironment({
|
|
39
39
|
projectRoot: canonicalRoot,
|
|
40
40
|
pythonExecutable: this.runtime.pythonExecutable,
|
|
41
|
+
}, {
|
|
42
|
+
presentationKit: {
|
|
43
|
+
version: this.runtime.presentationKitVersion,
|
|
44
|
+
packagePath: this.runtime.presentationKitPackagePath,
|
|
45
|
+
},
|
|
41
46
|
});
|
|
42
47
|
this.#bindings.set(canonicalRoot, binding);
|
|
43
48
|
}
|
package/lib/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export * from "./compatibility.js";
|
|
|
3
3
|
export * from "./datasource/index.js";
|
|
4
4
|
export * from "./disclosure/index.js";
|
|
5
5
|
export * from "./environment/index.js";
|
|
6
|
-
export * from "./evidence/index.js";
|
|
7
6
|
export { apply, Config, inject, installMarivoPlugin, name } from "./plugin.js";
|
|
7
|
+
export * from "./presentation/index.js";
|