@cyanheads/astronomy-mcp-server 0.1.2
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/AGENTS.md +431 -0
- package/CLAUDE.md +431 -0
- package/Dockerfile +104 -0
- package/LICENSE +201 -0
- package/README.md +320 -0
- package/changelog/0.1.x/0.1.1.md +28 -0
- package/changelog/0.1.x/0.1.2.md +16 -0
- package/changelog/template.md +127 -0
- package/dist/config/server-config.d.ts +22 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +40 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/prompts/definitions/stargazing-plan.prompt.d.ts +12 -0
- package/dist/mcp-server/prompts/definitions/stargazing-plan.prompt.d.ts.map +1 -0
- package/dist/mcp-server/prompts/definitions/stargazing-plan.prompt.js +36 -0
- package/dist/mcp-server/prompts/definitions/stargazing-plan.prompt.js.map +1 -0
- package/dist/mcp-server/resources/definitions/body.resource.d.ts +29 -0
- package/dist/mcp-server/resources/definitions/body.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/body.resource.js +65 -0
- package/dist/mcp-server/resources/definitions/body.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/find-events.tool.d.ts +157 -0
- package/dist/mcp-server/tools/definitions/find-events.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/find-events.tool.js +242 -0
- package/dist/mcp-server/tools/definitions/find-events.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-ephemeris.tool.d.ts +62 -0
- package/dist/mcp-server/tools/definitions/get-ephemeris.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-ephemeris.tool.js +161 -0
- package/dist/mcp-server/tools/definitions/get-ephemeris.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-moon-phase.tool.d.ts +53 -0
- package/dist/mcp-server/tools/definitions/get-moon-phase.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-moon-phase.tool.js +109 -0
- package/dist/mcp-server/tools/definitions/get-moon-phase.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-rise-set.tool.d.ts +100 -0
- package/dist/mcp-server/tools/definitions/get-rise-set.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-rise-set.tool.js +200 -0
- package/dist/mcp-server/tools/definitions/get-rise-set.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-satellite-passes.tool.d.ts +77 -0
- package/dist/mcp-server/tools/definitions/get-satellite-passes.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-satellite-passes.tool.js +180 -0
- package/dist/mcp-server/tools/definitions/get-satellite-passes.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-sky-position.tool.d.ts +99 -0
- package/dist/mcp-server/tools/definitions/get-sky-position.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-sky-position.tool.js +196 -0
- package/dist/mcp-server/tools/definitions/get-sky-position.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-visible.tool.d.ts +104 -0
- package/dist/mcp-server/tools/definitions/list-visible.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-visible.tool.js +151 -0
- package/dist/mcp-server/tools/definitions/list-visible.tool.js.map +1 -0
- package/dist/services/ephemeris/body-data.d.ts +25 -0
- package/dist/services/ephemeris/body-data.d.ts.map +1 -0
- package/dist/services/ephemeris/body-data.js +24 -0
- package/dist/services/ephemeris/body-data.js.map +1 -0
- package/dist/services/ephemeris/ephemeris-service.d.ts +93 -0
- package/dist/services/ephemeris/ephemeris-service.d.ts.map +1 -0
- package/dist/services/ephemeris/ephemeris-service.js +742 -0
- package/dist/services/ephemeris/ephemeris-service.js.map +1 -0
- package/dist/services/ephemeris/star-catalog.d.ts +17 -0
- package/dist/services/ephemeris/star-catalog.d.ts.map +1 -0
- package/dist/services/ephemeris/star-catalog.js +273 -0
- package/dist/services/ephemeris/star-catalog.js.map +1 -0
- package/dist/services/ephemeris/types.d.ts +150 -0
- package/dist/services/ephemeris/types.d.ts.map +1 -0
- package/dist/services/ephemeris/types.js +33 -0
- package/dist/services/ephemeris/types.js.map +1 -0
- package/dist/services/horizons/horizons-service.d.ts +47 -0
- package/dist/services/horizons/horizons-service.d.ts.map +1 -0
- package/dist/services/horizons/horizons-service.js +229 -0
- package/dist/services/horizons/horizons-service.js.map +1 -0
- package/dist/services/horizons/types.d.ts +21 -0
- package/dist/services/horizons/types.d.ts.map +1 -0
- package/dist/services/horizons/types.js +6 -0
- package/dist/services/horizons/types.js.map +1 -0
- package/dist/services/satellite/satellite-service.d.ts +48 -0
- package/dist/services/satellite/satellite-service.d.ts.map +1 -0
- package/dist/services/satellite/satellite-service.js +231 -0
- package/dist/services/satellite/satellite-service.js.map +1 -0
- package/dist/services/satellite/types.d.ts +32 -0
- package/dist/services/satellite/types.d.ts.map +1 -0
- package/dist/services/satellite/types.js +6 -0
- package/dist/services/satellite/types.js.map +1 -0
- package/package.json +104 -0
- package/server.json +139 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HorizonsService — gated extension wrapping the keyless JPL Horizons
|
|
3
|
+
* HTTP API for small-body (asteroid/comet) and spacecraft ephemerides that the
|
|
4
|
+
* in-process major-body engine cannot cover. The only network-touching code here
|
|
5
|
+
* besides the satellite extension: it carries its own timeout + retry boundary and
|
|
6
|
+
* degrades loudly (throws serviceUnavailable / notFound), never substituting core
|
|
7
|
+
* output. Parses the OBSERVER ephemeris table between Horizons' $$SOE/$$EOE markers.
|
|
8
|
+
* @module services/horizons/horizons-service
|
|
9
|
+
*/
|
|
10
|
+
import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
import { fetchWithTimeout, requestContextService, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
12
|
+
/** Cap on inline ephemeris rows; beyond this the result truncates with disclosure. */
|
|
13
|
+
const MAX_ROWS = 200;
|
|
14
|
+
export class HorizonsService {
|
|
15
|
+
baseUrl;
|
|
16
|
+
timeoutMs;
|
|
17
|
+
constructor(baseUrl, timeoutMs) {
|
|
18
|
+
this.baseUrl = baseUrl;
|
|
19
|
+
this.timeoutMs = timeoutMs;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fetch an OBSERVER ephemeris for a small body. When an observer is supplied the
|
|
23
|
+
* coordinates are topocentric and alt/az is included; otherwise geocentric.
|
|
24
|
+
*/
|
|
25
|
+
async ephemeris(designation, start, stop, step, ctx, observer) {
|
|
26
|
+
const reqCtx = requestContextService.createRequestContext({
|
|
27
|
+
operation: 'HorizonsService.ephemeris',
|
|
28
|
+
parentContext: { requestId: ctx.requestId, traceId: ctx.traceId },
|
|
29
|
+
});
|
|
30
|
+
const url = this.buildUrl(designation, start, stop, step, observer);
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = await withRetry(async () => {
|
|
34
|
+
const response = await fetchWithTimeout(url, this.timeoutMs, reqCtx, {
|
|
35
|
+
signal: ctx.signal,
|
|
36
|
+
});
|
|
37
|
+
return response.text();
|
|
38
|
+
}, {
|
|
39
|
+
operation: 'HorizonsService.ephemeris',
|
|
40
|
+
context: reqCtx,
|
|
41
|
+
baseDelayMs: 2000,
|
|
42
|
+
signal: ctx.signal,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
// fetchWithTimeout throws a status-mapped McpError on any non-2xx whose data
|
|
47
|
+
// carries raw upstream internals (URL, statusCode, responseBody). A transport
|
|
48
|
+
// failure is always horizons_unavailable here — Horizons signals a genuine
|
|
49
|
+
// no-match with a 200 body (handled in parse), not an HTTP error status. Map
|
|
50
|
+
// to the typed contract with clean data so nothing upstream leaks to the client.
|
|
51
|
+
throw serviceUnavailable(`Failed to fetch an ephemeris for "${designation}" from JPL Horizons.`, {
|
|
52
|
+
reason: 'horizons_unavailable',
|
|
53
|
+
recovery: { hint: 'JPL Horizons is degraded or timed out; retry in a few minutes.' },
|
|
54
|
+
}, { cause: err instanceof Error ? err : undefined });
|
|
55
|
+
}
|
|
56
|
+
return this.parse(designation, text, !!observer);
|
|
57
|
+
}
|
|
58
|
+
/** Build the Horizons GET URL with quoted, URL-encoded parameters. */
|
|
59
|
+
buildUrl(designation, start, stop, step, observer) {
|
|
60
|
+
const params = new URLSearchParams({
|
|
61
|
+
format: 'text',
|
|
62
|
+
COMMAND: `'${designation}'`,
|
|
63
|
+
EPHEM_TYPE: 'OBSERVER',
|
|
64
|
+
CENTER: observer ? "'coord@399'" : "'500@399'",
|
|
65
|
+
START_TIME: `'${start}'`,
|
|
66
|
+
STOP_TIME: `'${stop}'`,
|
|
67
|
+
STEP_SIZE: `'${step}'`,
|
|
68
|
+
// QUANTITIES 1=RA/Dec, 9=APmag/S-brt, 20=delta/deldot. Add 4=azimuth/elevation
|
|
69
|
+
// for a topocentric observer so the response carries the alt/az columns parseRow
|
|
70
|
+
// reads when hasObserver — without it the columns shift and delta lands undefined.
|
|
71
|
+
QUANTITIES: observer ? "'1,4,9,20'" : "'1,9,20'",
|
|
72
|
+
CSV_FORMAT: 'YES',
|
|
73
|
+
ANG_FORMAT: 'DEG',
|
|
74
|
+
EXTRA_PREC: 'YES',
|
|
75
|
+
});
|
|
76
|
+
if (observer) {
|
|
77
|
+
params.set('COORD_TYPE', 'GEODETIC');
|
|
78
|
+
// SITE_COORD is E-longitude, latitude, height(km): "lon,lat,km".
|
|
79
|
+
params.set('SITE_COORD', `'${observer.longitude},${observer.latitude},${(observer.elevation / 1000).toFixed(6)}'`);
|
|
80
|
+
}
|
|
81
|
+
return `${this.baseUrl}?${params.toString()}`;
|
|
82
|
+
}
|
|
83
|
+
/** Parse the CSV OBSERVER table between $$SOE and $$EOE. */
|
|
84
|
+
parse(designation, text, hasObserver) {
|
|
85
|
+
const hasBlock = text.includes('$$SOE');
|
|
86
|
+
const looksUnmatched = /No matches found|Cannot interpret|No ephemeris|Matching small-bodies/i.test(text);
|
|
87
|
+
if (looksUnmatched && !hasBlock) {
|
|
88
|
+
throw notFound(`JPL Horizons has no match for designation "${designation}".`, {
|
|
89
|
+
reason: 'body_not_found',
|
|
90
|
+
recovery: {
|
|
91
|
+
hint: 'Use a record-resolving form: a numbered asteroid as "<number>;" (e.g. "433;"), a periodic comet as "DES=<designation>;CAP" (e.g. "DES=1P;CAP"), or a spacecraft as its negative SPK-ID. Verify the designation at ssd.jpl.nasa.gov/tools/sbdb_lookup.html.',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const soe = text.indexOf('$$SOE');
|
|
96
|
+
const eoe = text.indexOf('$$EOE');
|
|
97
|
+
if (soe === -1 || eoe === -1) {
|
|
98
|
+
throw serviceUnavailable('JPL Horizons returned an unexpected response with no ephemeris block.', {
|
|
99
|
+
reason: 'horizons_unavailable',
|
|
100
|
+
recovery: {
|
|
101
|
+
hint: 'Horizons may be degraded or rejected the request; retry in a few minutes.',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const block = text.slice(soe + 5, eoe).trim();
|
|
106
|
+
const rows = block.split('\n').filter((line) => line.trim().length > 0);
|
|
107
|
+
const points = [];
|
|
108
|
+
let truncated = false;
|
|
109
|
+
for (const row of rows) {
|
|
110
|
+
if (points.length >= MAX_ROWS) {
|
|
111
|
+
truncated = true;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
const point = this.parseRow(row, hasObserver);
|
|
115
|
+
if (point)
|
|
116
|
+
points.push(point);
|
|
117
|
+
}
|
|
118
|
+
if (points.length === 0) {
|
|
119
|
+
throw serviceUnavailable('JPL Horizons returned an ephemeris block with no parsable rows.', {
|
|
120
|
+
reason: 'horizons_unavailable',
|
|
121
|
+
recovery: {
|
|
122
|
+
hint: 'The step or time span may be invalid; adjust and retry, or retry in a few minutes.',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return { designation, points, truncated };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Parse one CSV row (CSV_FORMAT YES). The column layout depends on whether an
|
|
130
|
+
* observer was supplied, because buildUrl requests azimuth/elevation (QUANTITIES
|
|
131
|
+
* '4') only for a topocentric observer:
|
|
132
|
+
* geocentric ('1,9,20'): date, flag, flag, RA(deg), DEC(deg), APmag, S-brt, delta(AU), deldot
|
|
133
|
+
* topocentric ('1,4,9,20'): date, flag, flag, RA(deg), DEC(deg), Azimuth(deg), Elevation(deg), APmag, S-brt, delta(AU), deldot
|
|
134
|
+
* Columns 1-2 are solar-presence / lunar-illumination flags, often blank.
|
|
135
|
+
*/
|
|
136
|
+
parseRow(row, hasObserver) {
|
|
137
|
+
const cols = row.split(',').map((c) => c.trim());
|
|
138
|
+
if (cols.length < 5)
|
|
139
|
+
return null;
|
|
140
|
+
// Column 0 is the calendar date; columns 1-2 are presence flags (often blank).
|
|
141
|
+
const dateStr = cols[0];
|
|
142
|
+
if (!dateStr)
|
|
143
|
+
return null;
|
|
144
|
+
const time = this.parseHorizonsDate(dateStr);
|
|
145
|
+
if (!time)
|
|
146
|
+
return null;
|
|
147
|
+
// After the date + two flag columns, the angular quantities begin.
|
|
148
|
+
const numeric = cols
|
|
149
|
+
.slice(3)
|
|
150
|
+
.map((c) => (c === '' || c === 'n.a.' ? null : Number.parseFloat(c)));
|
|
151
|
+
let idx = 0;
|
|
152
|
+
const ra = numeric[idx++];
|
|
153
|
+
const dec = numeric[idx++];
|
|
154
|
+
let azimuth = null;
|
|
155
|
+
let altitude = null;
|
|
156
|
+
if (hasObserver) {
|
|
157
|
+
azimuth = numeric[idx++] ?? null;
|
|
158
|
+
altitude = numeric[idx++] ?? null;
|
|
159
|
+
}
|
|
160
|
+
const apMag = numeric[idx++];
|
|
161
|
+
// s-brt is skipped; delta (distance AU) follows.
|
|
162
|
+
idx++; // s-brt column
|
|
163
|
+
const delta = numeric[idx++];
|
|
164
|
+
if (ra == null || dec == null)
|
|
165
|
+
return null;
|
|
166
|
+
const point = {
|
|
167
|
+
timeUtc: time,
|
|
168
|
+
raHours: ra / 15, // Horizons RA is in degrees; convert to sidereal hours.
|
|
169
|
+
decDegrees: dec,
|
|
170
|
+
distanceAu: delta ?? Number.NaN,
|
|
171
|
+
magnitude: apMag ?? null,
|
|
172
|
+
};
|
|
173
|
+
if (hasObserver && altitude !== null && azimuth !== null) {
|
|
174
|
+
point.altitudeDegrees = altitude;
|
|
175
|
+
point.azimuthDegrees = azimuth;
|
|
176
|
+
}
|
|
177
|
+
return point;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Convert a Horizons calendar date to ISO 8601 UTC. The OBSERVER table emits
|
|
181
|
+
* "2024-Apr-08 18:00" (HH:MM) at hour/day steps and "…18:00:00.0000" at finer
|
|
182
|
+
* steps, so seconds are optional. Horizons dates are always UT — parse them as
|
|
183
|
+
* UTC explicitly; never let a bare string fall to local-time `new Date(...)`.
|
|
184
|
+
*/
|
|
185
|
+
parseHorizonsDate(raw) {
|
|
186
|
+
const cleaned = raw.replace(/^A\.D\.\s*/, '').trim();
|
|
187
|
+
const match = cleaned.match(/^(\d{4})-([A-Za-z]{3})-(\d{2})\s+(\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?/);
|
|
188
|
+
if (!match) {
|
|
189
|
+
// Append Z so an unzoned fallback string is read as UTC, not host-local time.
|
|
190
|
+
const d = new Date(/[zZ]|[+-]\d{2}:?\d{2}$/.test(cleaned) ? cleaned : `${cleaned}Z`);
|
|
191
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
192
|
+
}
|
|
193
|
+
const months = {
|
|
194
|
+
Jan: '01',
|
|
195
|
+
Feb: '02',
|
|
196
|
+
Mar: '03',
|
|
197
|
+
Apr: '04',
|
|
198
|
+
May: '05',
|
|
199
|
+
Jun: '06',
|
|
200
|
+
Jul: '07',
|
|
201
|
+
Aug: '08',
|
|
202
|
+
Sep: '09',
|
|
203
|
+
Oct: '10',
|
|
204
|
+
Nov: '11',
|
|
205
|
+
Dec: '12',
|
|
206
|
+
};
|
|
207
|
+
const [, year, monName, day, hh, mm, ss] = match;
|
|
208
|
+
const monNum = monName ? months[monName] : undefined;
|
|
209
|
+
if (!monNum)
|
|
210
|
+
return null;
|
|
211
|
+
const iso = `${year}-${monNum}-${day}T${hh}:${mm}:${ss ?? '00'}Z`;
|
|
212
|
+
const d = new Date(iso);
|
|
213
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// --- Init / accessor pattern ------------------------------------------------
|
|
217
|
+
let _service;
|
|
218
|
+
/** Initialize the Horizons service with the configured endpoint and timeout. */
|
|
219
|
+
export function initHorizonsService(baseUrl, timeoutMs) {
|
|
220
|
+
_service = new HorizonsService(baseUrl, timeoutMs);
|
|
221
|
+
}
|
|
222
|
+
/** Accessor — throws if not initialized (the gate is off). */
|
|
223
|
+
export function getHorizonsService() {
|
|
224
|
+
if (!_service) {
|
|
225
|
+
throw new Error('HorizonsService not initialized — enable ASTRONOMY_ENABLE_HORIZONS');
|
|
226
|
+
}
|
|
227
|
+
return _service;
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=horizons-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"horizons-service.js","sourceRoot":"","sources":["../../../src/services/horizons/horizons-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIlG,sFAAsF;AACtF,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,OAAO,eAAe;IAEP;IACA;IAFnB,YACmB,OAAe,EACf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C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5D,CAAC;CACF;AAED,+EAA+E;AAE/E,IAAI,QAAqC,CAAC;AAE1C,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,SAAiB;IACpE,QAAQ,GAAG,IAAI,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Domain types for the JPL Horizons small-body ephemeris extension.
|
|
3
|
+
* @module services/horizons/types
|
|
4
|
+
*/
|
|
5
|
+
/** One step of a Horizons OBSERVER ephemeris, normalized to the wire units. */
|
|
6
|
+
export interface EphemerisPoint {
|
|
7
|
+
altitudeDegrees?: number;
|
|
8
|
+
azimuthDegrees?: number;
|
|
9
|
+
decDegrees: number;
|
|
10
|
+
distanceAu: number;
|
|
11
|
+
magnitude: number | null;
|
|
12
|
+
raHours: number;
|
|
13
|
+
timeUtc: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EphemerisResult {
|
|
16
|
+
designation: string;
|
|
17
|
+
points: EphemerisPoint[];
|
|
18
|
+
/** True when Horizons returned more rows than the inline cap; reduce by widening `step`. */
|
|
19
|
+
truncated: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/horizons/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,4FAA4F;IAC5F,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/horizons/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SatelliteService — gated extension that predicts visible satellite
|
|
3
|
+
* passes. Fetches the current TLE from CelesTrak (keyless, cached briefly in
|
|
4
|
+
* process per CelesTrak's refetch guidance), propagates with SGP4 via satellite.js
|
|
5
|
+
* (offline), and returns above-horizon passes. A pass is "visible" only when the
|
|
6
|
+
* satellite is sunlit at peak AND the observer's sky is dark — the ground-darkness
|
|
7
|
+
* gate reuses the core sun-altitude logic. Network-touching code carries its own
|
|
8
|
+
* timeout + retry boundary and degrades loudly; it never substitutes core output.
|
|
9
|
+
* @module services/satellite/satellite-service
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@cyanheads/mcp-ts-core';
|
|
12
|
+
import type { ObserverInput } from '../ephemeris/types.js';
|
|
13
|
+
import type { SatellitePassResult, Tle } from './types.js';
|
|
14
|
+
export declare class SatelliteService {
|
|
15
|
+
private readonly baseUrl;
|
|
16
|
+
private readonly timeoutMs;
|
|
17
|
+
private readonly cacheTtlMs;
|
|
18
|
+
private readonly cache;
|
|
19
|
+
constructor(baseUrl: string, timeoutMs: number, cacheTtlMs: number);
|
|
20
|
+
/** Fetch a current TLE for a NORAD ID, using the in-process TTL cache. */
|
|
21
|
+
fetchTle(noradId: number, ctx: Context): Promise<Tle>;
|
|
22
|
+
/**
|
|
23
|
+
* Map a fetch/transport McpError onto the typed contract with leak-free data.
|
|
24
|
+
* A NotFound (CelesTrak's 404 for an uncatalogued object) becomes tle_not_found;
|
|
25
|
+
* everything else (5xx, timeout, network) becomes celestrak_unavailable. The
|
|
26
|
+
* original error rides as `cause` for server-side logs but never reaches the client.
|
|
27
|
+
*/
|
|
28
|
+
private classifyFetchError;
|
|
29
|
+
/** Parse a CelesTrak TLE response (optional name line + the two element lines). */
|
|
30
|
+
private parseTle;
|
|
31
|
+
/**
|
|
32
|
+
* Predict visible passes over the next `days` from `start`. Steps the orbit with
|
|
33
|
+
* SGP4, brackets above-horizon intervals, and keeps passes whose peak is sunlit
|
|
34
|
+
* and over a dark-enough ground.
|
|
35
|
+
*/
|
|
36
|
+
predictPasses(tle: Tle, noradId: number, observer: ObserverInput, days: number, start: Date, formatLocal?: (d: Date) => string): SatellitePassResult;
|
|
37
|
+
/** Compute look angles (az/el) of the satellite from the observer at one instant. */
|
|
38
|
+
private lookAngles;
|
|
39
|
+
/** True when the satellite is in sunlight (not in Earth's umbra) at the given time. */
|
|
40
|
+
private isSunlit;
|
|
41
|
+
/** True when the observer's sky is dark enough (Sun below civil dusk) for a naked-eye pass. */
|
|
42
|
+
private isGroundDark;
|
|
43
|
+
}
|
|
44
|
+
/** Initialize the satellite service with the configured endpoint, timeout, and cache TTL. */
|
|
45
|
+
export declare function initSatelliteService(baseUrl: string, timeoutMs: number, cacheTtlMs: number): void;
|
|
46
|
+
/** Accessor — throws if not initialized (the gate is off). */
|
|
47
|
+
export declare function getSatelliteService(): SatelliteService;
|
|
48
|
+
//# sourceMappingURL=satellite-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satellite-service.d.ts","sourceRoot":"","sources":["../../../src/services/satellite/satellite-service.ts"],"names":[],"mappings":"AAAA;;;;;;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2
|
+
* @fileoverview SatelliteService — gated extension that predicts visible satellite
|
|
3
|
+
* passes. Fetches the current TLE from CelesTrak (keyless, cached briefly in
|
|
4
|
+
* process per CelesTrak's refetch guidance), propagates with SGP4 via satellite.js
|
|
5
|
+
* (offline), and returns above-horizon passes. A pass is "visible" only when the
|
|
6
|
+
* satellite is sunlit at peak AND the observer's sky is dark — the ground-darkness
|
|
7
|
+
* gate reuses the core sun-altitude logic. Network-touching code carries its own
|
|
8
|
+
* timeout + retry boundary and degrades loudly; it never substitutes core output.
|
|
9
|
+
* @module services/satellite/satellite-service
|
|
10
|
+
*/
|
|
11
|
+
import { JsonRpcErrorCode, McpError, notFound, serviceUnavailable, } from '@cyanheads/mcp-ts-core/errors';
|
|
12
|
+
import { fetchWithTimeout, requestContextService, withRetry } from '@cyanheads/mcp-ts-core/utils';
|
|
13
|
+
import { Body, Equator, Horizon, MakeTime, Observer } from 'astronomy-engine';
|
|
14
|
+
import { ecfToLookAngles, eciToEcf, gstime, jday, propagate, shadowFraction, sunPos, twoline2satrec, } from 'satellite.js';
|
|
15
|
+
const DEG = 180 / Math.PI;
|
|
16
|
+
/** Minimum peak elevation (deg) for a pass to count — below this it grazes the horizon. */
|
|
17
|
+
const MIN_PEAK_ELEVATION = 10;
|
|
18
|
+
/** Propagation step in seconds while scanning for passes. */
|
|
19
|
+
const STEP_SECONDS = 30;
|
|
20
|
+
/** Ground is "dark enough" for a naked-eye pass when the Sun is below this altitude (civil dusk). */
|
|
21
|
+
const GROUND_DARK_SUN_ALT = -6;
|
|
22
|
+
export class SatelliteService {
|
|
23
|
+
baseUrl;
|
|
24
|
+
timeoutMs;
|
|
25
|
+
cacheTtlMs;
|
|
26
|
+
cache = new Map();
|
|
27
|
+
constructor(baseUrl, timeoutMs, cacheTtlMs) {
|
|
28
|
+
this.baseUrl = baseUrl;
|
|
29
|
+
this.timeoutMs = timeoutMs;
|
|
30
|
+
this.cacheTtlMs = cacheTtlMs;
|
|
31
|
+
}
|
|
32
|
+
/** Fetch a current TLE for a NORAD ID, using the in-process TTL cache. */
|
|
33
|
+
async fetchTle(noradId, ctx) {
|
|
34
|
+
const cached = this.cache.get(noradId);
|
|
35
|
+
if (cached && cached.expiresAt > Date.now())
|
|
36
|
+
return cached.tle;
|
|
37
|
+
const reqCtx = requestContextService.createRequestContext({
|
|
38
|
+
operation: 'SatelliteService.fetchTle',
|
|
39
|
+
parentContext: { requestId: ctx.requestId, traceId: ctx.traceId },
|
|
40
|
+
});
|
|
41
|
+
const url = `${this.baseUrl}?CATNR=${noradId}&FORMAT=TLE`;
|
|
42
|
+
let text;
|
|
43
|
+
try {
|
|
44
|
+
text = await withRetry(async () => {
|
|
45
|
+
const response = await fetchWithTimeout(url, this.timeoutMs, reqCtx, {
|
|
46
|
+
signal: ctx.signal,
|
|
47
|
+
});
|
|
48
|
+
return response.text();
|
|
49
|
+
}, {
|
|
50
|
+
operation: 'SatelliteService.fetchTle',
|
|
51
|
+
context: reqCtx,
|
|
52
|
+
baseDelayMs: 1000,
|
|
53
|
+
signal: ctx.signal,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// fetchWithTimeout throws a status-mapped McpError on any non-2xx whose
|
|
58
|
+
// data carries raw upstream internals (URL, statusCode, responseBody). Map
|
|
59
|
+
// it into the typed contract with clean data so nothing upstream leaks to
|
|
60
|
+
// the client. CelesTrak answers a missing object with 404 → NotFound.
|
|
61
|
+
throw this.classifyFetchError(err, noradId);
|
|
62
|
+
}
|
|
63
|
+
const tle = this.parseTle(text, noradId);
|
|
64
|
+
this.cache.set(noradId, { tle, expiresAt: Date.now() + this.cacheTtlMs });
|
|
65
|
+
return tle;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Map a fetch/transport McpError onto the typed contract with leak-free data.
|
|
69
|
+
* A NotFound (CelesTrak's 404 for an uncatalogued object) becomes tle_not_found;
|
|
70
|
+
* everything else (5xx, timeout, network) becomes celestrak_unavailable. The
|
|
71
|
+
* original error rides as `cause` for server-side logs but never reaches the client.
|
|
72
|
+
*/
|
|
73
|
+
classifyFetchError(err, noradId) {
|
|
74
|
+
if (err instanceof McpError && err.code === JsonRpcErrorCode.NotFound) {
|
|
75
|
+
return notFound(`CelesTrak has no current element set for NORAD ID ${noradId}.`, {
|
|
76
|
+
reason: 'tle_not_found',
|
|
77
|
+
recovery: {
|
|
78
|
+
hint: 'Verify the catalog number at celestrak.org; the object may have decayed or never been catalogued.',
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return serviceUnavailable(`Failed to fetch a TLE for NORAD ID ${noradId} from CelesTrak.`, {
|
|
83
|
+
reason: 'celestrak_unavailable',
|
|
84
|
+
recovery: { hint: 'CelesTrak is degraded or timed out; retry in a few minutes.' },
|
|
85
|
+
}, { cause: err instanceof Error ? err : undefined });
|
|
86
|
+
}
|
|
87
|
+
/** Parse a CelesTrak TLE response (optional name line + the two element lines). */
|
|
88
|
+
parseTle(text, noradId) {
|
|
89
|
+
const trimmed = text.trim();
|
|
90
|
+
if (/No GP data found|Invalid query/i.test(trimmed) || trimmed.length === 0) {
|
|
91
|
+
throw notFound(`CelesTrak has no current element set for NORAD ID ${noradId}.`, {
|
|
92
|
+
reason: 'tle_not_found',
|
|
93
|
+
recovery: {
|
|
94
|
+
hint: 'Verify the catalog number at celestrak.org; the object may have decayed or never been catalogued.',
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const lines = trimmed.split('\n').map((l) => l.trimEnd());
|
|
99
|
+
const line1Index = lines.findIndex((l) => l.startsWith('1 '));
|
|
100
|
+
const line2Index = lines.findIndex((l) => l.startsWith('2 '));
|
|
101
|
+
const line1 = line1Index === -1 ? undefined : lines[line1Index];
|
|
102
|
+
const line2 = line2Index === -1 ? undefined : lines[line2Index];
|
|
103
|
+
if (!line1 || !line2) {
|
|
104
|
+
throw serviceUnavailable(`CelesTrak returned an unparsable response for NORAD ID ${noradId}.`, {
|
|
105
|
+
reason: 'celestrak_unavailable',
|
|
106
|
+
recovery: { hint: 'CelesTrak may be degraded; retry in a few minutes.' },
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const nameLine = line1Index > 0 ? lines[line1Index - 1]?.trim() : undefined;
|
|
110
|
+
return { ...(nameLine ? { name: nameLine } : {}), line1, line2 };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Predict visible passes over the next `days` from `start`. Steps the orbit with
|
|
114
|
+
* SGP4, brackets above-horizon intervals, and keeps passes whose peak is sunlit
|
|
115
|
+
* and over a dark-enough ground.
|
|
116
|
+
*/
|
|
117
|
+
predictPasses(tle, noradId, observer, days, start, formatLocal) {
|
|
118
|
+
const satrec = twoline2satrec(tle.line1, tle.line2);
|
|
119
|
+
const observerGd = {
|
|
120
|
+
longitude: (observer.longitude * Math.PI) / 180,
|
|
121
|
+
latitude: (observer.latitude * Math.PI) / 180,
|
|
122
|
+
height: observer.elevation / 1000,
|
|
123
|
+
};
|
|
124
|
+
const engineObserver = new Observer(observer.latitude, observer.longitude, observer.elevation);
|
|
125
|
+
const passes = [];
|
|
126
|
+
const totalSteps = Math.floor((days * 86400) / STEP_SECONDS);
|
|
127
|
+
let inPass = false;
|
|
128
|
+
let riseTime = null;
|
|
129
|
+
let riseAz = 0;
|
|
130
|
+
let peakElevation = -90;
|
|
131
|
+
let peakAz = 0;
|
|
132
|
+
let peakTime = null;
|
|
133
|
+
let lastAz = 0;
|
|
134
|
+
for (let i = 0; i <= totalSteps; i++) {
|
|
135
|
+
const t = new Date(start.getTime() + i * STEP_SECONDS * 1000);
|
|
136
|
+
const look = this.lookAngles(satrec, t, observerGd);
|
|
137
|
+
if (!look)
|
|
138
|
+
continue;
|
|
139
|
+
const elevationDeg = look.elevation * DEG;
|
|
140
|
+
const azimuthDeg = (((look.azimuth * DEG) % 360) + 360) % 360;
|
|
141
|
+
if (elevationDeg > 0) {
|
|
142
|
+
if (!inPass) {
|
|
143
|
+
inPass = true;
|
|
144
|
+
riseTime = t;
|
|
145
|
+
riseAz = azimuthDeg;
|
|
146
|
+
peakElevation = elevationDeg;
|
|
147
|
+
peakAz = azimuthDeg;
|
|
148
|
+
peakTime = t;
|
|
149
|
+
}
|
|
150
|
+
else if (elevationDeg > peakElevation) {
|
|
151
|
+
peakElevation = elevationDeg;
|
|
152
|
+
peakAz = azimuthDeg;
|
|
153
|
+
peakTime = t;
|
|
154
|
+
}
|
|
155
|
+
lastAz = azimuthDeg;
|
|
156
|
+
}
|
|
157
|
+
else if (inPass) {
|
|
158
|
+
// Pass just ended at the previous step.
|
|
159
|
+
inPass = false;
|
|
160
|
+
if (riseTime && peakTime && peakElevation >= MIN_PEAK_ELEVATION) {
|
|
161
|
+
const setTime = t;
|
|
162
|
+
const sunlit = this.isSunlit(satrec, peakTime);
|
|
163
|
+
const groundDark = this.isGroundDark(engineObserver, peakTime);
|
|
164
|
+
if (sunlit && groundDark) {
|
|
165
|
+
const pass = {
|
|
166
|
+
riseUtc: riseTime.toISOString(),
|
|
167
|
+
peakUtc: peakTime.toISOString(),
|
|
168
|
+
setUtc: setTime.toISOString(),
|
|
169
|
+
peakAltitudeDegrees: peakElevation,
|
|
170
|
+
riseAzimuthDegrees: riseAz,
|
|
171
|
+
setAzimuthDegrees: lastAz,
|
|
172
|
+
peakAzimuthDegrees: peakAz,
|
|
173
|
+
durationSeconds: (setTime.getTime() - riseTime.getTime()) / 1000,
|
|
174
|
+
sunlit,
|
|
175
|
+
};
|
|
176
|
+
if (formatLocal) {
|
|
177
|
+
pass.riseLocal = formatLocal(riseTime);
|
|
178
|
+
pass.peakLocal = formatLocal(peakTime);
|
|
179
|
+
pass.setLocal = formatLocal(setTime);
|
|
180
|
+
}
|
|
181
|
+
passes.push(pass);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
riseTime = null;
|
|
185
|
+
peakTime = null;
|
|
186
|
+
peakElevation = -90;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return { noradId, ...(tle.name ? { satelliteName: tle.name } : {}), passes };
|
|
190
|
+
}
|
|
191
|
+
/** Compute look angles (az/el) of the satellite from the observer at one instant. */
|
|
192
|
+
lookAngles(satrec, date, observerGd) {
|
|
193
|
+
const pv = propagate(satrec, date);
|
|
194
|
+
if (!pv)
|
|
195
|
+
return null;
|
|
196
|
+
const gmst = gstime(date);
|
|
197
|
+
const ecf = eciToEcf(pv.position, gmst);
|
|
198
|
+
const look = ecfToLookAngles(observerGd, ecf);
|
|
199
|
+
return { azimuth: look.azimuth, elevation: look.elevation };
|
|
200
|
+
}
|
|
201
|
+
/** True when the satellite is in sunlight (not in Earth's umbra) at the given time. */
|
|
202
|
+
isSunlit(satrec, date) {
|
|
203
|
+
const pv = propagate(satrec, date);
|
|
204
|
+
if (!pv)
|
|
205
|
+
return false;
|
|
206
|
+
const sun = sunPos(jday(date));
|
|
207
|
+
const fraction = shadowFraction(sun.rsun, pv.position);
|
|
208
|
+
return fraction < 0.5;
|
|
209
|
+
}
|
|
210
|
+
/** True when the observer's sky is dark enough (Sun below civil dusk) for a naked-eye pass. */
|
|
211
|
+
isGroundDark(observer, date) {
|
|
212
|
+
const time = MakeTime(date);
|
|
213
|
+
const eq = Equator(Body.Sun, time, observer, true, true);
|
|
214
|
+
const hor = Horizon(time, observer, eq.ra, eq.dec, 'normal');
|
|
215
|
+
return hor.altitude < GROUND_DARK_SUN_ALT;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// --- Init / accessor pattern ------------------------------------------------
|
|
219
|
+
let _service;
|
|
220
|
+
/** Initialize the satellite service with the configured endpoint, timeout, and cache TTL. */
|
|
221
|
+
export function initSatelliteService(baseUrl, timeoutMs, cacheTtlMs) {
|
|
222
|
+
_service = new SatelliteService(baseUrl, timeoutMs, cacheTtlMs);
|
|
223
|
+
}
|
|
224
|
+
/** Accessor — throws if not initialized (the gate is off). */
|
|
225
|
+
export function getSatelliteService() {
|
|
226
|
+
if (!_service) {
|
|
227
|
+
throw new Error('SatelliteService not initialized — enable ASTRONOMY_ENABLE_SATELLITES');
|
|
228
|
+
}
|
|
229
|
+
return _service;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=satellite-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satellite-service.js","sourceRoot":"","sources":["../../../src/services/satellite/satellite-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EACL,eAAe,EACf,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EAET,cAAc,EACd,MAAM,EACN,cAAc,GACf,MAAM,cAAc,CAAC;AAItB,MAAM,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1B,2FAA2F;AAC3F,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,6DAA6D;AAC7D,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,qGAAqG;AACrG,MAAM,mBAAmB,GAAG,CAAC,CAAC,CAAC;AAO/B,MAAM,OAAO,gBAAgB;IAIR;IACA;IACA;IALF,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEtD,YACmB,OAAe,EACf,SAAiB,EACjB,UAAkB;QAFlB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAQ;IAClC,CAAC;IAEJ,0EAA0E;IAC1E,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,GAAY;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,K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ass of a satellite over an observer. */
|
|
6
|
+
export interface SatellitePass {
|
|
7
|
+
durationSeconds: number;
|
|
8
|
+
peakAltitudeDegrees: number;
|
|
9
|
+
peakAzimuthDegrees: number;
|
|
10
|
+
peakLocal?: string;
|
|
11
|
+
peakUtc: string;
|
|
12
|
+
riseAzimuthDegrees: number;
|
|
13
|
+
riseLocal?: string;
|
|
14
|
+
riseUtc: string;
|
|
15
|
+
setAzimuthDegrees: number;
|
|
16
|
+
setLocal?: string;
|
|
17
|
+
setUtc: string;
|
|
18
|
+
/** Satellite is sunlit at peak (naked-eye visible only when this is true and the ground is dark). */
|
|
19
|
+
sunlit: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SatellitePassResult {
|
|
22
|
+
noradId: number;
|
|
23
|
+
passes: SatellitePass[];
|
|
24
|
+
satelliteName?: string;
|
|
25
|
+
}
|
|
26
|
+
/** A parsed two-line element set plus its display name. */
|
|
27
|
+
export interface Tle {
|
|
28
|
+
line1: string;
|
|
29
|
+
line2: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/satellite/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,2DAA2D;AAC3D,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/satellite/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|