@mcoda/shared 0.1.75 → 0.1.78
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/CHANGELOG.md +4 -0
- package/README.md +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/mswarm/ArtifactSandboxContract.d.ts +98 -0
- package/dist/mswarm/ArtifactSandboxContract.d.ts.map +1 -0
- package/dist/mswarm/ArtifactSandboxContract.js +111 -0
- package/dist/mswarm/CapabilityContract.d.ts +136 -0
- package/dist/mswarm/CapabilityContract.d.ts.map +1 -0
- package/dist/mswarm/CapabilityContract.js +128 -0
- package/dist/mswarm/GenericJobContract.d.ts +136 -0
- package/dist/mswarm/GenericJobContract.d.ts.map +1 -0
- package/dist/mswarm/GenericJobContract.js +1005 -0
- package/dist/mswarm/LifecycleContract.d.ts +122 -0
- package/dist/mswarm/LifecycleContract.d.ts.map +1 -0
- package/dist/mswarm/LifecycleContract.js +68 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Shared utilities and schemas used across the mcoda workspace.
|
|
|
10
10
|
- PathHelper for resolving mcoda directories.
|
|
11
11
|
- CryptoHelper for local secret encryption.
|
|
12
12
|
- CommandMetadata helpers and OpenAPI types.
|
|
13
|
+
- Versioned mswarm generic job, lifecycle, capability, and artifact sandbox contracts.
|
|
13
14
|
- QA profile types.
|
|
14
15
|
|
|
15
16
|
## Example
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export * from "./qa/QaReadiness.js";
|
|
|
7
7
|
export * from "./qa/QaTechStack.js";
|
|
8
8
|
export * from "./metadata/CommandMetadata.js";
|
|
9
9
|
export * from "./llm/LocalRunnerConfig.js";
|
|
10
|
+
export * from "./mswarm/GenericJobContract.js";
|
|
11
|
+
export * from "./mswarm/CapabilityContract.js";
|
|
12
|
+
export * from "./mswarm/ArtifactSandboxContract.js";
|
|
13
|
+
export * from "./mswarm/LifecycleContract.js";
|
|
10
14
|
export * from "./status/TaskStatus.js";
|
|
11
15
|
export type { BacklogLaneTotals, BacklogTotals, BacklogSummary, EffectiveVelocity, EstimateResult, EstimateDurations, EstimateEtas, EstimateStatusCounts, EstimateCompletionMetric, EstimateCompletion, VelocitySource, AgentHealth, AgentHealthStatus, AgentUsageLimitScope, AgentUsageLimitWindowType, AgentUsageLimitStatus, AgentUsageLimitRecord, UpsertAgentUsageLimitInput, RoutingDefaults, RoutingDefault, RoutingProvenance, RoutingCandidate, RoutingPreview, RoutingDefaultsUpdate, RefineTasksRequest, RefineTasksPlan, RefineTasksResult, RefineStrategy, RefineOperation, UpdateTaskOp, SplitTaskOp, MergeTasksOp, UpdateEstimateOp, UpdateInfo, UpdateChannel, ApplyUpdateResponse, } from "./openapi/OpenApiTypes.js";
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,8 @@ export * from "./qa/QaReadiness.js";
|
|
|
7
7
|
export * from "./qa/QaTechStack.js";
|
|
8
8
|
export * from "./metadata/CommandMetadata.js";
|
|
9
9
|
export * from "./llm/LocalRunnerConfig.js";
|
|
10
|
+
export * from "./mswarm/GenericJobContract.js";
|
|
11
|
+
export * from "./mswarm/CapabilityContract.js";
|
|
12
|
+
export * from "./mswarm/ArtifactSandboxContract.js";
|
|
13
|
+
export * from "./mswarm/LifecycleContract.js";
|
|
10
14
|
export * from "./status/TaskStatus.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { MswarmArtifactRef, MswarmArtifactScope, MswarmJobLimits, MswarmJobNetworkPolicy, MswarmJobPolicy, MswarmJobTrustMode, MswarmOutputSpec } from "./GenericJobContract.js";
|
|
2
|
+
export declare const MSWARM_ARTIFACT_SANDBOX_SCHEMA_VERSION: "2026-06-14";
|
|
3
|
+
export type MswarmArtifactStorageBackend = "local-dev" | "gateway" | "object-storage";
|
|
4
|
+
export type MswarmArtifactVisibility = "owner-local" | "tenant-scoped";
|
|
5
|
+
export type MswarmSandboxProfileName = "owner-local-process" | "container-cpu" | "container-nvidia";
|
|
6
|
+
export type MswarmArchiveEntryType = "file" | "directory" | "symlink" | "hardlink" | "device" | "other";
|
|
7
|
+
export interface MswarmArtifactAccessPolicy {
|
|
8
|
+
visibility: MswarmArtifactVisibility;
|
|
9
|
+
read_by: Array<"runner" | "owner" | "tenant" | "gateway">;
|
|
10
|
+
write_by: Array<"runner" | "owner" | "gateway">;
|
|
11
|
+
expires_at?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MswarmArtifactRetentionPolicy {
|
|
14
|
+
retain_for_seconds: number;
|
|
15
|
+
delete_after?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MswarmArtifactStoreDescriptor {
|
|
18
|
+
backend: MswarmArtifactStorageBackend;
|
|
19
|
+
root_uri?: string;
|
|
20
|
+
bucket?: string;
|
|
21
|
+
gateway_base_url?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MswarmArtifactRegistrationRequest {
|
|
24
|
+
job_id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
artifact: MswarmArtifactRef;
|
|
27
|
+
access?: MswarmArtifactAccessPolicy;
|
|
28
|
+
retention?: MswarmArtifactRetentionPolicy;
|
|
29
|
+
}
|
|
30
|
+
export interface MswarmRegisteredArtifact extends MswarmArtifactRef {
|
|
31
|
+
id: string;
|
|
32
|
+
job_id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
scope: MswarmArtifactScope;
|
|
35
|
+
registered_at: string;
|
|
36
|
+
store: MswarmArtifactStoreDescriptor;
|
|
37
|
+
access: MswarmArtifactAccessPolicy;
|
|
38
|
+
retention: MswarmArtifactRetentionPolicy;
|
|
39
|
+
local_path?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface MswarmOutputCollectionSpec extends MswarmOutputSpec {
|
|
42
|
+
max_bytes?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface MswarmArchiveEntryCheck {
|
|
45
|
+
path: string;
|
|
46
|
+
type?: MswarmArchiveEntryType;
|
|
47
|
+
size_bytes?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface MswarmPathValidationResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
normalized?: string;
|
|
52
|
+
reason?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface MswarmSandboxProfile {
|
|
55
|
+
schema_version: typeof MSWARM_ARTIFACT_SANDBOX_SCHEMA_VERSION;
|
|
56
|
+
name: MswarmSandboxProfileName;
|
|
57
|
+
trust_mode: MswarmJobTrustMode;
|
|
58
|
+
network: MswarmJobNetworkPolicy;
|
|
59
|
+
allow_raw_command: false;
|
|
60
|
+
filesystem: {
|
|
61
|
+
working_directory: "per-job";
|
|
62
|
+
inputs: "read-only";
|
|
63
|
+
outputs: "write-only";
|
|
64
|
+
allow_host_paths: false;
|
|
65
|
+
validate_output_paths: true;
|
|
66
|
+
validate_archive_entries: true;
|
|
67
|
+
};
|
|
68
|
+
container: {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
rootless: boolean;
|
|
71
|
+
user: string;
|
|
72
|
+
privileged: false;
|
|
73
|
+
read_only_root_fs: boolean;
|
|
74
|
+
gpu: "none" | "nvidia";
|
|
75
|
+
allowed_images?: string[];
|
|
76
|
+
};
|
|
77
|
+
limits: {
|
|
78
|
+
timeout_sec?: number;
|
|
79
|
+
max_stdout_bytes?: number;
|
|
80
|
+
max_stderr_bytes?: number;
|
|
81
|
+
max_output_bytes?: number;
|
|
82
|
+
max_artifact_bytes?: number;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export declare function normalizeMswarmSafeRelativePath(path: unknown): MswarmPathValidationResult;
|
|
86
|
+
export declare function assertMswarmSafeRelativePath(path: unknown, label?: string): string;
|
|
87
|
+
export declare function validateMswarmOutputSpecPath(output: MswarmOutputSpec): MswarmPathValidationResult;
|
|
88
|
+
export declare function validateMswarmArchiveEntry(entry: MswarmArchiveEntryCheck): MswarmPathValidationResult;
|
|
89
|
+
export declare function defaultMswarmArtifactAccessPolicy(visibility?: MswarmArtifactVisibility): MswarmArtifactAccessPolicy;
|
|
90
|
+
export declare function defaultMswarmArtifactRetentionPolicy(retainForSeconds?: number): MswarmArtifactRetentionPolicy;
|
|
91
|
+
export declare function buildMswarmLocalArtifactUri(jobId: string, relativePath: string): string;
|
|
92
|
+
export declare function buildMswarmSandboxProfile(input: {
|
|
93
|
+
policy: MswarmJobPolicy;
|
|
94
|
+
limits?: MswarmJobLimits;
|
|
95
|
+
containerized?: boolean;
|
|
96
|
+
gpu?: "none" | "nvidia";
|
|
97
|
+
}): MswarmSandboxProfile;
|
|
98
|
+
//# sourceMappingURL=ArtifactSandboxContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactSandboxContract.d.ts","sourceRoot":"","sources":["../../src/mswarm/ArtifactSandboxContract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,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
|
3
|
+
const URL_SCHEME_PREFIX = /^[a-zA-Z][a-zA-Z\d+.-]*:/;
|
|
4
|
+
export function normalizeMswarmSafeRelativePath(path) {
|
|
5
|
+
if (typeof path !== "string" || path.trim().length === 0) {
|
|
6
|
+
return { ok: false, reason: "path_required" };
|
|
7
|
+
}
|
|
8
|
+
const raw = path.trim();
|
|
9
|
+
if (raw.includes("\0")) {
|
|
10
|
+
return { ok: false, reason: "null_byte" };
|
|
11
|
+
}
|
|
12
|
+
if (raw.includes("\\")) {
|
|
13
|
+
return { ok: false, reason: "backslash_not_allowed" };
|
|
14
|
+
}
|
|
15
|
+
if (raw.startsWith("/") || raw.startsWith("//") || WINDOWS_DRIVE_PREFIX.test(raw)) {
|
|
16
|
+
return { ok: false, reason: "absolute_path_not_allowed" };
|
|
17
|
+
}
|
|
18
|
+
if (URL_SCHEME_PREFIX.test(raw)) {
|
|
19
|
+
return { ok: false, reason: "uri_path_not_allowed" };
|
|
20
|
+
}
|
|
21
|
+
const parts = raw.split("/").filter((part) => part.length > 0 && part !== ".");
|
|
22
|
+
if (parts.length === 0) {
|
|
23
|
+
return { ok: false, reason: "path_required" };
|
|
24
|
+
}
|
|
25
|
+
for (const part of parts) {
|
|
26
|
+
if (part === "..") {
|
|
27
|
+
return { ok: false, reason: "parent_path_not_allowed" };
|
|
28
|
+
}
|
|
29
|
+
if (part.length > 255) {
|
|
30
|
+
return { ok: false, reason: "path_segment_too_long" };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { ok: true, normalized: parts.join("/") };
|
|
34
|
+
}
|
|
35
|
+
export function assertMswarmSafeRelativePath(path, label = "path") {
|
|
36
|
+
const result = normalizeMswarmSafeRelativePath(path);
|
|
37
|
+
if (!result.ok || !result.normalized) {
|
|
38
|
+
throw new Error(`${label}_${result.reason || "invalid"}`);
|
|
39
|
+
}
|
|
40
|
+
return result.normalized;
|
|
41
|
+
}
|
|
42
|
+
export function validateMswarmOutputSpecPath(output) {
|
|
43
|
+
return normalizeMswarmSafeRelativePath(output.path);
|
|
44
|
+
}
|
|
45
|
+
export function validateMswarmArchiveEntry(entry) {
|
|
46
|
+
const type = entry.type || "file";
|
|
47
|
+
if (type === "symlink" || type === "hardlink" || type === "device" || type === "other") {
|
|
48
|
+
return { ok: false, reason: `archive_${type}_not_allowed` };
|
|
49
|
+
}
|
|
50
|
+
if (Number.isFinite(entry.size_bytes) && entry.size_bytes !== undefined && entry.size_bytes < 0) {
|
|
51
|
+
return { ok: false, reason: "negative_size_not_allowed" };
|
|
52
|
+
}
|
|
53
|
+
return normalizeMswarmSafeRelativePath(entry.path);
|
|
54
|
+
}
|
|
55
|
+
export function defaultMswarmArtifactAccessPolicy(visibility = "owner-local") {
|
|
56
|
+
return {
|
|
57
|
+
visibility,
|
|
58
|
+
read_by: visibility === "tenant-scoped" ? ["runner", "tenant", "gateway"] : ["runner", "owner"],
|
|
59
|
+
write_by: visibility === "tenant-scoped" ? ["runner", "gateway"] : ["runner", "owner"],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export function defaultMswarmArtifactRetentionPolicy(retainForSeconds = 86400) {
|
|
63
|
+
return {
|
|
64
|
+
retain_for_seconds: retainForSeconds,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function buildMswarmLocalArtifactUri(jobId, relativePath) {
|
|
68
|
+
const normalizedJobId = assertMswarmSafeRelativePath(jobId.replace(/[^a-zA-Z0-9_.-]/g, "_"), "job_id");
|
|
69
|
+
const normalizedPath = assertMswarmSafeRelativePath(relativePath, "artifact_path");
|
|
70
|
+
return `artifact://local/${normalizedJobId}/${normalizedPath}`;
|
|
71
|
+
}
|
|
72
|
+
export function buildMswarmSandboxProfile(input) {
|
|
73
|
+
const containerized = input.containerized === true;
|
|
74
|
+
const gpu = input.gpu || "none";
|
|
75
|
+
const name = containerized
|
|
76
|
+
? gpu === "nvidia"
|
|
77
|
+
? "container-nvidia"
|
|
78
|
+
: "container-cpu"
|
|
79
|
+
: "owner-local-process";
|
|
80
|
+
return {
|
|
81
|
+
schema_version: MSWARM_ARTIFACT_SANDBOX_SCHEMA_VERSION,
|
|
82
|
+
name,
|
|
83
|
+
trust_mode: input.policy.trust_mode,
|
|
84
|
+
network: input.policy.network || "none",
|
|
85
|
+
allow_raw_command: false,
|
|
86
|
+
filesystem: {
|
|
87
|
+
working_directory: "per-job",
|
|
88
|
+
inputs: "read-only",
|
|
89
|
+
outputs: "write-only",
|
|
90
|
+
allow_host_paths: false,
|
|
91
|
+
validate_output_paths: true,
|
|
92
|
+
validate_archive_entries: true,
|
|
93
|
+
},
|
|
94
|
+
container: {
|
|
95
|
+
enabled: containerized,
|
|
96
|
+
rootless: true,
|
|
97
|
+
user: "65532:65532",
|
|
98
|
+
privileged: false,
|
|
99
|
+
read_only_root_fs: true,
|
|
100
|
+
gpu,
|
|
101
|
+
...(input.policy.allowed_images?.length ? { allowed_images: [...input.policy.allowed_images] } : {}),
|
|
102
|
+
},
|
|
103
|
+
limits: {
|
|
104
|
+
timeout_sec: input.limits?.timeout_sec,
|
|
105
|
+
max_stdout_bytes: input.limits?.max_stdout_bytes,
|
|
106
|
+
max_stderr_bytes: input.limits?.max_stderr_bytes,
|
|
107
|
+
max_output_bytes: input.limits?.max_output_bytes,
|
|
108
|
+
max_artifact_bytes: input.policy.max_artifact_bytes,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { MswarmGpuVendor, MswarmJobTrustMode, MswarmJobType } from "./GenericJobContract.js";
|
|
2
|
+
export declare const MSWARM_CAPABILITY_SCHEMA_VERSION: "2026-06-14";
|
|
3
|
+
export declare const MSWARM_CAPABILITY_PROBE_STATUSES: readonly ["available", "missing", "error", "unknown"];
|
|
4
|
+
export type MswarmCapabilitySchemaVersion = typeof MSWARM_CAPABILITY_SCHEMA_VERSION;
|
|
5
|
+
export type MswarmCapabilityProbeStatus = (typeof MSWARM_CAPABILITY_PROBE_STATUSES)[number];
|
|
6
|
+
export type MswarmSoftwareProbeName = "docker" | "docker-nvidia" | "blender" | "ffmpeg";
|
|
7
|
+
export type MswarmPublicVramTier = "none" | "lt8" | "8-15" | "16-31" | "32plus";
|
|
8
|
+
export interface MswarmSoftwareProbeResult {
|
|
9
|
+
name: MswarmSoftwareProbeName;
|
|
10
|
+
status: MswarmCapabilityProbeStatus;
|
|
11
|
+
version?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MswarmGpuDeviceCapability {
|
|
15
|
+
id: string;
|
|
16
|
+
vendor: MswarmGpuVendor;
|
|
17
|
+
name?: string;
|
|
18
|
+
vram_gb?: number;
|
|
19
|
+
driver_version?: string;
|
|
20
|
+
cuda_version?: string;
|
|
21
|
+
compute_capability?: string;
|
|
22
|
+
capabilities?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface MswarmGpuCapabilityProbe {
|
|
25
|
+
status: MswarmCapabilityProbeStatus;
|
|
26
|
+
count: number;
|
|
27
|
+
vendors: MswarmGpuVendor[];
|
|
28
|
+
devices: MswarmGpuDeviceCapability[];
|
|
29
|
+
cuda_versions?: string[];
|
|
30
|
+
max_vram_gb?: number;
|
|
31
|
+
message?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MswarmRunnerCatalogCapability {
|
|
34
|
+
job_type: MswarmJobType;
|
|
35
|
+
runner: string;
|
|
36
|
+
trust_modes: MswarmJobTrustMode[];
|
|
37
|
+
required_capabilities?: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface MswarmNodeCapabilitySnapshot {
|
|
40
|
+
schema_version: MswarmCapabilitySchemaVersion;
|
|
41
|
+
snapshot_id: string;
|
|
42
|
+
captured_at: string;
|
|
43
|
+
node_id?: string;
|
|
44
|
+
platform?: string;
|
|
45
|
+
arch?: string;
|
|
46
|
+
generic_jobs_enabled: boolean;
|
|
47
|
+
job_types: MswarmJobType[];
|
|
48
|
+
trust_modes: MswarmJobTrustMode[];
|
|
49
|
+
gpu: MswarmGpuCapabilityProbe;
|
|
50
|
+
software: Record<MswarmSoftwareProbeName, MswarmSoftwareProbeResult>;
|
|
51
|
+
runner_catalog: MswarmRunnerCatalogCapability[];
|
|
52
|
+
diagnostics?: Array<{
|
|
53
|
+
name: string;
|
|
54
|
+
status: Exclude<MswarmCapabilityProbeStatus, "available">;
|
|
55
|
+
message?: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
export interface MswarmSchedulerMatchInput {
|
|
59
|
+
schema_version: MswarmCapabilitySchemaVersion;
|
|
60
|
+
snapshot_id: string;
|
|
61
|
+
node_id?: string;
|
|
62
|
+
updated_at: string;
|
|
63
|
+
generic_jobs_enabled: boolean;
|
|
64
|
+
available_job_types: MswarmJobType[];
|
|
65
|
+
trust_modes: MswarmJobTrustMode[];
|
|
66
|
+
resources: {
|
|
67
|
+
gpu_count: number;
|
|
68
|
+
gpu_vendors: MswarmGpuVendor[];
|
|
69
|
+
max_vram_gb?: number;
|
|
70
|
+
has_cuda: boolean;
|
|
71
|
+
software: {
|
|
72
|
+
docker_nvidia: boolean;
|
|
73
|
+
blender: boolean;
|
|
74
|
+
ffmpeg: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
capabilities: string[];
|
|
78
|
+
}
|
|
79
|
+
export interface MswarmPublicCapabilityProjection {
|
|
80
|
+
schema_version: MswarmCapabilitySchemaVersion;
|
|
81
|
+
snapshot_id: string;
|
|
82
|
+
captured_at: string;
|
|
83
|
+
generic_jobs_enabled: boolean;
|
|
84
|
+
job_types: MswarmJobType[];
|
|
85
|
+
accelerators: {
|
|
86
|
+
gpu: {
|
|
87
|
+
available: boolean;
|
|
88
|
+
count: number;
|
|
89
|
+
vendors: MswarmGpuVendor[];
|
|
90
|
+
cuda: boolean;
|
|
91
|
+
vram_tier: MswarmPublicVramTier;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
software: {
|
|
95
|
+
docker_nvidia: {
|
|
96
|
+
available: boolean;
|
|
97
|
+
status: MswarmCapabilityProbeStatus;
|
|
98
|
+
};
|
|
99
|
+
blender: {
|
|
100
|
+
available: boolean;
|
|
101
|
+
status: MswarmCapabilityProbeStatus;
|
|
102
|
+
};
|
|
103
|
+
ffmpeg: {
|
|
104
|
+
available: boolean;
|
|
105
|
+
status: MswarmCapabilityProbeStatus;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
capabilities: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface MswarmPrivateCapabilityCatalogEntry {
|
|
111
|
+
node_id?: string;
|
|
112
|
+
snapshot_id: string;
|
|
113
|
+
captured_at: string;
|
|
114
|
+
snapshot: MswarmNodeCapabilitySnapshot;
|
|
115
|
+
scheduler_match: MswarmSchedulerMatchInput;
|
|
116
|
+
public_projection: MswarmPublicCapabilityProjection;
|
|
117
|
+
}
|
|
118
|
+
export interface MswarmCapabilitySignature {
|
|
119
|
+
alg: "HS256";
|
|
120
|
+
value: string;
|
|
121
|
+
signed_at: string;
|
|
122
|
+
key_id?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface MswarmSignedCapabilityPayload {
|
|
125
|
+
schema_version: MswarmCapabilitySchemaVersion;
|
|
126
|
+
snapshot_id: string;
|
|
127
|
+
private_catalog_entry: MswarmPrivateCapabilityCatalogEntry;
|
|
128
|
+
scheduler_match: MswarmSchedulerMatchInput;
|
|
129
|
+
public_projection: MswarmPublicCapabilityProjection;
|
|
130
|
+
signature: MswarmCapabilitySignature;
|
|
131
|
+
}
|
|
132
|
+
export declare function buildMswarmCapabilityNames(snapshot: MswarmNodeCapabilitySnapshot): string[];
|
|
133
|
+
export declare function buildMswarmSchedulerMatchInput(snapshot: MswarmNodeCapabilitySnapshot): MswarmSchedulerMatchInput;
|
|
134
|
+
export declare function projectMswarmPublicCapabilities(snapshot: MswarmNodeCapabilitySnapshot): MswarmPublicCapabilityProjection;
|
|
135
|
+
export declare function buildMswarmPrivateCapabilityCatalogEntry(snapshot: MswarmNodeCapabilitySnapshot): MswarmPrivateCapabilityCatalogEntry;
|
|
136
|
+
//# sourceMappingURL=CapabilityContract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CapabilityContract.d.ts","sourceRoot":"","sources":["../../src/mswarm/CapabilityContract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,gCAAgC,EAAG,YAAqB,CAAC;AAEtE,eAAO,MAAM,gCAAgC,uDAKnC,CAAC;AAEX,MAAM,MAAM,6BAA6B,GAAG,OAAO,gCAAgC,CAAC;AACpF,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5F,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AACxF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,MAAM,EAAE,2BAA2B,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,2BAA2B,CAAC;IACpC,KAAK,EAAE,MA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EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,4BAA4B,CAAC;IACvC,eAAe,EAAE,yBAAyB,CAAC;IAC3C,iBAAiB,EAAE,gCAAgC,CAAC;CACrD;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B;IAC5C,cAAc,EAAE,6BAA6B,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,mCAAmC,CAAC;IAC3D,eAAe,EAAE,yBAAyB,CAAC;IAC3C,iBAAiB,EAAE,gCAAgC,CAAC;IACpD,SAAS,EAAE,yBAAyB,CAAC;CACtC;AA8BD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,4BAA4B,GAAG,MAAM,EAAE,CA8B3F;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,4BAA4B,GACrC,yBAAyB,CAsB3B;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,4BAA4B,GACrC,gCAAgC,CAgClC;AAED,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,4BAA4B,GACrC,mCAAmC,CASrC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const MSWARM_CAPABILITY_SCHEMA_VERSION = "2026-06-14";
|
|
2
|
+
export const MSWARM_CAPABILITY_PROBE_STATUSES = [
|
|
3
|
+
"available",
|
|
4
|
+
"missing",
|
|
5
|
+
"error",
|
|
6
|
+
"unknown",
|
|
7
|
+
];
|
|
8
|
+
function sortedUnique(values) {
|
|
9
|
+
return Array.from(new Set(values.filter((value) => typeof value === "string" && value.length > 0))).sort();
|
|
10
|
+
}
|
|
11
|
+
function softwareAvailable(result) {
|
|
12
|
+
return result?.status === "available";
|
|
13
|
+
}
|
|
14
|
+
function hasCuda(snapshot) {
|
|
15
|
+
return (Boolean(snapshot.gpu.cuda_versions?.length) ||
|
|
16
|
+
snapshot.gpu.devices.some((device) => {
|
|
17
|
+
const caps = device.capabilities || [];
|
|
18
|
+
return Boolean(device.cuda_version) || caps.some((capability) => capability.toLowerCase() === "cuda");
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
function publicVramTier(maxVramGb) {
|
|
22
|
+
if (!Number.isFinite(maxVramGb) || !maxVramGb || maxVramGb <= 0)
|
|
23
|
+
return "none";
|
|
24
|
+
if (maxVramGb < 8)
|
|
25
|
+
return "lt8";
|
|
26
|
+
if (maxVramGb < 16)
|
|
27
|
+
return "8-15";
|
|
28
|
+
if (maxVramGb < 32)
|
|
29
|
+
return "16-31";
|
|
30
|
+
return "32plus";
|
|
31
|
+
}
|
|
32
|
+
export function buildMswarmCapabilityNames(snapshot) {
|
|
33
|
+
const names = [];
|
|
34
|
+
if (snapshot.generic_jobs_enabled) {
|
|
35
|
+
names.push("generic_jobs");
|
|
36
|
+
}
|
|
37
|
+
for (const jobType of snapshot.job_types) {
|
|
38
|
+
names.push(`job_type:${jobType}`);
|
|
39
|
+
}
|
|
40
|
+
if (snapshot.gpu.status === "available" && snapshot.gpu.count > 0) {
|
|
41
|
+
names.push("gpu");
|
|
42
|
+
for (const vendor of snapshot.gpu.vendors) {
|
|
43
|
+
names.push(`gpu.${vendor}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (hasCuda(snapshot)) {
|
|
47
|
+
names.push("cuda");
|
|
48
|
+
}
|
|
49
|
+
if (softwareAvailable(snapshot.software.docker)) {
|
|
50
|
+
names.push("software.docker");
|
|
51
|
+
}
|
|
52
|
+
if (softwareAvailable(snapshot.software["docker-nvidia"])) {
|
|
53
|
+
names.push("docker.nvidia");
|
|
54
|
+
}
|
|
55
|
+
if (softwareAvailable(snapshot.software.blender)) {
|
|
56
|
+
names.push("software.blender");
|
|
57
|
+
}
|
|
58
|
+
if (softwareAvailable(snapshot.software.ffmpeg)) {
|
|
59
|
+
names.push("software.ffmpeg");
|
|
60
|
+
}
|
|
61
|
+
return sortedUnique(names);
|
|
62
|
+
}
|
|
63
|
+
export function buildMswarmSchedulerMatchInput(snapshot) {
|
|
64
|
+
return {
|
|
65
|
+
schema_version: MSWARM_CAPABILITY_SCHEMA_VERSION,
|
|
66
|
+
snapshot_id: snapshot.snapshot_id,
|
|
67
|
+
node_id: snapshot.node_id,
|
|
68
|
+
updated_at: snapshot.captured_at,
|
|
69
|
+
generic_jobs_enabled: snapshot.generic_jobs_enabled,
|
|
70
|
+
available_job_types: sortedUnique(snapshot.job_types),
|
|
71
|
+
trust_modes: sortedUnique(snapshot.trust_modes),
|
|
72
|
+
resources: {
|
|
73
|
+
gpu_count: snapshot.gpu.count,
|
|
74
|
+
gpu_vendors: sortedUnique(snapshot.gpu.vendors),
|
|
75
|
+
...(Number.isFinite(snapshot.gpu.max_vram_gb) ? { max_vram_gb: snapshot.gpu.max_vram_gb } : {}),
|
|
76
|
+
has_cuda: hasCuda(snapshot),
|
|
77
|
+
software: {
|
|
78
|
+
docker_nvidia: softwareAvailable(snapshot.software["docker-nvidia"]),
|
|
79
|
+
blender: softwareAvailable(snapshot.software.blender),
|
|
80
|
+
ffmpeg: softwareAvailable(snapshot.software.ffmpeg),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
capabilities: buildMswarmCapabilityNames(snapshot),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function projectMswarmPublicCapabilities(snapshot) {
|
|
87
|
+
return {
|
|
88
|
+
schema_version: MSWARM_CAPABILITY_SCHEMA_VERSION,
|
|
89
|
+
snapshot_id: snapshot.snapshot_id,
|
|
90
|
+
captured_at: snapshot.captured_at,
|
|
91
|
+
generic_jobs_enabled: snapshot.generic_jobs_enabled,
|
|
92
|
+
job_types: sortedUnique(snapshot.job_types),
|
|
93
|
+
accelerators: {
|
|
94
|
+
gpu: {
|
|
95
|
+
available: snapshot.gpu.status === "available" && snapshot.gpu.count > 0,
|
|
96
|
+
count: snapshot.gpu.count,
|
|
97
|
+
vendors: sortedUnique(snapshot.gpu.vendors),
|
|
98
|
+
cuda: hasCuda(snapshot),
|
|
99
|
+
vram_tier: publicVramTier(snapshot.gpu.max_vram_gb),
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
software: {
|
|
103
|
+
docker_nvidia: {
|
|
104
|
+
available: softwareAvailable(snapshot.software["docker-nvidia"]),
|
|
105
|
+
status: snapshot.software["docker-nvidia"].status,
|
|
106
|
+
},
|
|
107
|
+
blender: {
|
|
108
|
+
available: softwareAvailable(snapshot.software.blender),
|
|
109
|
+
status: snapshot.software.blender.status,
|
|
110
|
+
},
|
|
111
|
+
ffmpeg: {
|
|
112
|
+
available: softwareAvailable(snapshot.software.ffmpeg),
|
|
113
|
+
status: snapshot.software.ffmpeg.status,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
capabilities: buildMswarmCapabilityNames(snapshot),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function buildMswarmPrivateCapabilityCatalogEntry(snapshot) {
|
|
120
|
+
return {
|
|
121
|
+
node_id: snapshot.node_id,
|
|
122
|
+
snapshot_id: snapshot.snapshot_id,
|
|
123
|
+
captured_at: snapshot.captured_at,
|
|
124
|
+
snapshot,
|
|
125
|
+
scheduler_match: buildMswarmSchedulerMatchInput(snapshot),
|
|
126
|
+
public_projection: projectMswarmPublicCapabilities(snapshot),
|
|
127
|
+
};
|
|
128
|
+
}
|