@secure-exec/core 0.0.0-agentos-dylib-base.edaa4a4
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/README.md +7 -0
- package/commands/[ +0 -0
- package/commands/_stubs +0 -0
- package/commands/arch +0 -0
- package/commands/awk +0 -0
- package/commands/b2sum +0 -0
- package/commands/base32 +0 -0
- package/commands/base64 +0 -0
- package/commands/basename +0 -0
- package/commands/basenc +0 -0
- package/commands/bash +0 -0
- package/commands/cat +0 -0
- package/commands/chcon +0 -0
- package/commands/chgrp +0 -0
- package/commands/chmod +0 -0
- package/commands/chown +0 -0
- package/commands/chroot +0 -0
- package/commands/cksum +0 -0
- package/commands/codex +0 -0
- package/commands/codex-exec +0 -0
- package/commands/column +0 -0
- package/commands/comm +0 -0
- package/commands/cp +0 -0
- package/commands/curl +0 -0
- package/commands/cut +0 -0
- package/commands/date +0 -0
- package/commands/dd +0 -0
- package/commands/df +0 -0
- package/commands/diff +0 -0
- package/commands/dir +0 -0
- package/commands/dircolors +0 -0
- package/commands/dirname +0 -0
- package/commands/du +0 -0
- package/commands/echo +0 -0
- package/commands/egrep +0 -0
- package/commands/env +0 -0
- package/commands/expand +0 -0
- package/commands/expr +0 -0
- package/commands/factor +0 -0
- package/commands/false +0 -0
- package/commands/fd +0 -0
- package/commands/fgrep +0 -0
- package/commands/file +0 -0
- package/commands/find +0 -0
- package/commands/fmt +0 -0
- package/commands/fold +0 -0
- package/commands/git +0 -0
- package/commands/grep +0 -0
- package/commands/groups +0 -0
- package/commands/gunzip +0 -0
- package/commands/gzip +0 -0
- package/commands/head +0 -0
- package/commands/hostid +0 -0
- package/commands/hostname +0 -0
- package/commands/http-test +0 -0
- package/commands/id +0 -0
- package/commands/install +0 -0
- package/commands/join +0 -0
- package/commands/jq +0 -0
- package/commands/kill +0 -0
- package/commands/link +0 -0
- package/commands/ln +0 -0
- package/commands/logname +0 -0
- package/commands/ls +0 -0
- package/commands/md5sum +0 -0
- package/commands/mkdir +0 -0
- package/commands/mkfifo +0 -0
- package/commands/mknod +0 -0
- package/commands/mktemp +0 -0
- package/commands/more +0 -0
- package/commands/mv +0 -0
- package/commands/nice +0 -0
- package/commands/nl +0 -0
- package/commands/nohup +0 -0
- package/commands/nproc +0 -0
- package/commands/numfmt +0 -0
- package/commands/od +0 -0
- package/commands/paste +0 -0
- package/commands/pathchk +0 -0
- package/commands/pinky +0 -0
- package/commands/printenv +0 -0
- package/commands/printf +0 -0
- package/commands/ptx +0 -0
- package/commands/pwd +0 -0
- package/commands/readlink +0 -0
- package/commands/realpath +0 -0
- package/commands/rev +0 -0
- package/commands/rg +0 -0
- package/commands/rm +0 -0
- package/commands/rmdir +0 -0
- package/commands/runcon +0 -0
- package/commands/sed +0 -0
- package/commands/seq +0 -0
- package/commands/sh +0 -0
- package/commands/sha1sum +0 -0
- package/commands/sha224sum +0 -0
- package/commands/sha256sum +0 -0
- package/commands/sha384sum +0 -0
- package/commands/sha512sum +0 -0
- package/commands/shred +0 -0
- package/commands/shuf +0 -0
- package/commands/sleep +0 -0
- package/commands/sort +0 -0
- package/commands/spawn-test-host +0 -0
- package/commands/split +0 -0
- package/commands/stat +0 -0
- package/commands/stdbuf +0 -0
- package/commands/strings +0 -0
- package/commands/stty +0 -0
- package/commands/sum +0 -0
- package/commands/sync +0 -0
- package/commands/tac +0 -0
- package/commands/tail +0 -0
- package/commands/tar +0 -0
- package/commands/tee +0 -0
- package/commands/test +0 -0
- package/commands/timeout +0 -0
- package/commands/touch +0 -0
- package/commands/tr +0 -0
- package/commands/tree +0 -0
- package/commands/true +0 -0
- package/commands/truncate +0 -0
- package/commands/tsort +0 -0
- package/commands/tty +0 -0
- package/commands/uname +0 -0
- package/commands/unexpand +0 -0
- package/commands/uniq +0 -0
- package/commands/unlink +0 -0
- package/commands/uptime +0 -0
- package/commands/users +0 -0
- package/commands/vdir +0 -0
- package/commands/wc +0 -0
- package/commands/which +0 -0
- package/commands/who +0 -0
- package/commands/whoami +0 -0
- package/commands/xargs +0 -0
- package/commands/xu +0 -0
- package/commands/yes +0 -0
- package/commands/yq +0 -0
- package/commands/zcat +0 -0
- package/dist/binary.d.ts +4 -0
- package/dist/binary.js +25 -0
- package/dist/bytes.d.ts +2 -0
- package/dist/bytes.js +6 -0
- package/dist/callbacks.d.ts +41 -0
- package/dist/callbacks.js +94 -0
- package/dist/cargo.d.ts +2 -0
- package/dist/cargo.js +142 -0
- package/dist/correlation.d.ts +10 -0
- package/dist/correlation.js +49 -0
- package/dist/descriptors.d.ts +80 -0
- package/dist/descriptors.js +55 -0
- package/dist/event-buffer.d.ts +90 -0
- package/dist/event-buffer.js +313 -0
- package/dist/ext.d.ts +7 -0
- package/dist/ext.js +13 -0
- package/dist/filesystem.d.ts +41 -0
- package/dist/filesystem.js +70 -0
- package/dist/frame-payload-codec.d.ts +8 -0
- package/dist/frame-payload-codec.js +14 -0
- package/dist/frame-rpc.d.ts +40 -0
- package/dist/frame-rpc.js +81 -0
- package/dist/frame-stream.d.ts +34 -0
- package/dist/frame-stream.js +109 -0
- package/dist/framing.d.ts +8 -0
- package/dist/framing.js +23 -0
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +19 -0
- package/dist/generated/CreateVmConfig.js +1 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +26 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +8 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +22 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +5 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/generated-protocol.d.ts +1055 -0
- package/dist/generated-protocol.js +2921 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +28 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +20 -0
- package/dist/kernel-proxy.d.ts +165 -0
- package/dist/kernel-proxy.js +1760 -0
- package/dist/message-frame-transport.d.ts +29 -0
- package/dist/message-frame-transport.js +81 -0
- package/dist/native-client.d.ts +42 -0
- package/dist/native-client.js +126 -0
- package/dist/node-runtime.d.ts +516 -0
- package/dist/node-runtime.js +823 -0
- package/dist/numbers.d.ts +1 -0
- package/dist/numbers.js +8 -0
- package/dist/ownership.d.ts +18 -0
- package/dist/ownership.js +77 -0
- package/dist/permissions.d.ts +29 -0
- package/dist/permissions.js +68 -0
- package/dist/process.d.ts +22 -0
- package/dist/process.js +97 -0
- package/dist/protocol-client.d.ts +48 -0
- package/dist/protocol-client.js +181 -0
- package/dist/protocol-frames.d.ts +68 -0
- package/dist/protocol-frames.js +139 -0
- package/dist/protocol-maps.d.ts +31 -0
- package/dist/protocol-maps.js +253 -0
- package/dist/protocol-schema.d.ts +10 -0
- package/dist/protocol-schema.js +11 -0
- package/dist/request-payloads.d.ts +154 -0
- package/dist/request-payloads.js +241 -0
- package/dist/response-payloads.d.ts +124 -0
- package/dist/response-payloads.js +180 -0
- package/dist/sidecar-client.d.ts +17 -0
- package/dist/sidecar-client.js +1 -0
- package/dist/sidecar-errors.d.ts +15 -0
- package/dist/sidecar-errors.js +30 -0
- package/dist/sidecar-process.d.ts +281 -0
- package/dist/sidecar-process.js +839 -0
- package/dist/state.d.ts +40 -0
- package/dist/state.js +44 -0
- package/dist/test-runtime.d.ts +536 -0
- package/dist/test-runtime.js +2153 -0
- package/dist/vm-config.d.ts +31 -0
- package/dist/vm-config.js +1 -0
- package/fixtures/alpine-defaults.json +520 -0
- package/fixtures/base-filesystem.json +528 -0
- package/package.json +212 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @secure-exec/core
|
|
2
|
+
|
|
3
|
+
Raw Secure Exec protocol types and codecs.
|
|
4
|
+
|
|
5
|
+
- `@secure-exec/core/protocol` exports the generated sidecar protocol.
|
|
6
|
+
- `@secure-exec/core/binary` resolves the published `secure-exec-sidecar` binary and honors `SECURE_EXEC_SIDECAR_BIN`.
|
|
7
|
+
- `@secure-exec/core/framing`, `@secure-exec/core/frame-stream`, `@secure-exec/core/frame-rpc`, `@secure-exec/core/frame-payload-codec`, `@secure-exec/core/correlation`, `@secure-exec/core/event-buffer`, `@secure-exec/core/ownership`, `@secure-exec/core/permissions`, `@secure-exec/core/state`, `@secure-exec/core/request-payloads`, `@secure-exec/core/response-payloads`, `@secure-exec/core/protocol-frames`, `@secure-exec/core/protocol-client`, `@secure-exec/core/native-client`, `@secure-exec/core/descriptors`, `@secure-exec/core/process`, `@secure-exec/core/protocol-schema`, `@secure-exec/core/protocol-maps`, `@secure-exec/core/callbacks`, `@secure-exec/core/filesystem`, `@secure-exec/core/json`, `@secure-exec/core/numbers`, `@secure-exec/core/bytes`, and `@secure-exec/core/ext` expose generic Node transport primitives.
|
package/commands/[
ADDED
|
Binary file
|
package/commands/_stubs
ADDED
|
Binary file
|
package/commands/arch
ADDED
|
Binary file
|
package/commands/awk
ADDED
|
Binary file
|
package/commands/b2sum
ADDED
|
Binary file
|
package/commands/base32
ADDED
|
Binary file
|
package/commands/base64
ADDED
|
Binary file
|
|
Binary file
|
package/commands/basenc
ADDED
|
Binary file
|
package/commands/bash
ADDED
|
Binary file
|
package/commands/cat
ADDED
|
Binary file
|
package/commands/chcon
ADDED
|
Binary file
|
package/commands/chgrp
ADDED
|
Binary file
|
package/commands/chmod
ADDED
|
Binary file
|
package/commands/chown
ADDED
|
Binary file
|
package/commands/chroot
ADDED
|
Binary file
|
package/commands/cksum
ADDED
|
Binary file
|
package/commands/codex
ADDED
|
Binary file
|
|
Binary file
|
package/commands/column
ADDED
|
Binary file
|
package/commands/comm
ADDED
|
Binary file
|
package/commands/cp
ADDED
|
Binary file
|
package/commands/curl
ADDED
|
Binary file
|
package/commands/cut
ADDED
|
Binary file
|
package/commands/date
ADDED
|
Binary file
|
package/commands/dd
ADDED
|
Binary file
|
package/commands/df
ADDED
|
Binary file
|
package/commands/diff
ADDED
|
Binary file
|
package/commands/dir
ADDED
|
Binary file
|
|
Binary file
|
package/commands/dirname
ADDED
|
Binary file
|
package/commands/du
ADDED
|
Binary file
|
package/commands/echo
ADDED
|
Binary file
|
package/commands/egrep
ADDED
|
Binary file
|
package/commands/env
ADDED
|
Binary file
|
package/commands/expand
ADDED
|
Binary file
|
package/commands/expr
ADDED
|
Binary file
|
package/commands/factor
ADDED
|
Binary file
|
package/commands/false
ADDED
|
Binary file
|
package/commands/fd
ADDED
|
Binary file
|
package/commands/fgrep
ADDED
|
Binary file
|
package/commands/file
ADDED
|
Binary file
|
package/commands/find
ADDED
|
Binary file
|
package/commands/fmt
ADDED
|
Binary file
|
package/commands/fold
ADDED
|
Binary file
|
package/commands/git
ADDED
|
Binary file
|
package/commands/grep
ADDED
|
Binary file
|
package/commands/groups
ADDED
|
Binary file
|
package/commands/gunzip
ADDED
|
Binary file
|
package/commands/gzip
ADDED
|
Binary file
|
package/commands/head
ADDED
|
Binary file
|
package/commands/hostid
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/commands/id
ADDED
|
Binary file
|
package/commands/install
ADDED
|
Binary file
|
package/commands/join
ADDED
|
Binary file
|
package/commands/jq
ADDED
|
Binary file
|
package/commands/kill
ADDED
|
Binary file
|
package/commands/link
ADDED
|
Binary file
|
package/commands/ln
ADDED
|
Binary file
|
package/commands/logname
ADDED
|
Binary file
|
package/commands/ls
ADDED
|
Binary file
|
package/commands/md5sum
ADDED
|
Binary file
|
package/commands/mkdir
ADDED
|
Binary file
|
package/commands/mkfifo
ADDED
|
Binary file
|
package/commands/mknod
ADDED
|
Binary file
|
package/commands/mktemp
ADDED
|
Binary file
|
package/commands/more
ADDED
|
Binary file
|
package/commands/mv
ADDED
|
Binary file
|
package/commands/nice
ADDED
|
Binary file
|
package/commands/nl
ADDED
|
Binary file
|
package/commands/nohup
ADDED
|
Binary file
|
package/commands/nproc
ADDED
|
Binary file
|
package/commands/numfmt
ADDED
|
Binary file
|
package/commands/od
ADDED
|
Binary file
|
package/commands/paste
ADDED
|
Binary file
|
package/commands/pathchk
ADDED
|
Binary file
|
package/commands/pinky
ADDED
|
Binary file
|
|
Binary file
|
package/commands/printf
ADDED
|
Binary file
|
package/commands/ptx
ADDED
|
Binary file
|
package/commands/pwd
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/commands/rev
ADDED
|
Binary file
|
package/commands/rg
ADDED
|
Binary file
|
package/commands/rm
ADDED
|
Binary file
|
package/commands/rmdir
ADDED
|
Binary file
|
package/commands/runcon
ADDED
|
Binary file
|
package/commands/sed
ADDED
|
Binary file
|
package/commands/seq
ADDED
|
Binary file
|
package/commands/sh
ADDED
|
Binary file
|
package/commands/sha1sum
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/commands/shred
ADDED
|
Binary file
|
package/commands/shuf
ADDED
|
Binary file
|
package/commands/sleep
ADDED
|
Binary file
|
package/commands/sort
ADDED
|
Binary file
|
|
Binary file
|
package/commands/split
ADDED
|
Binary file
|
package/commands/stat
ADDED
|
Binary file
|
package/commands/stdbuf
ADDED
|
Binary file
|
package/commands/strings
ADDED
|
Binary file
|
package/commands/stty
ADDED
|
Binary file
|
package/commands/sum
ADDED
|
Binary file
|
package/commands/sync
ADDED
|
Binary file
|
package/commands/tac
ADDED
|
Binary file
|
package/commands/tail
ADDED
|
Binary file
|
package/commands/tar
ADDED
|
Binary file
|
package/commands/tee
ADDED
|
Binary file
|
package/commands/test
ADDED
|
Binary file
|
package/commands/timeout
ADDED
|
Binary file
|
package/commands/touch
ADDED
|
Binary file
|
package/commands/tr
ADDED
|
Binary file
|
package/commands/tree
ADDED
|
Binary file
|
package/commands/true
ADDED
|
Binary file
|
|
Binary file
|
package/commands/tsort
ADDED
|
Binary file
|
package/commands/tty
ADDED
|
Binary file
|
package/commands/uname
ADDED
|
Binary file
|
|
Binary file
|
package/commands/uniq
ADDED
|
Binary file
|
package/commands/unlink
ADDED
|
Binary file
|
package/commands/uptime
ADDED
|
Binary file
|
package/commands/users
ADDED
|
Binary file
|
package/commands/vdir
ADDED
|
Binary file
|
package/commands/wc
ADDED
|
Binary file
|
package/commands/which
ADDED
|
Binary file
|
package/commands/who
ADDED
|
Binary file
|
package/commands/whoami
ADDED
|
Binary file
|
package/commands/xargs
ADDED
|
Binary file
|
package/commands/xu
ADDED
|
Binary file
|
package/commands/yes
ADDED
|
Binary file
|
package/commands/yq
ADDED
|
Binary file
|
package/commands/zcat
ADDED
|
Binary file
|
package/dist/binary.d.ts
ADDED
package/dist/binary.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the published secure-exec sidecar binary for Node.js clients.
|
|
5
|
+
*/
|
|
6
|
+
export function resolvePublishedSidecarBinary() {
|
|
7
|
+
const override = process.env.SECURE_EXEC_SIDECAR_BIN;
|
|
8
|
+
if (override) {
|
|
9
|
+
if (!existsSync(override)) {
|
|
10
|
+
throw new Error(`SECURE_EXEC_SIDECAR_BIN is set to ${override} but the file does not exist`);
|
|
11
|
+
}
|
|
12
|
+
return override;
|
|
13
|
+
}
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
let mod;
|
|
16
|
+
try {
|
|
17
|
+
mod = require("@secure-exec/sidecar");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error("failed to resolve the secure-exec sidecar binary: the @secure-exec/sidecar " +
|
|
21
|
+
"package is not installed. Install it, or set SECURE_EXEC_SIDECAR_BIN to a local " +
|
|
22
|
+
`secure-exec-sidecar binary. (${error.message})`);
|
|
23
|
+
}
|
|
24
|
+
return mod.getSidecarPath();
|
|
25
|
+
}
|
package/dist/bytes.d.ts
ADDED
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type * as protocol from "./generated-protocol.js";
|
|
2
|
+
export interface CallbackExtEnvelope {
|
|
3
|
+
namespace: string;
|
|
4
|
+
payload: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
export type CallbackSidecarRequestPayload = {
|
|
7
|
+
type: "host_callback";
|
|
8
|
+
invocation_id: string;
|
|
9
|
+
callback_key: string;
|
|
10
|
+
input: unknown;
|
|
11
|
+
timeout_ms: number;
|
|
12
|
+
} | {
|
|
13
|
+
type: "js_bridge_call";
|
|
14
|
+
call_id: string;
|
|
15
|
+
mount_id: string;
|
|
16
|
+
operation: string;
|
|
17
|
+
args: unknown;
|
|
18
|
+
} | {
|
|
19
|
+
type: "ext";
|
|
20
|
+
envelope: CallbackExtEnvelope;
|
|
21
|
+
};
|
|
22
|
+
export type CallbackSidecarResponsePayload = {
|
|
23
|
+
type: "host_callback_result";
|
|
24
|
+
invocation_id: string;
|
|
25
|
+
result?: unknown;
|
|
26
|
+
error?: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "js_bridge_result";
|
|
29
|
+
call_id: string;
|
|
30
|
+
result?: unknown;
|
|
31
|
+
error?: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "ext_result";
|
|
34
|
+
envelope: CallbackExtEnvelope;
|
|
35
|
+
};
|
|
36
|
+
export type LiveSidecarRequestPayload = CallbackSidecarRequestPayload;
|
|
37
|
+
export type LiveSidecarResponsePayload = CallbackSidecarResponsePayload;
|
|
38
|
+
export declare function isMatchingSidecarResponsePayload(request: CallbackSidecarRequestPayload, response: CallbackSidecarResponsePayload): boolean;
|
|
39
|
+
export declare function errorSidecarResponsePayload(request: CallbackSidecarRequestPayload, error: unknown): CallbackSidecarResponsePayload;
|
|
40
|
+
export declare function fromGeneratedSidecarRequestPayload(payload: protocol.SidecarRequestPayload): LiveSidecarRequestPayload;
|
|
41
|
+
export declare function toGeneratedSidecarResponsePayload(payload: LiveSidecarResponsePayload): protocol.SidecarResponsePayload;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { fromGeneratedExtEnvelope, toGeneratedExtEnvelope, } from "./ext.js";
|
|
2
|
+
import { parseJsonUtf8, stringifyJsonUtf8 } from "./json.js";
|
|
3
|
+
import { bigIntToSafeNumber } from "./numbers.js";
|
|
4
|
+
export function isMatchingSidecarResponsePayload(request, response) {
|
|
5
|
+
switch (request.type) {
|
|
6
|
+
case "host_callback":
|
|
7
|
+
return response.type === "host_callback_result";
|
|
8
|
+
case "js_bridge_call":
|
|
9
|
+
return response.type === "js_bridge_result";
|
|
10
|
+
case "ext":
|
|
11
|
+
return response.type === "ext_result";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function errorSidecarResponsePayload(request, error) {
|
|
15
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
+
switch (request.type) {
|
|
17
|
+
case "host_callback":
|
|
18
|
+
return {
|
|
19
|
+
type: "host_callback_result",
|
|
20
|
+
invocation_id: request.invocation_id,
|
|
21
|
+
error: message,
|
|
22
|
+
};
|
|
23
|
+
case "js_bridge_call":
|
|
24
|
+
return {
|
|
25
|
+
type: "js_bridge_result",
|
|
26
|
+
call_id: request.call_id,
|
|
27
|
+
error: message,
|
|
28
|
+
};
|
|
29
|
+
case "ext":
|
|
30
|
+
return {
|
|
31
|
+
type: "ext_result",
|
|
32
|
+
envelope: {
|
|
33
|
+
namespace: request.envelope.namespace,
|
|
34
|
+
payload: Buffer.from(message, "utf8"),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function fromGeneratedSidecarRequestPayload(payload) {
|
|
40
|
+
switch (payload.tag) {
|
|
41
|
+
case "HostCallbackRequest":
|
|
42
|
+
return {
|
|
43
|
+
type: "host_callback",
|
|
44
|
+
invocation_id: payload.val.invocationId,
|
|
45
|
+
callback_key: payload.val.callbackKey,
|
|
46
|
+
input: parseJsonUtf8(payload.val.input, "host callback input"),
|
|
47
|
+
timeout_ms: bigIntToSafeNumber(payload.val.timeoutMs, "host callback timeout"),
|
|
48
|
+
};
|
|
49
|
+
case "JsBridgeCallRequest":
|
|
50
|
+
return {
|
|
51
|
+
type: "js_bridge_call",
|
|
52
|
+
call_id: payload.val.callId,
|
|
53
|
+
mount_id: payload.val.mountId,
|
|
54
|
+
operation: payload.val.operation,
|
|
55
|
+
args: parseJsonUtf8(payload.val.args, "js bridge call args"),
|
|
56
|
+
};
|
|
57
|
+
case "ExtEnvelope":
|
|
58
|
+
return {
|
|
59
|
+
type: "ext",
|
|
60
|
+
envelope: fromGeneratedExtEnvelope(payload.val),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function toGeneratedSidecarResponsePayload(payload) {
|
|
65
|
+
switch (payload.type) {
|
|
66
|
+
case "host_callback_result":
|
|
67
|
+
return {
|
|
68
|
+
tag: "HostCallbackResultResponse",
|
|
69
|
+
val: {
|
|
70
|
+
invocationId: payload.invocation_id,
|
|
71
|
+
result: payload.result === undefined
|
|
72
|
+
? null
|
|
73
|
+
: stringifyJsonUtf8(payload.result, "host_callback_result.result"),
|
|
74
|
+
error: payload.error ?? null,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
case "js_bridge_result":
|
|
78
|
+
return {
|
|
79
|
+
tag: "JsBridgeResultResponse",
|
|
80
|
+
val: {
|
|
81
|
+
callId: payload.call_id,
|
|
82
|
+
result: payload.result === undefined
|
|
83
|
+
? null
|
|
84
|
+
: stringifyJsonUtf8(payload.result, "js_bridge_result.result"),
|
|
85
|
+
error: payload.error ?? null,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
case "ext_result":
|
|
89
|
+
return {
|
|
90
|
+
tag: "ExtEnvelope",
|
|
91
|
+
val: toGeneratedExtEnvelope(payload.envelope),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/cargo.d.ts
ADDED