@mostra/runtime 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/child-protocol-CPXR6pMu.js +13 -0
- package/dist/child-protocol-CPXR6pMu.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{instance-CFTw3g-c.js → instance-Bw1BxctF.js} +2581 -189
- package/dist/instance-Bw1BxctF.js.map +1 -0
- package/dist/plugins/child/host.d.ts +1 -0
- package/dist/plugins/child/host.js +165 -0
- package/dist/plugins/child/host.js.map +1 -0
- package/dist/reference/cli.md +147 -5
- package/dist/reference/diagnostics.json +234 -0
- package/dist/reference/errors/MOSTRA_LICENSE_ACCEPT_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_MISMATCH.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_UNACCEPTED.md +23 -0
- package/dist/reference/errors/MOSTRA_LICENSE_UNDECLARED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ADDRESS_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_CSS_UNIMPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_FETCH_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_FILE_EXISTS.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ITEM_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_ITEM_NOT_FOUND.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_NOT_APPLIED.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_OFFLINE.md +23 -0
- package/dist/reference/errors/MOSTRA_PACK_TARGET_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_CONFLICT.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_CONTRACT_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_ENTRY_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_EXPORTER_UNKNOWN.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_FAILED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_MANIFEST_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_MANIFEST_WARNING.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_NOT_A_PLUGIN.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_NOT_INSTALLED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_OPTIONS_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_PLATFORM_UNSUPPORTED.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_SCOPE_INVALID.md +23 -0
- package/dist/reference/errors/MOSTRA_PLUGIN_SHADOWED.md +23 -0
- package/dist/skill/SKILL.md +4 -2
- package/dist/skill/references/mcp.md +2 -2
- package/dist/skill/references/plugins.md +51 -0
- package/package.json +10 -7
- package/src/deps/index.ts +407 -90
- package/src/deps/installer.ts +53 -10
- package/src/deps/lock.ts +74 -2
- package/src/home/settings.ts +3 -0
- package/src/instance/index.ts +57 -0
- package/src/packs/index.ts +7 -0
- package/src/packs/methods.ts +49 -0
- package/src/packs/packs.ts +706 -0
- package/src/packs/read.ts +759 -0
- package/src/platform/index.ts +1 -0
- package/src/platform/shell.ts +14 -0
- package/src/plugins/child/host.ts +231 -0
- package/src/plugins/child-protocol.ts +68 -0
- package/src/plugins/index.ts +7 -0
- package/src/plugins/location.ts +109 -0
- package/src/plugins/methods.ts +269 -0
- package/src/plugins/plugins.ts +1396 -0
- package/src/publish/publisher.ts +71 -3
- package/dist/instance-CFTw3g-c.js.map +0 -1
package/src/publish/publisher.ts
CHANGED
|
@@ -36,12 +36,14 @@ import { createZstdCompress } from "node:zlib";
|
|
|
36
36
|
import {
|
|
37
37
|
type ArtifactCreateParams,
|
|
38
38
|
type ArtifactCreateResult,
|
|
39
|
+
type ArtifactDetail,
|
|
39
40
|
type ArtifactExportParams,
|
|
40
41
|
type ArtifactExportResult,
|
|
41
42
|
ArtifactId,
|
|
42
43
|
type ArtifactImportParams,
|
|
43
44
|
type ArtifactManifest,
|
|
44
45
|
type ArtifactPublishParams,
|
|
46
|
+
type ArtifactRef,
|
|
45
47
|
type ArtifactVerifyParams,
|
|
46
48
|
BROWSER_PROTOCOL_REVISION,
|
|
47
49
|
createDiagnostic,
|
|
@@ -53,9 +55,15 @@ import {
|
|
|
53
55
|
type SourceRef,
|
|
54
56
|
type SubmissionPolicy,
|
|
55
57
|
type VerifyVerdict,
|
|
58
|
+
type VersionSummary,
|
|
56
59
|
} from "@mostra/protocol";
|
|
57
60
|
import type { RenderMode } from "../builder/index.ts";
|
|
58
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
type Dependencies,
|
|
63
|
+
type DependencyTarget,
|
|
64
|
+
lockKey,
|
|
65
|
+
type Resolution,
|
|
66
|
+
} from "../deps/index.ts";
|
|
59
67
|
import { type Faults, noFaults } from "../faults.ts";
|
|
60
68
|
import type { Gate } from "../gate.ts";
|
|
61
69
|
import {
|
|
@@ -125,6 +133,13 @@ export interface PublisherOptions {
|
|
|
125
133
|
readonly gate?: Gate;
|
|
126
134
|
}
|
|
127
135
|
|
|
136
|
+
/** A version an export reads: its artifact, its summary and its sealed directory. */
|
|
137
|
+
export interface ExportableVersion {
|
|
138
|
+
readonly detail: ArtifactDetail;
|
|
139
|
+
readonly summary: VersionSummary;
|
|
140
|
+
readonly versionDir: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
128
143
|
/** Publishes and creates artifacts. */
|
|
129
144
|
export interface Publisher {
|
|
130
145
|
/** `artifact/publish`: gated by verify (D41). */
|
|
@@ -139,6 +154,25 @@ export interface Publisher {
|
|
|
139
154
|
exportBundle(params: ArtifactExportParams): Promise<ArtifactExportResult>;
|
|
140
155
|
/** `artifact/import`: makes a bundle a version of this home, with its identity (RM-01). */
|
|
141
156
|
importBundle(params: ArtifactImportParams): Promise<PublishReceipt>;
|
|
157
|
+
/** A published version, checked whole, as an export reads it (`artifact/export`, `plugin/export`). */
|
|
158
|
+
exportable(params: {
|
|
159
|
+
readonly artifact: ArtifactRef;
|
|
160
|
+
readonly version?: number | string;
|
|
161
|
+
}): Promise<ExportableVersion>;
|
|
162
|
+
/** Runs `task` holding the instance's gate shared, as installs do: the home's own plugins. */
|
|
163
|
+
withHome<T>(task: () => Promise<T>): Promise<T>;
|
|
164
|
+
/**
|
|
165
|
+
* Runs `task` for an artifact's source, holding its path's queue (as its publishes and
|
|
166
|
+
* `deps/add` do) and the instance's gate shared, with the working lockfile's target: what
|
|
167
|
+
* `plugin/*` and `pack/add` change (WP-16).
|
|
168
|
+
*/
|
|
169
|
+
withArtifact<T>(
|
|
170
|
+
ref: SourceRef,
|
|
171
|
+
task: (artifact: {
|
|
172
|
+
readonly target: DependencyTarget;
|
|
173
|
+
readonly source: ResolvedSource;
|
|
174
|
+
}) => Promise<T>,
|
|
175
|
+
): Promise<T>;
|
|
142
176
|
}
|
|
143
177
|
|
|
144
178
|
const ENTRY_NAMES = ["index.tsx", "index.jsx", "index.mdx"];
|
|
@@ -490,6 +524,9 @@ export function createPublisher(options: PublisherOptions): Publisher {
|
|
|
490
524
|
artifactDir: source.root,
|
|
491
525
|
artifactPath: path,
|
|
492
526
|
});
|
|
527
|
+
// A lockfile that names plugins passed the plugin gate inside `resolve` (D172 item 5): its
|
|
528
|
+
// ranges, conflicts and licenses, then its entries, so no version records plugins this release
|
|
529
|
+
// can't load, or a license nobody acknowledged.
|
|
493
530
|
faults.at("publish:after-dependencies");
|
|
494
531
|
|
|
495
532
|
// 3. Digests (DATA_MODEL §2).
|
|
@@ -658,7 +695,7 @@ export function createPublisher(options: PublisherOptions): Publisher {
|
|
|
658
695
|
// A manifest or the dependencies that can't be read are the verdict, not a failure of verify.
|
|
659
696
|
if (
|
|
660
697
|
error instanceof RpcError &&
|
|
661
|
-
/^MOSTRA_(MANIFEST|DEP|ARTIFACT|BUILD)_/.test(error.diagnostic.code)
|
|
698
|
+
/^MOSTRA_(MANIFEST|DEP|ARTIFACT|BUILD|PLUGIN|LICENSE)_/.test(error.diagnostic.code)
|
|
662
699
|
) {
|
|
663
700
|
return failedVerdict(path, error.diagnostic);
|
|
664
701
|
}
|
|
@@ -881,9 +918,34 @@ export function createPublisher(options: PublisherOptions): Publisher {
|
|
|
881
918
|
exportBundle: (params) => gated(() => exportBundle(params)),
|
|
882
919
|
importBundle: (params) =>
|
|
883
920
|
gated(() => idempotent(requestKey("artifact/import", params), () => importBundle(params))),
|
|
921
|
+
exportable: (params) => gated(() => exportable(params)),
|
|
922
|
+
withHome: (task) => gated(task),
|
|
923
|
+
withArtifact: (ref, task) =>
|
|
924
|
+
gated(async () => {
|
|
925
|
+
const path = pathOf(ref);
|
|
926
|
+
const source = await resolveSource(path);
|
|
927
|
+
return queue.run(`path:${source.bindingPath}`, async () => {
|
|
928
|
+
const manifestId = extractManifest(source.entry, await readEntry(source)).manifest?.id;
|
|
929
|
+
return task({
|
|
930
|
+
target: {
|
|
931
|
+
key: lockKey(
|
|
932
|
+
manifestId ?? registry.artifactAt(source.bindingPath),
|
|
933
|
+
source.bindingPath,
|
|
934
|
+
),
|
|
935
|
+
artifactDir: source.root,
|
|
936
|
+
artifactPath: path,
|
|
937
|
+
},
|
|
938
|
+
source,
|
|
939
|
+
});
|
|
940
|
+
});
|
|
941
|
+
}),
|
|
884
942
|
};
|
|
885
943
|
|
|
886
|
-
|
|
944
|
+
/** A published version of an artifact, checked whole: what an export reads. */
|
|
945
|
+
async function exportable(params: {
|
|
946
|
+
readonly artifact: ArtifactRef;
|
|
947
|
+
readonly version?: number | string;
|
|
948
|
+
}): Promise<ExportableVersion> {
|
|
887
949
|
// `artifact` arrives canonical: the method's handler made it so (canonicalRef).
|
|
888
950
|
const detail = registry.get(params.artifact);
|
|
889
951
|
const wanted = params.version;
|
|
@@ -916,6 +978,11 @@ export function createPublisher(options: PublisherOptions): Publisher {
|
|
|
916
978
|
}),
|
|
917
979
|
);
|
|
918
980
|
}
|
|
981
|
+
return { detail, summary, versionDir };
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
async function exportBundle(params: ArtifactExportParams): Promise<ArtifactExportResult> {
|
|
985
|
+
const { detail, summary, versionDir } = await exportable(params);
|
|
919
986
|
const files = await writeBundle({
|
|
920
987
|
versionDir,
|
|
921
988
|
snapshot: registry.store.snapshotPath(detail.id, summary.sourceDigest),
|
|
@@ -1007,6 +1074,7 @@ export function createPublisher(options: PublisherOptions): Publisher {
|
|
|
1007
1074
|
artifactDir: source.root,
|
|
1008
1075
|
artifactPath: path,
|
|
1009
1076
|
packages: params.packages,
|
|
1077
|
+
...(params.acceptLicenses !== undefined ? { accept: params.acceptLicenses } : {}),
|
|
1010
1078
|
request: requestKey("deps/add", params),
|
|
1011
1079
|
});
|
|
1012
1080
|
});
|