@ericsanchezok/meta-protocol 0.0.0-dev-202603260727
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/.turbo/turbo-typecheck.log +1 -0
- package/dist/bash.d.ts +89 -0
- package/dist/bash.js +40 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.js +1 -0
- package/dist/env.d.ts +16 -0
- package/dist/env.js +17 -0
- package/dist/envelope.d.ts +50 -0
- package/dist/envelope.js +23 -0
- package/dist/error.d.ts +39 -0
- package/dist/error.js +24 -0
- package/dist/host.d.ts +90 -0
- package/dist/host.js +27 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/process.d.ts +274 -0
- package/dist/process.js +89 -0
- package/package.json +30 -0
- package/script/publish.ts +32 -0
- package/src/bash.ts +49 -0
- package/src/client.ts +13 -0
- package/src/env.ts +24 -0
- package/src/envelope.ts +30 -0
- package/src/error.ts +27 -0
- package/src/host.ts +34 -0
- package/src/index.ts +7 -0
- package/src/process.ts +106 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$ tsc --noEmit
|
package/dist/bash.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolBash {
|
|
3
|
+
const ExecutePayload: z.ZodObject<{
|
|
4
|
+
command: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
8
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
yieldMs: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
type ExecutePayload = z.infer<typeof ExecutePayload>;
|
|
12
|
+
const ResultMetadata: z.ZodObject<{
|
|
13
|
+
output: z.ZodOptional<z.ZodString>;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
exit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
timedOut: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
21
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
22
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
local: "local";
|
|
24
|
+
remote: "remote";
|
|
25
|
+
}>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
type ResultMetadata = z.infer<typeof ResultMetadata>;
|
|
28
|
+
const Result: z.ZodObject<{
|
|
29
|
+
title: z.ZodString;
|
|
30
|
+
metadata: z.ZodObject<{
|
|
31
|
+
output: z.ZodOptional<z.ZodString>;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
exit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
timedOut: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
39
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
40
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
41
|
+
local: "local";
|
|
42
|
+
remote: "remote";
|
|
43
|
+
}>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
output: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type Result = z.infer<typeof Result>;
|
|
48
|
+
const ExecuteRequest: z.ZodObject<{
|
|
49
|
+
version: z.ZodLiteral<1>;
|
|
50
|
+
requestID: z.ZodString;
|
|
51
|
+
envID: z.ZodString;
|
|
52
|
+
tool: z.ZodLiteral<"bash">;
|
|
53
|
+
action: z.ZodLiteral<"execute">;
|
|
54
|
+
payload: z.ZodObject<{
|
|
55
|
+
command: z.ZodString;
|
|
56
|
+
description: z.ZodString;
|
|
57
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
59
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
yieldMs: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
type ExecuteRequest = z.infer<typeof ExecuteRequest>;
|
|
64
|
+
const ExecuteResult: z.ZodObject<{
|
|
65
|
+
version: z.ZodLiteral<1>;
|
|
66
|
+
requestID: z.ZodString;
|
|
67
|
+
ok: z.ZodLiteral<true>;
|
|
68
|
+
result: z.ZodObject<{
|
|
69
|
+
title: z.ZodString;
|
|
70
|
+
metadata: z.ZodObject<{
|
|
71
|
+
output: z.ZodOptional<z.ZodString>;
|
|
72
|
+
description: z.ZodOptional<z.ZodString>;
|
|
73
|
+
exit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
74
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
background: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
timedOut: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
79
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
80
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
local: "local";
|
|
82
|
+
remote: "remote";
|
|
83
|
+
}>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
output: z.ZodString;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
type ExecuteResult = z.infer<typeof ExecuteResult>;
|
|
89
|
+
}
|
package/dist/bash.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { MetaProtocolEnvelope } from "./envelope";
|
|
3
|
+
import { MetaProtocolEnv } from "./env";
|
|
4
|
+
export var MetaProtocolBash;
|
|
5
|
+
(function (MetaProtocolBash) {
|
|
6
|
+
MetaProtocolBash.ExecutePayload = z.object({
|
|
7
|
+
command: z.string(),
|
|
8
|
+
description: z.string(),
|
|
9
|
+
timeout: z.number().optional(),
|
|
10
|
+
workdir: z.string().optional(),
|
|
11
|
+
background: z.boolean().optional(),
|
|
12
|
+
yieldMs: z.number().optional(),
|
|
13
|
+
});
|
|
14
|
+
MetaProtocolBash.ResultMetadata = z.object({
|
|
15
|
+
output: z.string().optional(),
|
|
16
|
+
description: z.string().optional(),
|
|
17
|
+
exit: z.number().nullable().optional(),
|
|
18
|
+
processId: MetaProtocolEnv.ProcessID.optional(),
|
|
19
|
+
background: z.boolean().optional(),
|
|
20
|
+
timedOut: z.boolean().optional(),
|
|
21
|
+
durationMs: z.number().optional(),
|
|
22
|
+
hostSessionID: MetaProtocolEnv.HostSessionID.optional(),
|
|
23
|
+
envID: MetaProtocolEnv.EnvID.optional(),
|
|
24
|
+
backend: z.enum(["local", "remote"]).optional(),
|
|
25
|
+
});
|
|
26
|
+
MetaProtocolBash.Result = z.object({
|
|
27
|
+
title: z.string(),
|
|
28
|
+
metadata: MetaProtocolBash.ResultMetadata,
|
|
29
|
+
output: z.string(),
|
|
30
|
+
});
|
|
31
|
+
MetaProtocolBash.ExecuteRequest = MetaProtocolEnvelope.RequestBase.extend({
|
|
32
|
+
tool: z.literal("bash"),
|
|
33
|
+
action: z.literal("execute"),
|
|
34
|
+
payload: MetaProtocolBash.ExecutePayload,
|
|
35
|
+
});
|
|
36
|
+
MetaProtocolBash.ExecuteResult = MetaProtocolEnvelope.ResultBase.extend({
|
|
37
|
+
ok: z.literal(true),
|
|
38
|
+
result: MetaProtocolBash.Result,
|
|
39
|
+
});
|
|
40
|
+
})(MetaProtocolBash || (MetaProtocolBash = {}));
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MetaProtocolBash } from "./bash";
|
|
2
|
+
import type { MetaProtocolEnv } from "./env";
|
|
3
|
+
import type { MetaProtocolProcess } from "./process";
|
|
4
|
+
export declare namespace MetaProtocolClient {
|
|
5
|
+
interface ExecutionClient {
|
|
6
|
+
executeBash(envID: MetaProtocolEnv.EnvID, input: MetaProtocolBash.ExecutePayload): Promise<MetaProtocolBash.Result>;
|
|
7
|
+
executeProcess(envID: MetaProtocolEnv.EnvID, input: MetaProtocolProcess.ExecutePayload): Promise<MetaProtocolProcess.Result>;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolEnv {
|
|
3
|
+
const EnvID: z.ZodString;
|
|
4
|
+
type EnvID = z.infer<typeof EnvID>;
|
|
5
|
+
const ProcessID: z.ZodString;
|
|
6
|
+
type ProcessID = z.infer<typeof ProcessID>;
|
|
7
|
+
const HostSessionID: z.ZodString;
|
|
8
|
+
type HostSessionID = z.infer<typeof HostSessionID>;
|
|
9
|
+
type Target = {
|
|
10
|
+
kind: "local";
|
|
11
|
+
} | {
|
|
12
|
+
kind: "remote";
|
|
13
|
+
envID: EnvID;
|
|
14
|
+
};
|
|
15
|
+
function resolve(envID?: string): Target;
|
|
16
|
+
}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export var MetaProtocolEnv;
|
|
3
|
+
(function (MetaProtocolEnv) {
|
|
4
|
+
MetaProtocolEnv.EnvID = z.string().min(1).describe("Execution environment ID");
|
|
5
|
+
MetaProtocolEnv.ProcessID = z.string().min(1).describe("Opaque process identifier");
|
|
6
|
+
MetaProtocolEnv.HostSessionID = z.string().min(1).describe("Remote host session identifier");
|
|
7
|
+
function resolve(envID) {
|
|
8
|
+
if (!envID) {
|
|
9
|
+
return { kind: "local" };
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
kind: "remote",
|
|
13
|
+
envID,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
MetaProtocolEnv.resolve = resolve;
|
|
17
|
+
})(MetaProtocolEnv || (MetaProtocolEnv = {}));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolEnvelope {
|
|
3
|
+
const Tool: z.ZodEnum<{
|
|
4
|
+
bash: "bash";
|
|
5
|
+
process: "process";
|
|
6
|
+
}>;
|
|
7
|
+
type Tool = z.infer<typeof Tool>;
|
|
8
|
+
const RequestBase: z.ZodObject<{
|
|
9
|
+
version: z.ZodLiteral<1>;
|
|
10
|
+
requestID: z.ZodString;
|
|
11
|
+
envID: z.ZodString;
|
|
12
|
+
tool: z.ZodEnum<{
|
|
13
|
+
bash: "bash";
|
|
14
|
+
process: "process";
|
|
15
|
+
}>;
|
|
16
|
+
action: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
type RequestBase = z.infer<typeof RequestBase>;
|
|
19
|
+
const ResultBase: z.ZodObject<{
|
|
20
|
+
version: z.ZodLiteral<1>;
|
|
21
|
+
requestID: z.ZodString;
|
|
22
|
+
ok: z.ZodBoolean;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
type ResultBase = z.infer<typeof ResultBase>;
|
|
25
|
+
const ErrorResult: z.ZodObject<{
|
|
26
|
+
version: z.ZodLiteral<1>;
|
|
27
|
+
requestID: z.ZodString;
|
|
28
|
+
ok: z.ZodLiteral<false>;
|
|
29
|
+
error: z.ZodObject<{
|
|
30
|
+
code: z.ZodEnum<{
|
|
31
|
+
env_not_found: "env_not_found";
|
|
32
|
+
env_inactive: "env_inactive";
|
|
33
|
+
device_offline: "device_offline";
|
|
34
|
+
request_timeout: "request_timeout";
|
|
35
|
+
request_cancelled: "request_cancelled";
|
|
36
|
+
remote_execution_error: "remote_execution_error";
|
|
37
|
+
invalid_request: "invalid_request";
|
|
38
|
+
unsupported_tool: "unsupported_tool";
|
|
39
|
+
unsupported_action: "unsupported_action";
|
|
40
|
+
unsupported_capability: "unsupported_capability";
|
|
41
|
+
host_internal_error: "host_internal_error";
|
|
42
|
+
stale_process_handle: "stale_process_handle";
|
|
43
|
+
stdin_unavailable: "stdin_unavailable";
|
|
44
|
+
}>;
|
|
45
|
+
message: z.ZodString;
|
|
46
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
type ErrorResult = z.infer<typeof ErrorResult>;
|
|
50
|
+
}
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { MetaProtocolEnv } from "./env";
|
|
3
|
+
import { MetaProtocolError } from "./error";
|
|
4
|
+
export var MetaProtocolEnvelope;
|
|
5
|
+
(function (MetaProtocolEnvelope) {
|
|
6
|
+
MetaProtocolEnvelope.Tool = z.enum(["bash", "process"]);
|
|
7
|
+
MetaProtocolEnvelope.RequestBase = z.object({
|
|
8
|
+
version: z.literal(1),
|
|
9
|
+
requestID: z.string().min(1),
|
|
10
|
+
envID: MetaProtocolEnv.EnvID,
|
|
11
|
+
tool: MetaProtocolEnvelope.Tool,
|
|
12
|
+
action: z.string().min(1),
|
|
13
|
+
});
|
|
14
|
+
MetaProtocolEnvelope.ResultBase = z.object({
|
|
15
|
+
version: z.literal(1),
|
|
16
|
+
requestID: z.string().min(1),
|
|
17
|
+
ok: z.boolean(),
|
|
18
|
+
});
|
|
19
|
+
MetaProtocolEnvelope.ErrorResult = MetaProtocolEnvelope.ResultBase.extend({
|
|
20
|
+
ok: z.literal(false),
|
|
21
|
+
error: MetaProtocolError.Shape,
|
|
22
|
+
});
|
|
23
|
+
})(MetaProtocolEnvelope || (MetaProtocolEnvelope = {}));
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolError {
|
|
3
|
+
const Code: z.ZodEnum<{
|
|
4
|
+
env_not_found: "env_not_found";
|
|
5
|
+
env_inactive: "env_inactive";
|
|
6
|
+
device_offline: "device_offline";
|
|
7
|
+
request_timeout: "request_timeout";
|
|
8
|
+
request_cancelled: "request_cancelled";
|
|
9
|
+
remote_execution_error: "remote_execution_error";
|
|
10
|
+
invalid_request: "invalid_request";
|
|
11
|
+
unsupported_tool: "unsupported_tool";
|
|
12
|
+
unsupported_action: "unsupported_action";
|
|
13
|
+
unsupported_capability: "unsupported_capability";
|
|
14
|
+
host_internal_error: "host_internal_error";
|
|
15
|
+
stale_process_handle: "stale_process_handle";
|
|
16
|
+
stdin_unavailable: "stdin_unavailable";
|
|
17
|
+
}>;
|
|
18
|
+
type Code = z.infer<typeof Code>;
|
|
19
|
+
const Shape: z.ZodObject<{
|
|
20
|
+
code: z.ZodEnum<{
|
|
21
|
+
env_not_found: "env_not_found";
|
|
22
|
+
env_inactive: "env_inactive";
|
|
23
|
+
device_offline: "device_offline";
|
|
24
|
+
request_timeout: "request_timeout";
|
|
25
|
+
request_cancelled: "request_cancelled";
|
|
26
|
+
remote_execution_error: "remote_execution_error";
|
|
27
|
+
invalid_request: "invalid_request";
|
|
28
|
+
unsupported_tool: "unsupported_tool";
|
|
29
|
+
unsupported_action: "unsupported_action";
|
|
30
|
+
unsupported_capability: "unsupported_capability";
|
|
31
|
+
host_internal_error: "host_internal_error";
|
|
32
|
+
stale_process_handle: "stale_process_handle";
|
|
33
|
+
stdin_unavailable: "stdin_unavailable";
|
|
34
|
+
}>;
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
type Shape = z.infer<typeof Shape>;
|
|
39
|
+
}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export var MetaProtocolError;
|
|
3
|
+
(function (MetaProtocolError) {
|
|
4
|
+
MetaProtocolError.Code = z.enum([
|
|
5
|
+
"env_not_found",
|
|
6
|
+
"env_inactive",
|
|
7
|
+
"device_offline",
|
|
8
|
+
"request_timeout",
|
|
9
|
+
"request_cancelled",
|
|
10
|
+
"remote_execution_error",
|
|
11
|
+
"invalid_request",
|
|
12
|
+
"unsupported_tool",
|
|
13
|
+
"unsupported_action",
|
|
14
|
+
"unsupported_capability",
|
|
15
|
+
"host_internal_error",
|
|
16
|
+
"stale_process_handle",
|
|
17
|
+
"stdin_unavailable",
|
|
18
|
+
]);
|
|
19
|
+
MetaProtocolError.Shape = z.object({
|
|
20
|
+
code: MetaProtocolError.Code,
|
|
21
|
+
message: z.string(),
|
|
22
|
+
details: z.unknown().optional(),
|
|
23
|
+
});
|
|
24
|
+
})(MetaProtocolError || (MetaProtocolError = {}));
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolHost {
|
|
3
|
+
const Shell: z.ZodEnum<{
|
|
4
|
+
none: "none";
|
|
5
|
+
sh: "sh";
|
|
6
|
+
cmd: "cmd";
|
|
7
|
+
powershell: "powershell";
|
|
8
|
+
pwsh: "pwsh";
|
|
9
|
+
}>;
|
|
10
|
+
type Shell = z.infer<typeof Shell>;
|
|
11
|
+
const Runtime: z.ZodEnum<{
|
|
12
|
+
unknown: "unknown";
|
|
13
|
+
node: "node";
|
|
14
|
+
bun: "bun";
|
|
15
|
+
}>;
|
|
16
|
+
type Runtime = z.infer<typeof Runtime>;
|
|
17
|
+
const Capabilities: z.ZodObject<{
|
|
18
|
+
platform: z.ZodString;
|
|
19
|
+
arch: z.ZodString;
|
|
20
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
21
|
+
runtime: z.ZodEnum<{
|
|
22
|
+
unknown: "unknown";
|
|
23
|
+
node: "node";
|
|
24
|
+
bun: "bun";
|
|
25
|
+
}>;
|
|
26
|
+
defaultShell: z.ZodEnum<{
|
|
27
|
+
none: "none";
|
|
28
|
+
sh: "sh";
|
|
29
|
+
cmd: "cmd";
|
|
30
|
+
powershell: "powershell";
|
|
31
|
+
pwsh: "pwsh";
|
|
32
|
+
}>;
|
|
33
|
+
supportedShells: z.ZodArray<z.ZodEnum<{
|
|
34
|
+
none: "none";
|
|
35
|
+
sh: "sh";
|
|
36
|
+
cmd: "cmd";
|
|
37
|
+
powershell: "powershell";
|
|
38
|
+
pwsh: "pwsh";
|
|
39
|
+
}>>;
|
|
40
|
+
supportsPty: z.ZodBoolean;
|
|
41
|
+
supportsSendKeys: z.ZodBoolean;
|
|
42
|
+
supportsSoftKill: z.ZodBoolean;
|
|
43
|
+
supportsProcessGroups: z.ZodBoolean;
|
|
44
|
+
envCaseInsensitive: z.ZodBoolean;
|
|
45
|
+
lineEndings: z.ZodEnum<{
|
|
46
|
+
lf: "lf";
|
|
47
|
+
crlf: "crlf";
|
|
48
|
+
}>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
type Capabilities = z.infer<typeof Capabilities>;
|
|
51
|
+
const Hello: z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"host.hello">;
|
|
53
|
+
envID: z.ZodString;
|
|
54
|
+
hostSessionID: z.ZodString;
|
|
55
|
+
capabilities: z.ZodObject<{
|
|
56
|
+
platform: z.ZodString;
|
|
57
|
+
arch: z.ZodString;
|
|
58
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
59
|
+
runtime: z.ZodEnum<{
|
|
60
|
+
unknown: "unknown";
|
|
61
|
+
node: "node";
|
|
62
|
+
bun: "bun";
|
|
63
|
+
}>;
|
|
64
|
+
defaultShell: z.ZodEnum<{
|
|
65
|
+
none: "none";
|
|
66
|
+
sh: "sh";
|
|
67
|
+
cmd: "cmd";
|
|
68
|
+
powershell: "powershell";
|
|
69
|
+
pwsh: "pwsh";
|
|
70
|
+
}>;
|
|
71
|
+
supportedShells: z.ZodArray<z.ZodEnum<{
|
|
72
|
+
none: "none";
|
|
73
|
+
sh: "sh";
|
|
74
|
+
cmd: "cmd";
|
|
75
|
+
powershell: "powershell";
|
|
76
|
+
pwsh: "pwsh";
|
|
77
|
+
}>>;
|
|
78
|
+
supportsPty: z.ZodBoolean;
|
|
79
|
+
supportsSendKeys: z.ZodBoolean;
|
|
80
|
+
supportsSoftKill: z.ZodBoolean;
|
|
81
|
+
supportsProcessGroups: z.ZodBoolean;
|
|
82
|
+
envCaseInsensitive: z.ZodBoolean;
|
|
83
|
+
lineEndings: z.ZodEnum<{
|
|
84
|
+
lf: "lf";
|
|
85
|
+
crlf: "crlf";
|
|
86
|
+
}>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
type Hello = z.infer<typeof Hello>;
|
|
90
|
+
}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { MetaProtocolEnv } from "./env";
|
|
3
|
+
export var MetaProtocolHost;
|
|
4
|
+
(function (MetaProtocolHost) {
|
|
5
|
+
MetaProtocolHost.Shell = z.enum(["none", "sh", "cmd", "powershell", "pwsh"]);
|
|
6
|
+
MetaProtocolHost.Runtime = z.enum(["node", "bun", "unknown"]);
|
|
7
|
+
MetaProtocolHost.Capabilities = z.object({
|
|
8
|
+
platform: z.string(),
|
|
9
|
+
arch: z.string(),
|
|
10
|
+
hostname: z.string().optional(),
|
|
11
|
+
runtime: MetaProtocolHost.Runtime,
|
|
12
|
+
defaultShell: MetaProtocolHost.Shell,
|
|
13
|
+
supportedShells: z.array(MetaProtocolHost.Shell),
|
|
14
|
+
supportsPty: z.boolean(),
|
|
15
|
+
supportsSendKeys: z.boolean(),
|
|
16
|
+
supportsSoftKill: z.boolean(),
|
|
17
|
+
supportsProcessGroups: z.boolean(),
|
|
18
|
+
envCaseInsensitive: z.boolean(),
|
|
19
|
+
lineEndings: z.enum(["lf", "crlf"]),
|
|
20
|
+
});
|
|
21
|
+
MetaProtocolHost.Hello = z.object({
|
|
22
|
+
type: z.literal("host.hello"),
|
|
23
|
+
envID: MetaProtocolEnv.EnvID,
|
|
24
|
+
hostSessionID: MetaProtocolEnv.HostSessionID,
|
|
25
|
+
capabilities: MetaProtocolHost.Capabilities,
|
|
26
|
+
});
|
|
27
|
+
})(MetaProtocolHost || (MetaProtocolHost = {}));
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace MetaProtocolProcess {
|
|
3
|
+
const Action: z.ZodEnum<{
|
|
4
|
+
list: "list";
|
|
5
|
+
poll: "poll";
|
|
6
|
+
log: "log";
|
|
7
|
+
write: "write";
|
|
8
|
+
"send-keys": "send-keys";
|
|
9
|
+
kill: "kill";
|
|
10
|
+
clear: "clear";
|
|
11
|
+
remove: "remove";
|
|
12
|
+
}>;
|
|
13
|
+
type Action = z.infer<typeof Action>;
|
|
14
|
+
const ProcessState: z.ZodEnum<{
|
|
15
|
+
running: "running";
|
|
16
|
+
completed: "completed";
|
|
17
|
+
failed: "failed";
|
|
18
|
+
killed: "killed";
|
|
19
|
+
}>;
|
|
20
|
+
type ProcessState = z.infer<typeof ProcessState>;
|
|
21
|
+
const ActionStatus: z.ZodEnum<{
|
|
22
|
+
error: "error";
|
|
23
|
+
running: "running";
|
|
24
|
+
completed: "completed";
|
|
25
|
+
failed: "failed";
|
|
26
|
+
killed: "killed";
|
|
27
|
+
not_found: "not_found";
|
|
28
|
+
cleared: "cleared";
|
|
29
|
+
removed: "removed";
|
|
30
|
+
}>;
|
|
31
|
+
type ActionStatus = z.infer<typeof ActionStatus>;
|
|
32
|
+
const ProcessInfo: z.ZodObject<{
|
|
33
|
+
processId: z.ZodString;
|
|
34
|
+
status: z.ZodEnum<{
|
|
35
|
+
running: "running";
|
|
36
|
+
completed: "completed";
|
|
37
|
+
failed: "failed";
|
|
38
|
+
killed: "killed";
|
|
39
|
+
}>;
|
|
40
|
+
command: z.ZodString;
|
|
41
|
+
description: z.ZodOptional<z.ZodString>;
|
|
42
|
+
runtimeMs: z.ZodNumber;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
type ProcessInfo = z.infer<typeof ProcessInfo>;
|
|
45
|
+
const ExecutePayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
action: z.ZodLiteral<"list">;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
action: z.ZodLiteral<"poll">;
|
|
49
|
+
processId: z.ZodString;
|
|
50
|
+
block: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
action: z.ZodLiteral<"log">;
|
|
54
|
+
processId: z.ZodString;
|
|
55
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
action: z.ZodLiteral<"write">;
|
|
59
|
+
processId: z.ZodString;
|
|
60
|
+
data: z.ZodString;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
action: z.ZodLiteral<"send-keys">;
|
|
63
|
+
processId: z.ZodString;
|
|
64
|
+
keys: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
action: z.ZodLiteral<"kill">;
|
|
67
|
+
processId: z.ZodString;
|
|
68
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
69
|
+
action: z.ZodLiteral<"clear">;
|
|
70
|
+
processId: z.ZodString;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
action: z.ZodLiteral<"remove">;
|
|
73
|
+
processId: z.ZodString;
|
|
74
|
+
}, z.core.$strip>], "action">;
|
|
75
|
+
type ExecutePayload = z.infer<typeof ExecutePayload>;
|
|
76
|
+
const ResultMetadata: z.ZodObject<{
|
|
77
|
+
action: z.ZodEnum<{
|
|
78
|
+
list: "list";
|
|
79
|
+
poll: "poll";
|
|
80
|
+
log: "log";
|
|
81
|
+
write: "write";
|
|
82
|
+
"send-keys": "send-keys";
|
|
83
|
+
kill: "kill";
|
|
84
|
+
clear: "clear";
|
|
85
|
+
remove: "remove";
|
|
86
|
+
}>;
|
|
87
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
89
|
+
error: "error";
|
|
90
|
+
running: "running";
|
|
91
|
+
completed: "completed";
|
|
92
|
+
failed: "failed";
|
|
93
|
+
killed: "killed";
|
|
94
|
+
not_found: "not_found";
|
|
95
|
+
cleared: "cleared";
|
|
96
|
+
removed: "removed";
|
|
97
|
+
}>>;
|
|
98
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
command: z.ZodOptional<z.ZodString>;
|
|
100
|
+
description: z.ZodOptional<z.ZodString>;
|
|
101
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
103
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
104
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
local: "local";
|
|
106
|
+
remote: "remote";
|
|
107
|
+
}>>;
|
|
108
|
+
processes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
109
|
+
processId: z.ZodString;
|
|
110
|
+
status: z.ZodEnum<{
|
|
111
|
+
running: "running";
|
|
112
|
+
completed: "completed";
|
|
113
|
+
failed: "failed";
|
|
114
|
+
killed: "killed";
|
|
115
|
+
}>;
|
|
116
|
+
command: z.ZodString;
|
|
117
|
+
description: z.ZodOptional<z.ZodString>;
|
|
118
|
+
runtimeMs: z.ZodNumber;
|
|
119
|
+
}, z.core.$strip>>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
type ResultMetadata = z.infer<typeof ResultMetadata>;
|
|
122
|
+
const Result: z.ZodObject<{
|
|
123
|
+
title: z.ZodString;
|
|
124
|
+
metadata: z.ZodObject<{
|
|
125
|
+
action: z.ZodEnum<{
|
|
126
|
+
list: "list";
|
|
127
|
+
poll: "poll";
|
|
128
|
+
log: "log";
|
|
129
|
+
write: "write";
|
|
130
|
+
"send-keys": "send-keys";
|
|
131
|
+
kill: "kill";
|
|
132
|
+
clear: "clear";
|
|
133
|
+
remove: "remove";
|
|
134
|
+
}>;
|
|
135
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
136
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
137
|
+
error: "error";
|
|
138
|
+
running: "running";
|
|
139
|
+
completed: "completed";
|
|
140
|
+
failed: "failed";
|
|
141
|
+
killed: "killed";
|
|
142
|
+
not_found: "not_found";
|
|
143
|
+
cleared: "cleared";
|
|
144
|
+
removed: "removed";
|
|
145
|
+
}>>;
|
|
146
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
147
|
+
command: z.ZodOptional<z.ZodString>;
|
|
148
|
+
description: z.ZodOptional<z.ZodString>;
|
|
149
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
151
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
152
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
153
|
+
local: "local";
|
|
154
|
+
remote: "remote";
|
|
155
|
+
}>>;
|
|
156
|
+
processes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
157
|
+
processId: z.ZodString;
|
|
158
|
+
status: z.ZodEnum<{
|
|
159
|
+
running: "running";
|
|
160
|
+
completed: "completed";
|
|
161
|
+
failed: "failed";
|
|
162
|
+
killed: "killed";
|
|
163
|
+
}>;
|
|
164
|
+
command: z.ZodString;
|
|
165
|
+
description: z.ZodOptional<z.ZodString>;
|
|
166
|
+
runtimeMs: z.ZodNumber;
|
|
167
|
+
}, z.core.$strip>>>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
output: z.ZodString;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
type Result = z.infer<typeof Result>;
|
|
172
|
+
const ExecuteRequest: z.ZodObject<{
|
|
173
|
+
version: z.ZodLiteral<1>;
|
|
174
|
+
requestID: z.ZodString;
|
|
175
|
+
envID: z.ZodString;
|
|
176
|
+
tool: z.ZodLiteral<"process">;
|
|
177
|
+
action: z.ZodEnum<{
|
|
178
|
+
list: "list";
|
|
179
|
+
poll: "poll";
|
|
180
|
+
log: "log";
|
|
181
|
+
write: "write";
|
|
182
|
+
"send-keys": "send-keys";
|
|
183
|
+
kill: "kill";
|
|
184
|
+
clear: "clear";
|
|
185
|
+
remove: "remove";
|
|
186
|
+
}>;
|
|
187
|
+
payload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
188
|
+
action: z.ZodLiteral<"list">;
|
|
189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
190
|
+
action: z.ZodLiteral<"poll">;
|
|
191
|
+
processId: z.ZodString;
|
|
192
|
+
block: z.ZodOptional<z.ZodBoolean>;
|
|
193
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
195
|
+
action: z.ZodLiteral<"log">;
|
|
196
|
+
processId: z.ZodString;
|
|
197
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
198
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
199
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
200
|
+
action: z.ZodLiteral<"write">;
|
|
201
|
+
processId: z.ZodString;
|
|
202
|
+
data: z.ZodString;
|
|
203
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
204
|
+
action: z.ZodLiteral<"send-keys">;
|
|
205
|
+
processId: z.ZodString;
|
|
206
|
+
keys: z.ZodArray<z.ZodString>;
|
|
207
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
208
|
+
action: z.ZodLiteral<"kill">;
|
|
209
|
+
processId: z.ZodString;
|
|
210
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
211
|
+
action: z.ZodLiteral<"clear">;
|
|
212
|
+
processId: z.ZodString;
|
|
213
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
214
|
+
action: z.ZodLiteral<"remove">;
|
|
215
|
+
processId: z.ZodString;
|
|
216
|
+
}, z.core.$strip>], "action">;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
type ExecuteRequest = z.infer<typeof ExecuteRequest>;
|
|
219
|
+
const ExecuteResult: z.ZodObject<{
|
|
220
|
+
version: z.ZodLiteral<1>;
|
|
221
|
+
requestID: z.ZodString;
|
|
222
|
+
ok: z.ZodLiteral<true>;
|
|
223
|
+
result: z.ZodObject<{
|
|
224
|
+
title: z.ZodString;
|
|
225
|
+
metadata: z.ZodObject<{
|
|
226
|
+
action: z.ZodEnum<{
|
|
227
|
+
list: "list";
|
|
228
|
+
poll: "poll";
|
|
229
|
+
log: "log";
|
|
230
|
+
write: "write";
|
|
231
|
+
"send-keys": "send-keys";
|
|
232
|
+
kill: "kill";
|
|
233
|
+
clear: "clear";
|
|
234
|
+
remove: "remove";
|
|
235
|
+
}>;
|
|
236
|
+
processId: z.ZodOptional<z.ZodString>;
|
|
237
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
238
|
+
error: "error";
|
|
239
|
+
running: "running";
|
|
240
|
+
completed: "completed";
|
|
241
|
+
failed: "failed";
|
|
242
|
+
killed: "killed";
|
|
243
|
+
not_found: "not_found";
|
|
244
|
+
cleared: "cleared";
|
|
245
|
+
removed: "removed";
|
|
246
|
+
}>>;
|
|
247
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
248
|
+
command: z.ZodOptional<z.ZodString>;
|
|
249
|
+
description: z.ZodOptional<z.ZodString>;
|
|
250
|
+
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
251
|
+
hostSessionID: z.ZodOptional<z.ZodString>;
|
|
252
|
+
envID: z.ZodOptional<z.ZodString>;
|
|
253
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
254
|
+
local: "local";
|
|
255
|
+
remote: "remote";
|
|
256
|
+
}>>;
|
|
257
|
+
processes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
258
|
+
processId: z.ZodString;
|
|
259
|
+
status: z.ZodEnum<{
|
|
260
|
+
running: "running";
|
|
261
|
+
completed: "completed";
|
|
262
|
+
failed: "failed";
|
|
263
|
+
killed: "killed";
|
|
264
|
+
}>;
|
|
265
|
+
command: z.ZodString;
|
|
266
|
+
description: z.ZodOptional<z.ZodString>;
|
|
267
|
+
runtimeMs: z.ZodNumber;
|
|
268
|
+
}, z.core.$strip>>>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
output: z.ZodString;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
}, z.core.$strip>;
|
|
273
|
+
type ExecuteResult = z.infer<typeof ExecuteResult>;
|
|
274
|
+
}
|
package/dist/process.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { MetaProtocolEnvelope } from "./envelope";
|
|
3
|
+
import { MetaProtocolEnv } from "./env";
|
|
4
|
+
export var MetaProtocolProcess;
|
|
5
|
+
(function (MetaProtocolProcess) {
|
|
6
|
+
MetaProtocolProcess.Action = z.enum(["list", "poll", "log", "write", "send-keys", "kill", "clear", "remove"]);
|
|
7
|
+
MetaProtocolProcess.ProcessState = z.enum(["running", "completed", "failed", "killed"]);
|
|
8
|
+
MetaProtocolProcess.ActionStatus = z.enum([
|
|
9
|
+
"running",
|
|
10
|
+
"completed",
|
|
11
|
+
"failed",
|
|
12
|
+
"killed",
|
|
13
|
+
"not_found",
|
|
14
|
+
"error",
|
|
15
|
+
"cleared",
|
|
16
|
+
"removed",
|
|
17
|
+
]);
|
|
18
|
+
MetaProtocolProcess.ProcessInfo = z.object({
|
|
19
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
20
|
+
status: MetaProtocolProcess.ProcessState,
|
|
21
|
+
command: z.string(),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
runtimeMs: z.number(),
|
|
24
|
+
});
|
|
25
|
+
MetaProtocolProcess.ExecutePayload = z.discriminatedUnion("action", [
|
|
26
|
+
z.object({ action: z.literal("list") }),
|
|
27
|
+
z.object({
|
|
28
|
+
action: z.literal("poll"),
|
|
29
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
30
|
+
block: z.boolean().optional(),
|
|
31
|
+
timeout: z.number().optional(),
|
|
32
|
+
}),
|
|
33
|
+
z.object({
|
|
34
|
+
action: z.literal("log"),
|
|
35
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
36
|
+
offset: z.number().optional(),
|
|
37
|
+
limit: z.number().optional(),
|
|
38
|
+
}),
|
|
39
|
+
z.object({
|
|
40
|
+
action: z.literal("write"),
|
|
41
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
42
|
+
data: z.string(),
|
|
43
|
+
}),
|
|
44
|
+
z.object({
|
|
45
|
+
action: z.literal("send-keys"),
|
|
46
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
47
|
+
keys: z.array(z.string()),
|
|
48
|
+
}),
|
|
49
|
+
z.object({
|
|
50
|
+
action: z.literal("kill"),
|
|
51
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
52
|
+
}),
|
|
53
|
+
z.object({
|
|
54
|
+
action: z.literal("clear"),
|
|
55
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
56
|
+
}),
|
|
57
|
+
z.object({
|
|
58
|
+
action: z.literal("remove"),
|
|
59
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
MetaProtocolProcess.ResultMetadata = z.object({
|
|
63
|
+
action: MetaProtocolProcess.Action,
|
|
64
|
+
processId: MetaProtocolEnv.ProcessID.optional(),
|
|
65
|
+
status: MetaProtocolProcess.ActionStatus.optional(),
|
|
66
|
+
exitCode: z.number().optional(),
|
|
67
|
+
command: z.string().optional(),
|
|
68
|
+
description: z.string().optional(),
|
|
69
|
+
nextOffset: z.number().optional(),
|
|
70
|
+
hostSessionID: MetaProtocolEnv.HostSessionID.optional(),
|
|
71
|
+
envID: MetaProtocolEnv.EnvID.optional(),
|
|
72
|
+
backend: z.enum(["local", "remote"]).optional(),
|
|
73
|
+
processes: z.array(MetaProtocolProcess.ProcessInfo).optional(),
|
|
74
|
+
});
|
|
75
|
+
MetaProtocolProcess.Result = z.object({
|
|
76
|
+
title: z.string(),
|
|
77
|
+
metadata: MetaProtocolProcess.ResultMetadata,
|
|
78
|
+
output: z.string(),
|
|
79
|
+
});
|
|
80
|
+
MetaProtocolProcess.ExecuteRequest = MetaProtocolEnvelope.RequestBase.extend({
|
|
81
|
+
tool: z.literal("process"),
|
|
82
|
+
action: MetaProtocolProcess.Action,
|
|
83
|
+
payload: MetaProtocolProcess.ExecutePayload,
|
|
84
|
+
});
|
|
85
|
+
MetaProtocolProcess.ExecuteResult = MetaProtocolEnvelope.ResultBase.extend({
|
|
86
|
+
ok: z.literal(true),
|
|
87
|
+
result: MetaProtocolProcess.Result,
|
|
88
|
+
});
|
|
89
|
+
})(MetaProtocolProcess || (MetaProtocolProcess = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@ericsanchezok/meta-protocol",
|
|
4
|
+
"version": "0.0.0-dev-202603260727",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./*": {
|
|
14
|
+
"import": "./dist/*.js",
|
|
15
|
+
"types": "./dist/*.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"build": "tsc -p tsconfig.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"zod": "4.1.8"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@tsconfig/node22": "22.0.2",
|
|
27
|
+
"@types/node": "22.13.9",
|
|
28
|
+
"typescript": "5.8.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Script } from "@ericsanchezok/synergy-script"
|
|
3
|
+
import { $ } from "bun"
|
|
4
|
+
|
|
5
|
+
const dir = new URL("..", import.meta.url).pathname
|
|
6
|
+
process.chdir(dir)
|
|
7
|
+
|
|
8
|
+
await $`bun tsc`
|
|
9
|
+
const pkg = await import("../package.json").then((m) => m.default)
|
|
10
|
+
const original = JSON.parse(JSON.stringify(pkg))
|
|
11
|
+
for (const [key, value] of Object.entries(pkg.exports)) {
|
|
12
|
+
const source = typeof value === "string" ? value : (value as { import?: string }).import
|
|
13
|
+
if (!source || typeof source !== "string") continue
|
|
14
|
+
const file = source.replace("./src/", "./dist/").replace(".ts", "").replace(".js", "")
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
pkg.exports[key] = {
|
|
17
|
+
import: file + ".js",
|
|
18
|
+
types: file + ".d.ts",
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
await Bun.write("package.json", JSON.stringify(pkg, null, 2))
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const NPM_REGISTRY = "https://registry.npmjs.org"
|
|
25
|
+
await $`rm -f *.tgz`.nothrow()
|
|
26
|
+
await $`bun pm pack`
|
|
27
|
+
const tgz = (await $`ls *.tgz`.text()).trim()
|
|
28
|
+
const authFlag = process.env.NPM_TOKEN ? `--//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}` : ""
|
|
29
|
+
await $`npm publish ${tgz} --tag ${Script.channel} --registry ${NPM_REGISTRY} --access public ${authFlag}`
|
|
30
|
+
} finally {
|
|
31
|
+
await Bun.write("package.json", JSON.stringify(original, null, 2))
|
|
32
|
+
}
|
package/src/bash.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
import { MetaProtocolEnvelope } from "./envelope"
|
|
3
|
+
import { MetaProtocolEnv } from "./env"
|
|
4
|
+
|
|
5
|
+
export namespace MetaProtocolBash {
|
|
6
|
+
export const ExecutePayload = z.object({
|
|
7
|
+
command: z.string(),
|
|
8
|
+
description: z.string(),
|
|
9
|
+
timeout: z.number().optional(),
|
|
10
|
+
workdir: z.string().optional(),
|
|
11
|
+
background: z.boolean().optional(),
|
|
12
|
+
yieldMs: z.number().optional(),
|
|
13
|
+
})
|
|
14
|
+
export type ExecutePayload = z.infer<typeof ExecutePayload>
|
|
15
|
+
|
|
16
|
+
export const ResultMetadata = z.object({
|
|
17
|
+
output: z.string().optional(),
|
|
18
|
+
description: z.string().optional(),
|
|
19
|
+
exit: z.number().nullable().optional(),
|
|
20
|
+
processId: MetaProtocolEnv.ProcessID.optional(),
|
|
21
|
+
background: z.boolean().optional(),
|
|
22
|
+
timedOut: z.boolean().optional(),
|
|
23
|
+
durationMs: z.number().optional(),
|
|
24
|
+
hostSessionID: MetaProtocolEnv.HostSessionID.optional(),
|
|
25
|
+
envID: MetaProtocolEnv.EnvID.optional(),
|
|
26
|
+
backend: z.enum(["local", "remote"]).optional(),
|
|
27
|
+
})
|
|
28
|
+
export type ResultMetadata = z.infer<typeof ResultMetadata>
|
|
29
|
+
|
|
30
|
+
export const Result = z.object({
|
|
31
|
+
title: z.string(),
|
|
32
|
+
metadata: ResultMetadata,
|
|
33
|
+
output: z.string(),
|
|
34
|
+
})
|
|
35
|
+
export type Result = z.infer<typeof Result>
|
|
36
|
+
|
|
37
|
+
export const ExecuteRequest = MetaProtocolEnvelope.RequestBase.extend({
|
|
38
|
+
tool: z.literal("bash"),
|
|
39
|
+
action: z.literal("execute"),
|
|
40
|
+
payload: ExecutePayload,
|
|
41
|
+
})
|
|
42
|
+
export type ExecuteRequest = z.infer<typeof ExecuteRequest>
|
|
43
|
+
|
|
44
|
+
export const ExecuteResult = MetaProtocolEnvelope.ResultBase.extend({
|
|
45
|
+
ok: z.literal(true),
|
|
46
|
+
result: Result,
|
|
47
|
+
})
|
|
48
|
+
export type ExecuteResult = z.infer<typeof ExecuteResult>
|
|
49
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MetaProtocolBash } from "./bash"
|
|
2
|
+
import type { MetaProtocolEnv } from "./env"
|
|
3
|
+
import type { MetaProtocolProcess } from "./process"
|
|
4
|
+
|
|
5
|
+
export namespace MetaProtocolClient {
|
|
6
|
+
export interface ExecutionClient {
|
|
7
|
+
executeBash(envID: MetaProtocolEnv.EnvID, input: MetaProtocolBash.ExecutePayload): Promise<MetaProtocolBash.Result>
|
|
8
|
+
executeProcess(
|
|
9
|
+
envID: MetaProtocolEnv.EnvID,
|
|
10
|
+
input: MetaProtocolProcess.ExecutePayload,
|
|
11
|
+
): Promise<MetaProtocolProcess.Result>
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/env.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
|
|
3
|
+
export namespace MetaProtocolEnv {
|
|
4
|
+
export const EnvID = z.string().min(1).describe("Execution environment ID")
|
|
5
|
+
export type EnvID = z.infer<typeof EnvID>
|
|
6
|
+
|
|
7
|
+
export const ProcessID = z.string().min(1).describe("Opaque process identifier")
|
|
8
|
+
export type ProcessID = z.infer<typeof ProcessID>
|
|
9
|
+
|
|
10
|
+
export const HostSessionID = z.string().min(1).describe("Remote host session identifier")
|
|
11
|
+
export type HostSessionID = z.infer<typeof HostSessionID>
|
|
12
|
+
|
|
13
|
+
export type Target = { kind: "local" } | { kind: "remote"; envID: EnvID }
|
|
14
|
+
|
|
15
|
+
export function resolve(envID?: string): Target {
|
|
16
|
+
if (!envID) {
|
|
17
|
+
return { kind: "local" }
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
kind: "remote",
|
|
21
|
+
envID,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/envelope.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
import { MetaProtocolEnv } from "./env"
|
|
3
|
+
import { MetaProtocolError } from "./error"
|
|
4
|
+
|
|
5
|
+
export namespace MetaProtocolEnvelope {
|
|
6
|
+
export const Tool = z.enum(["bash", "process"])
|
|
7
|
+
export type Tool = z.infer<typeof Tool>
|
|
8
|
+
|
|
9
|
+
export const RequestBase = z.object({
|
|
10
|
+
version: z.literal(1),
|
|
11
|
+
requestID: z.string().min(1),
|
|
12
|
+
envID: MetaProtocolEnv.EnvID,
|
|
13
|
+
tool: Tool,
|
|
14
|
+
action: z.string().min(1),
|
|
15
|
+
})
|
|
16
|
+
export type RequestBase = z.infer<typeof RequestBase>
|
|
17
|
+
|
|
18
|
+
export const ResultBase = z.object({
|
|
19
|
+
version: z.literal(1),
|
|
20
|
+
requestID: z.string().min(1),
|
|
21
|
+
ok: z.boolean(),
|
|
22
|
+
})
|
|
23
|
+
export type ResultBase = z.infer<typeof ResultBase>
|
|
24
|
+
|
|
25
|
+
export const ErrorResult = ResultBase.extend({
|
|
26
|
+
ok: z.literal(false),
|
|
27
|
+
error: MetaProtocolError.Shape,
|
|
28
|
+
})
|
|
29
|
+
export type ErrorResult = z.infer<typeof ErrorResult>
|
|
30
|
+
}
|
package/src/error.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
|
|
3
|
+
export namespace MetaProtocolError {
|
|
4
|
+
export const Code = z.enum([
|
|
5
|
+
"env_not_found",
|
|
6
|
+
"env_inactive",
|
|
7
|
+
"device_offline",
|
|
8
|
+
"request_timeout",
|
|
9
|
+
"request_cancelled",
|
|
10
|
+
"remote_execution_error",
|
|
11
|
+
"invalid_request",
|
|
12
|
+
"unsupported_tool",
|
|
13
|
+
"unsupported_action",
|
|
14
|
+
"unsupported_capability",
|
|
15
|
+
"host_internal_error",
|
|
16
|
+
"stale_process_handle",
|
|
17
|
+
"stdin_unavailable",
|
|
18
|
+
])
|
|
19
|
+
export type Code = z.infer<typeof Code>
|
|
20
|
+
|
|
21
|
+
export const Shape = z.object({
|
|
22
|
+
code: Code,
|
|
23
|
+
message: z.string(),
|
|
24
|
+
details: z.unknown().optional(),
|
|
25
|
+
})
|
|
26
|
+
export type Shape = z.infer<typeof Shape>
|
|
27
|
+
}
|
package/src/host.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
import { MetaProtocolEnv } from "./env"
|
|
3
|
+
|
|
4
|
+
export namespace MetaProtocolHost {
|
|
5
|
+
export const Shell = z.enum(["none", "sh", "cmd", "powershell", "pwsh"])
|
|
6
|
+
export type Shell = z.infer<typeof Shell>
|
|
7
|
+
|
|
8
|
+
export const Runtime = z.enum(["node", "bun", "unknown"])
|
|
9
|
+
export type Runtime = z.infer<typeof Runtime>
|
|
10
|
+
|
|
11
|
+
export const Capabilities = z.object({
|
|
12
|
+
platform: z.string(),
|
|
13
|
+
arch: z.string(),
|
|
14
|
+
hostname: z.string().optional(),
|
|
15
|
+
runtime: Runtime,
|
|
16
|
+
defaultShell: Shell,
|
|
17
|
+
supportedShells: z.array(Shell),
|
|
18
|
+
supportsPty: z.boolean(),
|
|
19
|
+
supportsSendKeys: z.boolean(),
|
|
20
|
+
supportsSoftKill: z.boolean(),
|
|
21
|
+
supportsProcessGroups: z.boolean(),
|
|
22
|
+
envCaseInsensitive: z.boolean(),
|
|
23
|
+
lineEndings: z.enum(["lf", "crlf"]),
|
|
24
|
+
})
|
|
25
|
+
export type Capabilities = z.infer<typeof Capabilities>
|
|
26
|
+
|
|
27
|
+
export const Hello = z.object({
|
|
28
|
+
type: z.literal("host.hello"),
|
|
29
|
+
envID: MetaProtocolEnv.EnvID,
|
|
30
|
+
hostSessionID: MetaProtocolEnv.HostSessionID,
|
|
31
|
+
capabilities: Capabilities,
|
|
32
|
+
})
|
|
33
|
+
export type Hello = z.infer<typeof Hello>
|
|
34
|
+
}
|
package/src/index.ts
ADDED
package/src/process.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import z from "zod"
|
|
2
|
+
import { MetaProtocolEnvelope } from "./envelope"
|
|
3
|
+
import { MetaProtocolEnv } from "./env"
|
|
4
|
+
|
|
5
|
+
export namespace MetaProtocolProcess {
|
|
6
|
+
export const Action = z.enum(["list", "poll", "log", "write", "send-keys", "kill", "clear", "remove"])
|
|
7
|
+
export type Action = z.infer<typeof Action>
|
|
8
|
+
|
|
9
|
+
export const ProcessState = z.enum(["running", "completed", "failed", "killed"])
|
|
10
|
+
export type ProcessState = z.infer<typeof ProcessState>
|
|
11
|
+
|
|
12
|
+
export const ActionStatus = z.enum([
|
|
13
|
+
"running",
|
|
14
|
+
"completed",
|
|
15
|
+
"failed",
|
|
16
|
+
"killed",
|
|
17
|
+
"not_found",
|
|
18
|
+
"error",
|
|
19
|
+
"cleared",
|
|
20
|
+
"removed",
|
|
21
|
+
])
|
|
22
|
+
export type ActionStatus = z.infer<typeof ActionStatus>
|
|
23
|
+
|
|
24
|
+
export const ProcessInfo = z.object({
|
|
25
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
26
|
+
status: ProcessState,
|
|
27
|
+
command: z.string(),
|
|
28
|
+
description: z.string().optional(),
|
|
29
|
+
runtimeMs: z.number(),
|
|
30
|
+
})
|
|
31
|
+
export type ProcessInfo = z.infer<typeof ProcessInfo>
|
|
32
|
+
|
|
33
|
+
export const ExecutePayload = z.discriminatedUnion("action", [
|
|
34
|
+
z.object({ action: z.literal("list") }),
|
|
35
|
+
z.object({
|
|
36
|
+
action: z.literal("poll"),
|
|
37
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
38
|
+
block: z.boolean().optional(),
|
|
39
|
+
timeout: z.number().optional(),
|
|
40
|
+
}),
|
|
41
|
+
z.object({
|
|
42
|
+
action: z.literal("log"),
|
|
43
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
44
|
+
offset: z.number().optional(),
|
|
45
|
+
limit: z.number().optional(),
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
action: z.literal("write"),
|
|
49
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
50
|
+
data: z.string(),
|
|
51
|
+
}),
|
|
52
|
+
z.object({
|
|
53
|
+
action: z.literal("send-keys"),
|
|
54
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
55
|
+
keys: z.array(z.string()),
|
|
56
|
+
}),
|
|
57
|
+
z.object({
|
|
58
|
+
action: z.literal("kill"),
|
|
59
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
60
|
+
}),
|
|
61
|
+
z.object({
|
|
62
|
+
action: z.literal("clear"),
|
|
63
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
64
|
+
}),
|
|
65
|
+
z.object({
|
|
66
|
+
action: z.literal("remove"),
|
|
67
|
+
processId: MetaProtocolEnv.ProcessID,
|
|
68
|
+
}),
|
|
69
|
+
])
|
|
70
|
+
export type ExecutePayload = z.infer<typeof ExecutePayload>
|
|
71
|
+
|
|
72
|
+
export const ResultMetadata = z.object({
|
|
73
|
+
action: Action,
|
|
74
|
+
processId: MetaProtocolEnv.ProcessID.optional(),
|
|
75
|
+
status: ActionStatus.optional(),
|
|
76
|
+
exitCode: z.number().optional(),
|
|
77
|
+
command: z.string().optional(),
|
|
78
|
+
description: z.string().optional(),
|
|
79
|
+
nextOffset: z.number().optional(),
|
|
80
|
+
hostSessionID: MetaProtocolEnv.HostSessionID.optional(),
|
|
81
|
+
envID: MetaProtocolEnv.EnvID.optional(),
|
|
82
|
+
backend: z.enum(["local", "remote"]).optional(),
|
|
83
|
+
processes: z.array(ProcessInfo).optional(),
|
|
84
|
+
})
|
|
85
|
+
export type ResultMetadata = z.infer<typeof ResultMetadata>
|
|
86
|
+
|
|
87
|
+
export const Result = z.object({
|
|
88
|
+
title: z.string(),
|
|
89
|
+
metadata: ResultMetadata,
|
|
90
|
+
output: z.string(),
|
|
91
|
+
})
|
|
92
|
+
export type Result = z.infer<typeof Result>
|
|
93
|
+
|
|
94
|
+
export const ExecuteRequest = MetaProtocolEnvelope.RequestBase.extend({
|
|
95
|
+
tool: z.literal("process"),
|
|
96
|
+
action: Action,
|
|
97
|
+
payload: ExecutePayload,
|
|
98
|
+
})
|
|
99
|
+
export type ExecuteRequest = z.infer<typeof ExecuteRequest>
|
|
100
|
+
|
|
101
|
+
export const ExecuteResult = MetaProtocolEnvelope.ResultBase.extend({
|
|
102
|
+
ok: z.literal(true),
|
|
103
|
+
result: Result,
|
|
104
|
+
})
|
|
105
|
+
export type ExecuteResult = z.infer<typeof ExecuteResult>
|
|
106
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"lib": ["ESNext", "DOM"],
|
|
8
|
+
"types": ["node"],
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"noEmit": false,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"isolatedModules": true
|
|
17
|
+
},
|
|
18
|
+
"include": ["src"]
|
|
19
|
+
}
|