@blokjs/shared 2.1.0 → 2.2.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/AgentSessionContracts.d.ts +316 -0
- package/dist/AgentSessionContracts.js +331 -0
- package/dist/BlokError.d.ts +23 -0
- package/dist/BlokError.js +65 -0
- package/dist/CapabilityContracts.d.ts +91 -0
- package/dist/CapabilityContracts.js +104 -0
- package/dist/CapabilityManifest.d.ts +67 -0
- package/dist/CapabilityManifest.js +172 -0
- package/dist/EnforcementContracts.d.ts +61 -0
- package/dist/EnforcementContracts.js +17 -0
- package/dist/EnforcementProfileContracts.d.ts +36 -0
- package/dist/EnforcementProfileContracts.js +55 -0
- package/dist/EvidenceContracts.d.ts +884 -0
- package/dist/EvidenceContracts.js +237 -0
- package/dist/GitCapabilityContracts.d.ts +103 -0
- package/dist/GitCapabilityContracts.js +222 -0
- package/dist/GlobalLogger.d.ts +2 -0
- package/dist/GlobalLogger.js +4 -0
- package/dist/GraphContracts.d.ts +1643 -0
- package/dist/GraphContracts.js +333 -0
- package/dist/InteractionContracts.d.ts +76 -0
- package/dist/InteractionContracts.js +218 -0
- package/dist/JoinContracts.d.ts +593 -0
- package/dist/JoinContracts.js +329 -0
- package/dist/NodeBase.d.ts +20 -0
- package/dist/NodeBase.js +57 -6
- package/dist/PermissionAlgebra.d.ts +51 -0
- package/dist/PermissionAlgebra.js +125 -0
- package/dist/PolicyContracts.d.ts +184 -0
- package/dist/PolicyContracts.js +1 -0
- package/dist/ProcessCapabilityContracts.d.ts +146 -0
- package/dist/ProcessCapabilityContracts.js +263 -0
- package/dist/RuntimeContracts.d.ts +125 -0
- package/dist/RuntimeContracts.js +108 -0
- package/dist/SecretContracts.d.ts +43 -0
- package/dist/SecretContracts.js +1 -0
- package/dist/WasiComponentContracts.d.ts +582 -0
- package/dist/WasiComponentContracts.js +192 -0
- package/dist/WorkflowBindingContracts.d.ts +1062 -0
- package/dist/WorkflowBindingContracts.js +339 -0
- package/dist/index.d.ts +33 -2
- package/dist/index.js +21 -2
- package/dist/types/LoggerContext.d.ts +7 -0
- package/dist/utils/Mapper.d.ts +14 -0
- package/dist/utils/Mapper.js +32 -0
- package/package.json +3 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The JavaScript execution targets that a project may select. */
|
|
3
|
+
export declare const JAVASCRIPT_RUNTIMES: readonly ["node", "bun", "deno"];
|
|
4
|
+
export declare const JavaScriptRuntimeSchema: z.ZodEnum<["node", "bun", "deno"]>;
|
|
5
|
+
export type JavaScriptRuntime = z.infer<typeof JavaScriptRuntimeSchema>;
|
|
6
|
+
/** Package managers are independent from the JavaScript execution target. */
|
|
7
|
+
export declare const PACKAGE_MANAGERS: readonly ["npm", "pnpm", "yarn", "bun"];
|
|
8
|
+
export declare const PackageManagerSchema: z.ZodEnum<["npm", "pnpm", "yarn", "bun"]>;
|
|
9
|
+
export type PackageManager = z.infer<typeof PackageManagerSchema>;
|
|
10
|
+
/** Canonical runtime kinds used by the runner registry and step `type`. */
|
|
11
|
+
export declare const RUNTIME_KINDS: readonly ["nodejs", "bun", "deno", "python3", "kotlin", "go", "java", "rust", "php", "csharp", "ruby", "swift", "dart", "elixir", "docker", "wasm", "wasi"];
|
|
12
|
+
export declare const RuntimeKindSchema: z.ZodEnum<["nodejs", "bun", "deno", "python3", "kotlin", "go", "java", "rust", "php", "csharp", "ruby", "swift", "dart", "elixir", "docker", "wasm", "wasi"]>;
|
|
13
|
+
export type RuntimeKind = z.infer<typeof RuntimeKindSchema>;
|
|
14
|
+
/** Inputs accepted at compatibility boundaries before canonicalization. */
|
|
15
|
+
export declare const RuntimeKindInputSchema: z.ZodEnum<["nodejs", "bun", "deno", "python3", "kotlin", "go", "java", "rust", "php", "csharp", "ruby", "swift", "dart", "elixir", "docker", "wasm", "wasi", "node", "typescript", "ts"]>;
|
|
16
|
+
export type RuntimeKindInput = z.infer<typeof RuntimeKindInputSchema>;
|
|
17
|
+
export type RuntimeDiagnostic = {
|
|
18
|
+
code: "deprecated-runtime-alias";
|
|
19
|
+
severity: "warning";
|
|
20
|
+
input: string;
|
|
21
|
+
canonical: string;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
export type RuntimeNormalization = {
|
|
25
|
+
kind: RuntimeKind;
|
|
26
|
+
diagnostic?: RuntimeDiagnostic;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Normalize a runtime kind at a load/registry boundary.
|
|
30
|
+
*
|
|
31
|
+
* `runtime.nodejs` is the canonical step spelling. `node`, `typescript`, and
|
|
32
|
+
* `ts` remain accepted for old workflows and CLI/config bridges, but callers
|
|
33
|
+
* receive a diagnostic so compatibility never looks like an engine switch.
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeRuntimeKind(input: string): RuntimeNormalization;
|
|
36
|
+
/** Normalize the project-level JavaScript selection vocabulary. */
|
|
37
|
+
export declare function normalizeJavaScriptRuntime(input: string): {
|
|
38
|
+
runtime: JavaScriptRuntime;
|
|
39
|
+
diagnostic?: RuntimeDiagnostic;
|
|
40
|
+
};
|
|
41
|
+
/** Convert a project selection to the public step/registry kind. */
|
|
42
|
+
export declare function runtimeKindForJavaScriptRuntime(runtime: JavaScriptRuntime): RuntimeKind;
|
|
43
|
+
/** The runtime-specific capability declaration shared by workers and tooling. */
|
|
44
|
+
export declare const RuntimeCapabilityManifestSchema: z.ZodObject<{
|
|
45
|
+
runtime: z.ZodEnum<["node", "bun", "deno"]>;
|
|
46
|
+
version: z.ZodString;
|
|
47
|
+
protocolVersion: z.ZodString;
|
|
48
|
+
moduleFormats: z.ZodArray<z.ZodEnum<["esm", "commonjs"]>, "many">;
|
|
49
|
+
typescriptExecution: z.ZodEnum<["native", "transpile", "loader"]>;
|
|
50
|
+
npmCompatibility: z.ZodEnum<["native", "compatibility", "none"]>;
|
|
51
|
+
permissions: z.ZodObject<{
|
|
52
|
+
filesystem: z.ZodEnum<["none", "read", "read-write"]>;
|
|
53
|
+
network: z.ZodEnum<["none", "restricted", "unrestricted"]>;
|
|
54
|
+
environment: z.ZodEnum<["none", "declared", "unrestricted"]>;
|
|
55
|
+
subprocess: z.ZodEnum<["none", "declared", "unrestricted"]>;
|
|
56
|
+
ffi: z.ZodEnum<["none", "declared", "unrestricted"]>;
|
|
57
|
+
secrets: z.ZodEnum<["none", "declared"]>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
network: "none" | "restricted" | "unrestricted";
|
|
60
|
+
filesystem: "read" | "none" | "read-write";
|
|
61
|
+
secrets: "declared" | "none";
|
|
62
|
+
environment: "declared" | "none" | "unrestricted";
|
|
63
|
+
subprocess: "declared" | "none" | "unrestricted";
|
|
64
|
+
ffi: "declared" | "none" | "unrestricted";
|
|
65
|
+
}, {
|
|
66
|
+
network: "none" | "restricted" | "unrestricted";
|
|
67
|
+
filesystem: "read" | "none" | "read-write";
|
|
68
|
+
secrets: "declared" | "none";
|
|
69
|
+
environment: "declared" | "none" | "unrestricted";
|
|
70
|
+
subprocess: "declared" | "none" | "unrestricted";
|
|
71
|
+
ffi: "declared" | "none" | "unrestricted";
|
|
72
|
+
}>;
|
|
73
|
+
cancellation: z.ZodBoolean;
|
|
74
|
+
streaming: z.ZodBoolean;
|
|
75
|
+
maxMessageBytes: z.ZodNumber;
|
|
76
|
+
}, "strict", z.ZodTypeAny, {
|
|
77
|
+
version: string;
|
|
78
|
+
streaming: boolean;
|
|
79
|
+
runtime: "node" | "bun" | "deno";
|
|
80
|
+
protocolVersion: string;
|
|
81
|
+
moduleFormats: ("esm" | "commonjs")[];
|
|
82
|
+
typescriptExecution: "native" | "transpile" | "loader";
|
|
83
|
+
npmCompatibility: "none" | "native" | "compatibility";
|
|
84
|
+
permissions: {
|
|
85
|
+
network: "none" | "restricted" | "unrestricted";
|
|
86
|
+
filesystem: "read" | "none" | "read-write";
|
|
87
|
+
secrets: "declared" | "none";
|
|
88
|
+
environment: "declared" | "none" | "unrestricted";
|
|
89
|
+
subprocess: "declared" | "none" | "unrestricted";
|
|
90
|
+
ffi: "declared" | "none" | "unrestricted";
|
|
91
|
+
};
|
|
92
|
+
cancellation: boolean;
|
|
93
|
+
maxMessageBytes: number;
|
|
94
|
+
}, {
|
|
95
|
+
version: string;
|
|
96
|
+
streaming: boolean;
|
|
97
|
+
runtime: "node" | "bun" | "deno";
|
|
98
|
+
protocolVersion: string;
|
|
99
|
+
moduleFormats: ("esm" | "commonjs")[];
|
|
100
|
+
typescriptExecution: "native" | "transpile" | "loader";
|
|
101
|
+
npmCompatibility: "none" | "native" | "compatibility";
|
|
102
|
+
permissions: {
|
|
103
|
+
network: "none" | "restricted" | "unrestricted";
|
|
104
|
+
filesystem: "read" | "none" | "read-write";
|
|
105
|
+
secrets: "declared" | "none";
|
|
106
|
+
environment: "declared" | "none" | "unrestricted";
|
|
107
|
+
subprocess: "declared" | "none" | "unrestricted";
|
|
108
|
+
ffi: "declared" | "none" | "unrestricted";
|
|
109
|
+
};
|
|
110
|
+
cancellation: boolean;
|
|
111
|
+
maxMessageBytes: number;
|
|
112
|
+
}>;
|
|
113
|
+
export type RuntimeCapabilityManifest = z.infer<typeof RuntimeCapabilityManifestSchema>;
|
|
114
|
+
/** Project configuration fields for JS runtime selection and package policy. */
|
|
115
|
+
export declare const JavaScriptRuntimeSelectionSchema: z.ZodObject<{
|
|
116
|
+
runtime: z.ZodDefault<z.ZodEnum<["node", "bun", "deno"]>>;
|
|
117
|
+
packageManager: z.ZodOptional<z.ZodEnum<["npm", "pnpm", "yarn", "bun"]>>;
|
|
118
|
+
}, "strict", z.ZodTypeAny, {
|
|
119
|
+
runtime: "node" | "bun" | "deno";
|
|
120
|
+
packageManager?: "bun" | "npm" | "pnpm" | "yarn" | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
runtime?: "node" | "bun" | "deno" | undefined;
|
|
123
|
+
packageManager?: "bun" | "npm" | "pnpm" | "yarn" | undefined;
|
|
124
|
+
}>;
|
|
125
|
+
export type JavaScriptRuntimeSelection = z.infer<typeof JavaScriptRuntimeSelectionSchema>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The JavaScript execution targets that a project may select. */
|
|
3
|
+
export const JAVASCRIPT_RUNTIMES = ["node", "bun", "deno"];
|
|
4
|
+
export const JavaScriptRuntimeSchema = z.enum(JAVASCRIPT_RUNTIMES);
|
|
5
|
+
/** Package managers are independent from the JavaScript execution target. */
|
|
6
|
+
export const PACKAGE_MANAGERS = ["npm", "pnpm", "yarn", "bun"];
|
|
7
|
+
export const PackageManagerSchema = z.enum(PACKAGE_MANAGERS);
|
|
8
|
+
/** Canonical runtime kinds used by the runner registry and step `type`. */
|
|
9
|
+
export const RUNTIME_KINDS = [
|
|
10
|
+
"nodejs",
|
|
11
|
+
"bun",
|
|
12
|
+
"deno",
|
|
13
|
+
"python3",
|
|
14
|
+
"kotlin",
|
|
15
|
+
"go",
|
|
16
|
+
"java",
|
|
17
|
+
"rust",
|
|
18
|
+
"php",
|
|
19
|
+
"csharp",
|
|
20
|
+
"ruby",
|
|
21
|
+
"swift",
|
|
22
|
+
"dart",
|
|
23
|
+
"elixir",
|
|
24
|
+
"docker",
|
|
25
|
+
"wasm",
|
|
26
|
+
"wasi",
|
|
27
|
+
];
|
|
28
|
+
export const RuntimeKindSchema = z.enum(RUNTIME_KINDS);
|
|
29
|
+
/** Inputs accepted at compatibility boundaries before canonicalization. */
|
|
30
|
+
export const RuntimeKindInputSchema = z.enum([...RUNTIME_KINDS, "node", "typescript", "ts"]);
|
|
31
|
+
const RUNTIME_KIND_ALIASES = {
|
|
32
|
+
node: "nodejs",
|
|
33
|
+
typescript: "nodejs",
|
|
34
|
+
ts: "nodejs",
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a runtime kind at a load/registry boundary.
|
|
38
|
+
*
|
|
39
|
+
* `runtime.nodejs` is the canonical step spelling. `node`, `typescript`, and
|
|
40
|
+
* `ts` remain accepted for old workflows and CLI/config bridges, but callers
|
|
41
|
+
* receive a diagnostic so compatibility never looks like an engine switch.
|
|
42
|
+
*/
|
|
43
|
+
export function normalizeRuntimeKind(input) {
|
|
44
|
+
const alias = RUNTIME_KIND_ALIASES[input.toLowerCase()];
|
|
45
|
+
if (alias) {
|
|
46
|
+
return {
|
|
47
|
+
kind: alias,
|
|
48
|
+
diagnostic: {
|
|
49
|
+
code: "deprecated-runtime-alias",
|
|
50
|
+
severity: "warning",
|
|
51
|
+
input,
|
|
52
|
+
canonical: alias,
|
|
53
|
+
message: `Runtime alias "${input}" is deprecated; use "${alias}" for step execution. The selected JavaScript engine is not changed by this compatibility mapping.`,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return { kind: RuntimeKindSchema.parse(input) };
|
|
58
|
+
}
|
|
59
|
+
/** Normalize the project-level JavaScript selection vocabulary. */
|
|
60
|
+
export function normalizeJavaScriptRuntime(input) {
|
|
61
|
+
const normalized = input.toLowerCase();
|
|
62
|
+
if (normalized === "nodejs" || normalized === "typescript" || normalized === "ts") {
|
|
63
|
+
return {
|
|
64
|
+
runtime: "node",
|
|
65
|
+
diagnostic: {
|
|
66
|
+
code: "deprecated-runtime-alias",
|
|
67
|
+
severity: "warning",
|
|
68
|
+
input,
|
|
69
|
+
canonical: "node",
|
|
70
|
+
message: `Project runtime alias "${input}" is deprecated; use "node" in .blok/config.json.`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return { runtime: JavaScriptRuntimeSchema.parse(normalized) };
|
|
75
|
+
}
|
|
76
|
+
/** Convert a project selection to the public step/registry kind. */
|
|
77
|
+
export function runtimeKindForJavaScriptRuntime(runtime) {
|
|
78
|
+
return runtime === "node" ? "nodejs" : runtime;
|
|
79
|
+
}
|
|
80
|
+
/** The runtime-specific capability declaration shared by workers and tooling. */
|
|
81
|
+
export const RuntimeCapabilityManifestSchema = z
|
|
82
|
+
.object({
|
|
83
|
+
runtime: JavaScriptRuntimeSchema,
|
|
84
|
+
version: z.string().min(1),
|
|
85
|
+
protocolVersion: z.string().min(1),
|
|
86
|
+
moduleFormats: z.array(z.enum(["esm", "commonjs"])).min(1),
|
|
87
|
+
typescriptExecution: z.enum(["native", "transpile", "loader"]),
|
|
88
|
+
npmCompatibility: z.enum(["native", "compatibility", "none"]),
|
|
89
|
+
permissions: z.object({
|
|
90
|
+
filesystem: z.enum(["none", "read", "read-write"]),
|
|
91
|
+
network: z.enum(["none", "restricted", "unrestricted"]),
|
|
92
|
+
environment: z.enum(["none", "declared", "unrestricted"]),
|
|
93
|
+
subprocess: z.enum(["none", "declared", "unrestricted"]),
|
|
94
|
+
ffi: z.enum(["none", "declared", "unrestricted"]),
|
|
95
|
+
secrets: z.enum(["none", "declared"]),
|
|
96
|
+
}),
|
|
97
|
+
cancellation: z.boolean(),
|
|
98
|
+
streaming: z.boolean(),
|
|
99
|
+
maxMessageBytes: z.number().int().positive(),
|
|
100
|
+
})
|
|
101
|
+
.strict();
|
|
102
|
+
/** Project configuration fields for JS runtime selection and package policy. */
|
|
103
|
+
export const JavaScriptRuntimeSelectionSchema = z
|
|
104
|
+
.object({
|
|
105
|
+
runtime: JavaScriptRuntimeSchema.default("node"),
|
|
106
|
+
packageManager: PackageManagerSchema.optional(),
|
|
107
|
+
})
|
|
108
|
+
.strict();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { InteractionAttribution, PolicyContext } from "./PolicyContracts.js";
|
|
2
|
+
export declare const SECRET_REFERENCE_VERSION: "1";
|
|
3
|
+
/** An opaque name, never a credential or resolved value. */
|
|
4
|
+
export interface SecretRef {
|
|
5
|
+
readonly version: typeof SECRET_REFERENCE_VERSION;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SecretRequest extends PolicyContext {
|
|
9
|
+
readonly reference: SecretRef;
|
|
10
|
+
readonly requestId: string;
|
|
11
|
+
}
|
|
12
|
+
/** A deliberately non-serializable capability for trusted node code. */
|
|
13
|
+
export interface SecretLease {
|
|
14
|
+
readonly reference: SecretRef;
|
|
15
|
+
readonly leaseId: string;
|
|
16
|
+
readonly expiresAt: string;
|
|
17
|
+
readonly read: () => string;
|
|
18
|
+
}
|
|
19
|
+
export interface SecretResolver {
|
|
20
|
+
resolve(request: SecretRequest): Promise<SecretLease>;
|
|
21
|
+
}
|
|
22
|
+
export type SecretResolutionFailure = "SECRET_NOT_AUTHORIZED" | "SECRET_NOT_FOUND" | "SECRET_EXPIRED" | "SECRET_REVOKED" | "SECRET_RESOLVER_UNAVAILABLE";
|
|
23
|
+
export interface SecretResolutionAuditEvent {
|
|
24
|
+
readonly version: "1";
|
|
25
|
+
readonly eventType: "secret.resolve";
|
|
26
|
+
readonly eventId: string;
|
|
27
|
+
readonly timestamp: string;
|
|
28
|
+
readonly correlationId: string;
|
|
29
|
+
readonly principalId?: string;
|
|
30
|
+
readonly sessionId?: string;
|
|
31
|
+
readonly turnId?: string;
|
|
32
|
+
readonly attribution?: InteractionAttribution;
|
|
33
|
+
readonly workflow: PolicyContext["workflow"];
|
|
34
|
+
readonly step: PolicyContext["step"];
|
|
35
|
+
readonly reference: SecretRef;
|
|
36
|
+
readonly leaseId?: string;
|
|
37
|
+
readonly outcome: "success" | "failure";
|
|
38
|
+
readonly errorCode?: SecretResolutionFailure;
|
|
39
|
+
readonly redaction: {
|
|
40
|
+
readonly redacted: true;
|
|
41
|
+
readonly fields: readonly ["value"];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SECRET_REFERENCE_VERSION = "1";
|