MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / sandboxIdFromInstanceId

Function sandboxIdFromInstanceId

packages/worker-utils/src/instance-id.ts:24–36  ·  view source on GitHub ↗
(instanceId: string)

Source from the content-addressed store, hash-verified

22 * Strips dashes and prefixes `ki_` — result is `ki_{32-char-hex}` (35 chars).
23 */
24export function sandboxIdFromInstanceId(instanceId: string): string {
25 if (!isValidInstanceId(instanceId)) {
26 throw new Error('Invalid instanceId: must be a UUID');
27 }
28 const hex = instanceId.replace(/-/g, '');
29 const prefixed = `ki_${hex}`;
30 if (prefixed.length > MAX_SANDBOX_ID_LENGTH) {
31 throw new Error(
32 `instanceId too long: prefixed sandboxId would be ${prefixed.length} chars (max ${MAX_SANDBOX_ID_LENGTH})`
33 );
34 }
35 return prefixed;
36}
37
38/** Returns true if the sandboxId uses the `ki_` instance-keyed format. */
39export function isInstanceKeyedSandboxId(sandboxId: string): boolean {

Callers 4

resolveSandboxIdFunction · 0.90

Calls 2

isValidInstanceIdFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected