@jini-ai/sidecar 0.1.0

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.
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @module types
3
+ *
4
+ * Public data types for the generic sidecar runtime: the stamp shape and
5
+ * contract descriptor a host supplies, the request/option records for namespace
6
+ * and runtime-path resolution, the launch-env and bootstrap inputs, the resolved
7
+ * runtime context, port allocation shapes, and the JSON-IPC handler/handle types.
8
+ * Pure type declarations with no runtime code and no dependency on sibling files.
9
+ */
10
+ /** Minimal shape of a sidecar process stamp: the five identity fields. */
11
+ export type SidecarStampShape = {
12
+ app: string;
13
+ ipc: string;
14
+ mode: string;
15
+ namespace: string;
16
+ source: string;
17
+ };
18
+ /**
19
+ * Host-supplied contract: default path/namespace values, env var names, and the
20
+ * normalizers that validate/canonicalize app, namespace, source, and full stamp.
21
+ */
22
+ export type SidecarContractDescriptor<TStamp extends SidecarStampShape = SidecarStampShape> = {
23
+ defaults: {
24
+ host: string;
25
+ ipcBase: string;
26
+ namespace: string;
27
+ projectTmpDirName: string;
28
+ windowsPipePrefix: string;
29
+ };
30
+ env: {
31
+ base: string;
32
+ ipcBase: string;
33
+ ipcPath: string;
34
+ namespace: string;
35
+ source: string;
36
+ };
37
+ normalizeApp(app: unknown): TStamp["app"];
38
+ normalizeNamespace(namespace: unknown): string;
39
+ normalizeSource(source: unknown): TStamp["source"];
40
+ normalizeStamp(input: unknown): TStamp;
41
+ };
42
+ /** Inputs for resolving the effective namespace (explicit, env, or default). */
43
+ export type NamespaceResolutionOptions<TStamp extends SidecarStampShape = SidecarStampShape> = {
44
+ contract: SidecarContractDescriptor<TStamp>;
45
+ env?: NodeJS.ProcessEnv;
46
+ namespace?: string | null;
47
+ };
48
+ /** Inputs for resolving a source-scoped runtime root under a project. */
49
+ export type ProjectRuntimePathRequest<TStamp extends SidecarStampShape = SidecarStampShape> = {
50
+ contract: SidecarContractDescriptor<TStamp>;
51
+ projectRoot: string;
52
+ source: TStamp["source"] | string;
53
+ };
54
+ /** Inputs for resolving the sidecar base (explicit, env, or project-derived). */
55
+ export type BaseResolutionOptions<TStamp extends SidecarStampShape = SidecarStampShape> = {
56
+ base?: string | null;
57
+ contract: SidecarContractDescriptor<TStamp>;
58
+ env?: NodeJS.ProcessEnv;
59
+ projectRoot?: string;
60
+ source: TStamp["source"] | string;
61
+ };
62
+ /** Inputs for resolving a namespace-scoped path from a base + namespace. */
63
+ export type RuntimePathRequest<TStamp extends SidecarStampShape = SidecarStampShape> = {
64
+ base: string;
65
+ contract: SidecarContractDescriptor<TStamp>;
66
+ namespace: string;
67
+ };
68
+ /** {@link RuntimePathRequest} plus a run id, for a per-run runtime root. */
69
+ export type RuntimeRootRequest<TStamp extends SidecarStampShape = SidecarStampShape> = RuntimePathRequest<TStamp> & {
70
+ runId: string;
71
+ };
72
+ /** Inputs for resolving an app's IPC socket/pipe path. */
73
+ export type AppIpcPathRequest<TStamp extends SidecarStampShape = SidecarStampShape> = {
74
+ app: TStamp["app"] | string;
75
+ contract: SidecarContractDescriptor<TStamp>;
76
+ env?: NodeJS.ProcessEnv;
77
+ namespace: string;
78
+ };
79
+ /** Inputs for resolving an app-scoped runtime dir/file under a namespace root. */
80
+ export type AppRuntimePathRequest<TStamp extends SidecarStampShape = SidecarStampShape> = {
81
+ app: TStamp["app"] | string;
82
+ contract: SidecarContractDescriptor<TStamp>;
83
+ namespaceRoot: string;
84
+ };
85
+ /** The resolved live runtime context of a bootstrapped sidecar process. */
86
+ export type SidecarRuntimeContext<TStamp extends SidecarStampShape = SidecarStampShape> = {
87
+ app: TStamp["app"];
88
+ base: string;
89
+ ipc: string;
90
+ mode: TStamp["mode"];
91
+ namespace: string;
92
+ source: TStamp["source"];
93
+ };
94
+ /** Inputs for composing the env a child sidecar is launched with. */
95
+ export type SidecarLaunchEnvRequest<TStamp extends SidecarStampShape = SidecarStampShape> = {
96
+ base: string;
97
+ contract: SidecarContractDescriptor<TStamp>;
98
+ extraEnv?: NodeJS.ProcessEnv;
99
+ stamp: TStamp;
100
+ };
101
+ /** Inputs for bootstrapping a sidecar runtime from a stamp + env. */
102
+ export type BootstrapSidecarRuntimeOptions<TStamp extends SidecarStampShape = SidecarStampShape> = {
103
+ app: TStamp["app"] | string;
104
+ base?: string | null;
105
+ contract: SidecarContractDescriptor<TStamp>;
106
+ projectRoot?: string;
107
+ };
108
+ /** Result of allocating a port: the chosen port and how it was chosen. */
109
+ export type PortAllocation = {
110
+ port: number;
111
+ source: "dynamic" | "forced";
112
+ };
113
+ /** Inputs for {@link allocatePort}. */
114
+ export type PortRequest = {
115
+ host?: string;
116
+ label?: string;
117
+ port?: number | string | null;
118
+ reserved?: Set<number>;
119
+ };
120
+ /** Handler invoked with each decoded JSON-IPC message, returning the reply. */
121
+ export type JsonIpcHandler = (message: any) => unknown | Promise<unknown>;
122
+ /** Handle to a running JSON-IPC server. */
123
+ export type JsonIpcServerHandle = {
124
+ close(): Promise<void>;
125
+ };
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CAAC,MAAM,SAAS,iBAAiB,GAAG,iBAAiB,IAAI;IAC5F,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;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,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module types
3
+ *
4
+ * Public data types for the generic sidecar runtime: the stamp shape and
5
+ * contract descriptor a host supplies, the request/option records for namespace
6
+ * and runtime-path resolution, the launch-env and bootstrap inputs, the resolved
7
+ * runtime context, port allocation shapes, and the JSON-IPC handler/handle types.
8
+ * Pure type declarations with no runtime code and no dependency on sibling files.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@jini-ai/sidecar",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/AINSEP/Jini.git",
8
+ "directory": "packages/sidecar"
9
+ },
10
+ "jini": {
11
+ "domain": "platform",
12
+ "kind": "process-bridge",
13
+ "runtime": "node",
14
+ "admission": "locked"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "!dist/**/*.test.js",
26
+ "!dist/**/*.test.d.ts",
27
+ "!dist/**/*.test.js.map",
28
+ "!dist/**/*.test.d.ts.map",
29
+ "!dist/**/__tests__/**"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org"
34
+ },
35
+ "dependencies": {
36
+ "@jini-ai/core": "0.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "@vitest/coverage-v8": "^2.1.9"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.json",
43
+ "typecheck": "tsc -p tsconfig.json --noEmit",
44
+ "test": "vitest run",
45
+ "test:coverage": "vitest run --coverage"
46
+ }
47
+ }