@reasonlayer/sdk 0.0.1-rc.3
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 +201 -0
- package/README.md +35 -0
- package/bin/rl.mjs +75 -0
- package/dist/builder.d.ts +38 -0
- package/dist/builder.js +41 -0
- package/dist/bundler/index.d.ts +32 -0
- package/dist/bundler/index.js +143 -0
- package/dist/bundler/node.d.ts +10 -0
- package/dist/bundler/node.js +55 -0
- package/dist/cli/args.d.ts +9 -0
- package/dist/cli/args.js +71 -0
- package/dist/cli/config.d.ts +38 -0
- package/dist/cli/config.js +94 -0
- package/dist/cli/convex.d.ts +9 -0
- package/dist/cli/convex.js +25 -0
- package/dist/cli/format.d.ts +11 -0
- package/dist/cli/format.js +140 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +721 -0
- package/dist/cli/keychain.d.ts +21 -0
- package/dist/cli/keychain.js +100 -0
- package/dist/cli/operations.d.ts +106 -0
- package/dist/cli/operations.js +623 -0
- package/dist/cli/sdk-package.d.ts +18 -0
- package/dist/cli/sdk-package.js +45 -0
- package/dist/cli/storage-upload.d.ts +9 -0
- package/dist/cli/storage-upload.js +21 -0
- package/dist/cli/watcher-compile.d.ts +1 -0
- package/dist/cli/watcher-compile.js +20 -0
- package/dist/cli/watcher-process.d.ts +1 -0
- package/dist/cli/watcher-process.js +312 -0
- package/dist/cli/workspace-files.d.ts +12 -0
- package/dist/cli/workspace-files.js +91 -0
- package/dist/cli/workspace-local.d.ts +27 -0
- package/dist/cli/workspace-local.js +310 -0
- package/dist/cli/workspace-session.d.ts +13 -0
- package/dist/cli/workspace-session.js +12 -0
- package/dist/compile.d.ts +27 -0
- package/dist/compile.js +834 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/schedule-validation.d.ts +1 -0
- package/dist/schedule-validation.js +16 -0
- package/dist/selector-schema.d.ts +26 -0
- package/dist/selector-schema.js +780 -0
- package/dist/selectors.d.ts +25 -0
- package/dist/selectors.js +99 -0
- package/dist/testkit.d.ts +32 -0
- package/dist/testkit.js +161 -0
- package/dist/types.d.ts +184 -0
- package/dist/types.js +110 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.d.ts +4937 -0
- package/node_modules/@reasonlayer/integrations/dist/catalog.js +20 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.d.ts +3014 -0
- package/node_modules/@reasonlayer/integrations/dist/generated/slack.js +3101 -0
- package/node_modules/@reasonlayer/integrations/dist/index.d.ts +2 -0
- package/node_modules/@reasonlayer/integrations/dist/index.js +1 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.d.ts +44 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/definitions.js +52 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.d.ts +7 -0
- package/node_modules/@reasonlayer/integrations/dist/internal/transport.js +48 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.d.ts +1 -0
- package/node_modules/@reasonlayer/integrations/dist/testkit.js +1 -0
- package/node_modules/@reasonlayer/integrations/package.json +26 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.d.ts +7 -0
- package/node_modules/@reasonlayer/protocol/dist/environments.js +7 -0
- package/node_modules/@reasonlayer/protocol/dist/events.d.ts +313 -0
- package/node_modules/@reasonlayer/protocol/dist/events.js +20 -0
- package/node_modules/@reasonlayer/protocol/dist/index.d.ts +18 -0
- package/node_modules/@reasonlayer/protocol/dist/index.js +9 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.d.ts +252 -0
- package/node_modules/@reasonlayer/protocol/dist/ir.js +116 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.d.ts +5 -0
- package/node_modules/@reasonlayer/protocol/dist/permissions.js +30 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.d.ts +617 -0
- package/node_modules/@reasonlayer/protocol/dist/readmodels.js +36 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.d.ts +67 -0
- package/node_modules/@reasonlayer/protocol/dist/runtime.js +66 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/scheduling.js +126 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.d.ts +23 -0
- package/node_modules/@reasonlayer/protocol/dist/selector.js +77 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.d.ts +69 -0
- package/node_modules/@reasonlayer/protocol/dist/tasks.js +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.d.ts +6 -0
- package/node_modules/@reasonlayer/protocol/dist/validate.js +18 -0
- package/node_modules/@reasonlayer/protocol/package.json +21 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.d.ts +13 -0
- package/node_modules/@reasonlayer/runner/dist/environment-materializer.js +92 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.d.ts +17 -0
- package/node_modules/@reasonlayer/runner/dist/flue-transcript.js +182 -0
- package/node_modules/@reasonlayer/runner/dist/index.d.ts +184 -0
- package/node_modules/@reasonlayer/runner/dist/index.js +884 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.d.ts +15 -0
- package/node_modules/@reasonlayer/runner/dist/mcp-supervisor.js +142 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.d.ts +36 -0
- package/node_modules/@reasonlayer/runner/dist/sandbox-env.js +171 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.d.ts +1 -0
- package/node_modules/@reasonlayer/runner/dist/task-child.js +72 -0
- package/node_modules/@reasonlayer/runner/package.json +21 -0
- package/package.json +65 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR contract (spec §5). The five step kinds are the complete V2 language —
|
|
3
|
+
* no legacy kinds, no version negotiation. Both the SDK compiler and the engine import these
|
|
4
|
+
* types, so drift is a compile error.
|
|
5
|
+
*/
|
|
6
|
+
/** JSON Schema draft-07, output mode (spec §4.4). */
|
|
7
|
+
export type JsonSchema = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Cross-step data flow (spec §4.2). `mapItem` is only valid inside a map
|
|
10
|
+
* child's selectors; the compiler enforces scope.
|
|
11
|
+
*/
|
|
12
|
+
export type SelectorIR = {
|
|
13
|
+
kind: "input";
|
|
14
|
+
path: string[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: "step";
|
|
17
|
+
stepId: string;
|
|
18
|
+
path: string[];
|
|
19
|
+
} | {
|
|
20
|
+
kind: "variable";
|
|
21
|
+
name: string;
|
|
22
|
+
path: string[];
|
|
23
|
+
} | {
|
|
24
|
+
kind: "literal";
|
|
25
|
+
value: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "object";
|
|
28
|
+
fields: Record<string, SelectorIR>;
|
|
29
|
+
} | {
|
|
30
|
+
kind: "array";
|
|
31
|
+
items: SelectorIR[];
|
|
32
|
+
} | {
|
|
33
|
+
kind: "mapItem";
|
|
34
|
+
path: string[];
|
|
35
|
+
};
|
|
36
|
+
export interface RetryPolicyIR {
|
|
37
|
+
maxAttempts: number;
|
|
38
|
+
backoffMs?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface SecretRefIR {
|
|
41
|
+
kind: "secret";
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
export interface VariableIR {
|
|
45
|
+
name: string;
|
|
46
|
+
schemaJson: JsonSchema;
|
|
47
|
+
defaultJson: unknown;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const VARIABLE_NAME_PATTERN: RegExp;
|
|
51
|
+
export interface DeviceRefIR {
|
|
52
|
+
kind: "device";
|
|
53
|
+
handle: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const STEP_ID_PATTERN: RegExp;
|
|
56
|
+
export interface LocalMcpServerIR {
|
|
57
|
+
kind: "command";
|
|
58
|
+
command: string;
|
|
59
|
+
/**
|
|
60
|
+
* Command MCP servers are currently expected to expose a streamable HTTP
|
|
61
|
+
* endpoint on the assigned PORT. Stdio commands need a bridge before they
|
|
62
|
+
* can be run by the production supervisor.
|
|
63
|
+
*/
|
|
64
|
+
transport: "http";
|
|
65
|
+
env?: Record<string, SecretRefIR>;
|
|
66
|
+
}
|
|
67
|
+
export interface RemoteMcpServerIR {
|
|
68
|
+
kind: "url";
|
|
69
|
+
url: string;
|
|
70
|
+
headers?: Record<string, SecretRefIR>;
|
|
71
|
+
}
|
|
72
|
+
export type McpServerIR = LocalMcpServerIR | RemoteMcpServerIR;
|
|
73
|
+
export interface EnvironmentFileIR {
|
|
74
|
+
/** Absolute path inside the sandbox template/rootfs. */
|
|
75
|
+
path: string;
|
|
76
|
+
/** sha256 of contentBase64 decoded bytes. */
|
|
77
|
+
sha256: string;
|
|
78
|
+
/** Small file contents captured by the SDK build. */
|
|
79
|
+
contentBase64: string;
|
|
80
|
+
}
|
|
81
|
+
export interface EnvironmentIR {
|
|
82
|
+
/** sha256 over the canonical declaration JSON, excluding this field. */
|
|
83
|
+
envHash: string;
|
|
84
|
+
npm?: string[];
|
|
85
|
+
pip?: string[];
|
|
86
|
+
apt?: string[];
|
|
87
|
+
/** Extra executable names to verify, e.g. apt package ripgrep -> binary rg. */
|
|
88
|
+
binaries?: string[];
|
|
89
|
+
files?: EnvironmentFileIR[];
|
|
90
|
+
setup?: string[];
|
|
91
|
+
mcp?: Record<string, McpServerIR>;
|
|
92
|
+
}
|
|
93
|
+
export type EnvironmentStatusKind = "building" | "ready" | "failed";
|
|
94
|
+
export interface EnvironmentMcpToolInventory {
|
|
95
|
+
tools: string[];
|
|
96
|
+
mode: "fake" | "runtime-deferred" | "verified";
|
|
97
|
+
note?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface EnvironmentProvenance {
|
|
100
|
+
mode: "fake" | "e2b";
|
|
101
|
+
checkedAt: number;
|
|
102
|
+
declaredCliChecks: string[];
|
|
103
|
+
cliChecks?: Record<string, {
|
|
104
|
+
path: string;
|
|
105
|
+
exitCode: number;
|
|
106
|
+
}>;
|
|
107
|
+
buildInfo?: unknown;
|
|
108
|
+
mcpTools: Record<string, EnvironmentMcpToolInventory>;
|
|
109
|
+
}
|
|
110
|
+
export interface EnvironmentStatus {
|
|
111
|
+
envHash: string;
|
|
112
|
+
status: EnvironmentStatusKind;
|
|
113
|
+
templateAlias?: string;
|
|
114
|
+
error?: string;
|
|
115
|
+
provenance?: EnvironmentProvenance;
|
|
116
|
+
}
|
|
117
|
+
export type EnvironmentDeclaration = Omit<EnvironmentIR, "envHash">;
|
|
118
|
+
export declare function stableJson(value: unknown): string;
|
|
119
|
+
export declare function environmentDeclaration(environment: EnvironmentIR): EnvironmentDeclaration;
|
|
120
|
+
export declare function canonicalEnvironmentDeclarationJson(environment: EnvironmentIR): string;
|
|
121
|
+
export declare function mcpUrlEnvName(name: string): string;
|
|
122
|
+
export declare function shellQuote(value: string): string;
|
|
123
|
+
export interface ParsedNpmPackage {
|
|
124
|
+
packageName: string;
|
|
125
|
+
version: string;
|
|
126
|
+
}
|
|
127
|
+
export interface ParsedPipPackage {
|
|
128
|
+
packageName: string;
|
|
129
|
+
version: string;
|
|
130
|
+
}
|
|
131
|
+
export declare function parseExactNpmPackage(spec: string): ParsedNpmPackage | null;
|
|
132
|
+
export declare function parseExactPipPackage(spec: string): ParsedPipPackage | null;
|
|
133
|
+
export declare function executableNameFromPackageName(packageName: string): string;
|
|
134
|
+
export declare function executableNameFromNpmSpec(spec: string): string;
|
|
135
|
+
export declare function executableNameFromPipSpec(spec: string): string;
|
|
136
|
+
export declare function firstCommandToken(command: string): string;
|
|
137
|
+
export declare function declaredEnvironmentExecutables(environment: EnvironmentIR): string[];
|
|
138
|
+
/** Execution host shape (spec §4.1), independent of the current provider adapter. */
|
|
139
|
+
export type HostIR = {
|
|
140
|
+
kind: "cloud";
|
|
141
|
+
} | {
|
|
142
|
+
kind: "device";
|
|
143
|
+
handle: string;
|
|
144
|
+
};
|
|
145
|
+
export type ReviewViewIR = {
|
|
146
|
+
kind: "json";
|
|
147
|
+
} | {
|
|
148
|
+
kind: "builtin";
|
|
149
|
+
name: string;
|
|
150
|
+
} | {
|
|
151
|
+
kind: "custom";
|
|
152
|
+
moduleRef: string;
|
|
153
|
+
exportName: string;
|
|
154
|
+
};
|
|
155
|
+
export interface CodeStepIR {
|
|
156
|
+
kind: "code";
|
|
157
|
+
id: string;
|
|
158
|
+
input: SelectorIR;
|
|
159
|
+
outputSchemaJson: JsonSchema;
|
|
160
|
+
moduleRef: string;
|
|
161
|
+
exportName: string;
|
|
162
|
+
host: HostIR;
|
|
163
|
+
browserProfile?: string;
|
|
164
|
+
timeoutMs?: number;
|
|
165
|
+
retries?: RetryPolicyIR;
|
|
166
|
+
secrets?: string[];
|
|
167
|
+
environment?: EnvironmentIR;
|
|
168
|
+
}
|
|
169
|
+
export interface AgentStepIR {
|
|
170
|
+
kind: "agent";
|
|
171
|
+
id: string;
|
|
172
|
+
input: SelectorIR;
|
|
173
|
+
outputSchemaJson: JsonSchema;
|
|
174
|
+
framework: "flue";
|
|
175
|
+
/** Canonical managed integration action ids injected as Flue tools. */
|
|
176
|
+
catalogTools: string[];
|
|
177
|
+
moduleRef: string;
|
|
178
|
+
exportName: string;
|
|
179
|
+
host: HostIR;
|
|
180
|
+
browserProfile?: string;
|
|
181
|
+
timeoutMs?: number;
|
|
182
|
+
retries?: RetryPolicyIR;
|
|
183
|
+
secrets?: string[];
|
|
184
|
+
environment?: EnvironmentIR;
|
|
185
|
+
}
|
|
186
|
+
export interface ReviewStepIR {
|
|
187
|
+
kind: "review";
|
|
188
|
+
id: string;
|
|
189
|
+
input: SelectorIR;
|
|
190
|
+
outputSchemaJson: JsonSchema;
|
|
191
|
+
view: ReviewViewIR;
|
|
192
|
+
deadlineMs?: number;
|
|
193
|
+
}
|
|
194
|
+
/** A managed catalog action. Provider and connection details never enter workflow IR. */
|
|
195
|
+
export interface ActionStepIR {
|
|
196
|
+
kind: "action";
|
|
197
|
+
id: string;
|
|
198
|
+
actionId: string;
|
|
199
|
+
actionVersion: string;
|
|
200
|
+
input: SelectorIR;
|
|
201
|
+
inputSchemaJson: JsonSchema;
|
|
202
|
+
outputSchemaJson: JsonSchema;
|
|
203
|
+
timeoutMs?: number;
|
|
204
|
+
retries?: RetryPolicyIR;
|
|
205
|
+
}
|
|
206
|
+
export interface TriggerIR {
|
|
207
|
+
kind: "schedule";
|
|
208
|
+
name: string;
|
|
209
|
+
cron: string;
|
|
210
|
+
timezone: string;
|
|
211
|
+
}
|
|
212
|
+
/** The map child is itself a code/agent/review step; its selectors may use `mapItem`. */
|
|
213
|
+
export type MapChildStepIR = CodeStepIR | AgentStepIR | ReviewStepIR;
|
|
214
|
+
export interface MapStepIR {
|
|
215
|
+
kind: "map";
|
|
216
|
+
id: string;
|
|
217
|
+
/** The list to fan out over. */
|
|
218
|
+
over: SelectorIR;
|
|
219
|
+
/** Per-item identity for dedupe + resume; evaluated against the item (mapItem scope), must yield a string. */
|
|
220
|
+
key: SelectorIR;
|
|
221
|
+
step: MapChildStepIR;
|
|
222
|
+
concurrency?: number;
|
|
223
|
+
retries?: RetryPolicyIR;
|
|
224
|
+
}
|
|
225
|
+
export type StepIR = CodeStepIR | AgentStepIR | ReviewStepIR | ActionStepIR | MapStepIR;
|
|
226
|
+
export interface WorkflowIR {
|
|
227
|
+
schemaVersion: 1;
|
|
228
|
+
id: string;
|
|
229
|
+
/** Authoring metadata surfaced in the console. */
|
|
230
|
+
description?: string;
|
|
231
|
+
/** Org-side placement handles declared with device(...). */
|
|
232
|
+
devices?: DeviceRefIR[];
|
|
233
|
+
/** Org-side vault handles declared with secret(...). */
|
|
234
|
+
secrets?: SecretRefIR[];
|
|
235
|
+
/** Typed data-plane values resolved and snapshotted when a run starts. */
|
|
236
|
+
variables?: VariableIR[];
|
|
237
|
+
/** Named declarations reconciled by (workflow, name) when a version publishes. */
|
|
238
|
+
triggers?: TriggerIR[];
|
|
239
|
+
inputSchemaJson: JsonSchema;
|
|
240
|
+
outputSchemaJson: JsonSchema;
|
|
241
|
+
steps: Record<string, StepIR>;
|
|
242
|
+
output: SelectorIR;
|
|
243
|
+
}
|
|
244
|
+
/** Map children share one bundle entrypoint per map step. */
|
|
245
|
+
export declare function mapChildId(mapId: string): string;
|
|
246
|
+
/** Managed placement rule (spec §4.1): all cloud steps run through the E2B claim path. */
|
|
247
|
+
export declare function isCloudHostedStep(step: {
|
|
248
|
+
kind: string;
|
|
249
|
+
host?: HostIR;
|
|
250
|
+
}): boolean;
|
|
251
|
+
export declare function executableStepEnvironment(step: CodeStepIR | AgentStepIR | MapChildStepIR): EnvironmentIR | undefined;
|
|
252
|
+
export declare function collectWorkflowEnvironments(ir: WorkflowIR): EnvironmentIR[];
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IR contract (spec §5). The five step kinds are the complete V2 language —
|
|
3
|
+
* no legacy kinds, no version negotiation. Both the SDK compiler and the engine import these
|
|
4
|
+
* types, so drift is a compile error.
|
|
5
|
+
*/
|
|
6
|
+
export const VARIABLE_NAME_PATTERN = /^[a-z][a-z0-9-]*$/;
|
|
7
|
+
export const STEP_ID_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
8
|
+
export function stableJson(value) {
|
|
9
|
+
if (value === null || typeof value !== "object")
|
|
10
|
+
return JSON.stringify(value);
|
|
11
|
+
if (Array.isArray(value))
|
|
12
|
+
return `[${value.map((item) => stableJson(item)).join(",")}]`;
|
|
13
|
+
const entries = Object.entries(value)
|
|
14
|
+
.filter(([, nested]) => nested !== undefined)
|
|
15
|
+
.sort(([a], [b]) => a.localeCompare(b));
|
|
16
|
+
return `{${entries.map(([key, nested]) => `${JSON.stringify(key)}:${stableJson(nested)}`).join(",")}}`;
|
|
17
|
+
}
|
|
18
|
+
export function environmentDeclaration(environment) {
|
|
19
|
+
const { envHash: _envHash, ...declaration } = environment;
|
|
20
|
+
return declaration;
|
|
21
|
+
}
|
|
22
|
+
export function canonicalEnvironmentDeclarationJson(environment) {
|
|
23
|
+
return stableJson(environmentDeclaration(environment));
|
|
24
|
+
}
|
|
25
|
+
export function mcpUrlEnvName(name) {
|
|
26
|
+
return `RL_MCP_${name.replace(/[^a-zA-Z0-9_]/g, "_").toUpperCase()}_URL`;
|
|
27
|
+
}
|
|
28
|
+
export function shellQuote(value) {
|
|
29
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
30
|
+
}
|
|
31
|
+
export function parseExactNpmPackage(spec) {
|
|
32
|
+
const versionAt = spec.lastIndexOf("@");
|
|
33
|
+
if (versionAt <= 0)
|
|
34
|
+
return null;
|
|
35
|
+
const packageName = spec.slice(0, versionAt);
|
|
36
|
+
const version = spec.slice(versionAt + 1);
|
|
37
|
+
if (!packageName || !version || version === "latest")
|
|
38
|
+
return null;
|
|
39
|
+
if (!/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/.test(version))
|
|
40
|
+
return null;
|
|
41
|
+
return { packageName, version };
|
|
42
|
+
}
|
|
43
|
+
export function parseExactPipPackage(spec) {
|
|
44
|
+
const markerIndex = spec.indexOf("==");
|
|
45
|
+
if (markerIndex <= 0)
|
|
46
|
+
return null;
|
|
47
|
+
const packageName = spec.slice(0, markerIndex);
|
|
48
|
+
const version = spec.slice(markerIndex + 2);
|
|
49
|
+
if (!packageName || !/^[0-9][0-9A-Za-z.!+_-]*$/.test(version) || version.includes("*")) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return { packageName, version };
|
|
53
|
+
}
|
|
54
|
+
export function executableNameFromPackageName(packageName) {
|
|
55
|
+
return packageName.split("/").pop() ?? packageName;
|
|
56
|
+
}
|
|
57
|
+
export function executableNameFromNpmSpec(spec) {
|
|
58
|
+
return executableNameFromPackageName(parseExactNpmPackage(spec)?.packageName ?? spec);
|
|
59
|
+
}
|
|
60
|
+
export function executableNameFromPipSpec(spec) {
|
|
61
|
+
return executableNameFromPackageName(parseExactPipPackage(spec)?.packageName ?? spec);
|
|
62
|
+
}
|
|
63
|
+
export function firstCommandToken(command) {
|
|
64
|
+
return command.trim().split(/\s+/)[0] ?? command;
|
|
65
|
+
}
|
|
66
|
+
export function declaredEnvironmentExecutables(environment) {
|
|
67
|
+
return [
|
|
68
|
+
...(environment.npm ?? []).map(executableNameFromNpmSpec),
|
|
69
|
+
...(environment.pip ?? []).map(executableNameFromPipSpec),
|
|
70
|
+
...(environment.binaries ?? []),
|
|
71
|
+
...Object.values(environment.mcp ?? {})
|
|
72
|
+
.filter((server) => server.kind === "command")
|
|
73
|
+
.map((server) => firstCommandToken(server.command)),
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
/** Map children share one bundle entrypoint per map step. */
|
|
77
|
+
export function mapChildId(mapId) {
|
|
78
|
+
return `${mapId}:item`;
|
|
79
|
+
}
|
|
80
|
+
/** Managed placement rule (spec §4.1): all cloud steps run through the E2B claim path. */
|
|
81
|
+
export function isCloudHostedStep(step) {
|
|
82
|
+
if (step.kind === "action")
|
|
83
|
+
return true;
|
|
84
|
+
return (step.kind === "code" || step.kind === "agent") && step.host?.kind === "cloud";
|
|
85
|
+
}
|
|
86
|
+
export function executableStepEnvironment(step) {
|
|
87
|
+
if ((step.kind === "code" || step.kind === "agent") && step.environment) {
|
|
88
|
+
return step.environment;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
function stepRequiresEnvironmentTemplate(step) {
|
|
93
|
+
if (step.kind !== "code" && step.kind !== "agent")
|
|
94
|
+
return false;
|
|
95
|
+
if (!step.environment)
|
|
96
|
+
return false;
|
|
97
|
+
return isCloudHostedStep(step);
|
|
98
|
+
}
|
|
99
|
+
export function collectWorkflowEnvironments(ir) {
|
|
100
|
+
const byHash = new Map();
|
|
101
|
+
for (const step of Object.values(ir.steps)) {
|
|
102
|
+
const root = (step.kind === "code" || step.kind === "agent") && stepRequiresEnvironmentTemplate(step)
|
|
103
|
+
? step.environment
|
|
104
|
+
: undefined;
|
|
105
|
+
if (root)
|
|
106
|
+
byHash.set(root.envHash, root);
|
|
107
|
+
if (step.kind === "map") {
|
|
108
|
+
const child = stepRequiresEnvironmentTemplate(step.step)
|
|
109
|
+
? executableStepEnvironment(step.step)
|
|
110
|
+
: undefined;
|
|
111
|
+
if (child)
|
|
112
|
+
byHash.set(child.envHash, child);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return [...byHash.values()].sort((a, b) => a.envHash.localeCompare(b.envHash));
|
|
116
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const PERMISSIONS: readonly ["org:read", "members:read", "members:write", "tokens:read", "tokens:write", "workflows:read", "workflows:delete", "workspace:write", "deployments:read", "deployments:write", "runs:read", "runs:write", "tasks:claim", "transcripts:read", "reviews:read", "reviews:resolve", "triggers:read", "triggers:write", "secrets:read", "secrets:write", "variables:read", "variables:write", "devices:read", "devices:write", "alerts:read", "alerts:write", "integrations:read", "integrations:write"];
|
|
2
|
+
export type Permission = (typeof PERMISSIONS)[number];
|
|
3
|
+
type PermissionResource = Permission extends `${infer Resource}:${string}` ? Resource : never;
|
|
4
|
+
export type Scope = Permission | `${PermissionResource}:*` | "*";
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const PERMISSIONS = [
|
|
2
|
+
"org:read",
|
|
3
|
+
"members:read",
|
|
4
|
+
"members:write",
|
|
5
|
+
"tokens:read",
|
|
6
|
+
"tokens:write",
|
|
7
|
+
"workflows:read",
|
|
8
|
+
"workflows:delete",
|
|
9
|
+
"workspace:write",
|
|
10
|
+
"deployments:read",
|
|
11
|
+
"deployments:write",
|
|
12
|
+
"runs:read",
|
|
13
|
+
"runs:write",
|
|
14
|
+
"tasks:claim",
|
|
15
|
+
"transcripts:read",
|
|
16
|
+
"reviews:read",
|
|
17
|
+
"reviews:resolve",
|
|
18
|
+
"triggers:read",
|
|
19
|
+
"triggers:write",
|
|
20
|
+
"secrets:read",
|
|
21
|
+
"secrets:write",
|
|
22
|
+
"variables:read",
|
|
23
|
+
"variables:write",
|
|
24
|
+
"devices:read",
|
|
25
|
+
"devices:write",
|
|
26
|
+
"alerts:read",
|
|
27
|
+
"alerts:write",
|
|
28
|
+
"integrations:read",
|
|
29
|
+
"integrations:write",
|
|
30
|
+
];
|