MCPcopy Create free account
hub / github.com/apache/maka / parseShellRunResourceRef

Function parseShellRunResourceRef

packages/runtime/src/shell-run-contract.ts:193–221  ·  view source on GitHub ↗
(ref: string)

Source from the content-addressed store, hash-verified

191}
192
193export function parseShellRunResourceRef(ref: string): { shellRunId: string } | null {
194 let url: URL;
195 try {
196 url = new URL(ref);
197 } catch {
198 return null;
199 }
200 if (
201 url.protocol !== 'maka:' ||
202 url.hostname !== 'runtime' ||
203 url.username ||
204 url.password ||
205 url.port ||
206 url.search ||
207 url.hash
208 )
209 return null;
210 const match = SHELL_RUN_RESOURCE_PATH_PATTERN.exec(url.pathname);
211 if (!match) return null;
212 const encodedId = match[1];
213 if (!encodedId) return null;
214 try {
215 const shellRunId = decodeURIComponent(encodedId);
216 if (!isShellRunId(shellRunId) || ref !== shellRunResourceRef(shellRunId)) return null;
217 return { shellRunId };
218 } catch {
219 return null;
220 }
221}

Callers 6

isShellRunResourceRefFunction · 0.85
writeStdinMethod · 0.85
stopBackgroundTaskMethod · 0.85
getSessionUpdateMethod · 0.85
getLivePtySnapshotMethod · 0.85
resourceDetailMethod · 0.85

Calls 3

isShellRunIdFunction · 0.90
shellRunResourceRefFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected